From 02fd1c00a10753b6c81fc907daedeaa5d510c317 Mon Sep 17 00:00:00 2001 From: Alexis Jacomy Date: Tue, 3 Oct 2023 16:54:16 +0200 Subject: [PATCH] #1386 - Adds more safeguards to #kill method --- src/sigma.ts | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/sigma.ts b/src/sigma.ts index 416c00c0e..6ca46b63d 100644 --- a/src/sigma.ts +++ b/src/sigma.ts @@ -1820,10 +1820,25 @@ export default class Sigma extends TypedEventEm this.renderHighlightedNodesFrame = null; } + // Destroying WebGL contexts + for (const id in this.webGLContexts) { + const context = this.webGLContexts[id]; + context.getExtension("WEBGL_lose_context")?.loseContext(); + } + // Destroying canvases const container = this.container; while (container.firstChild) container.removeChild(container.firstChild); + + // Destroying remaining collections + this.canvasContexts = {}; + this.webGLContexts = {}; + this.elements = {}; + + this.nodePrograms = {}; + this.nodeHoverPrograms = {}; + this.edgePrograms = {}; } /**