From ce17599383b1c5f7d9b19fa87e31eebe19a9475c Mon Sep 17 00:00:00 2001 From: Vaivaswat Date: Fri, 11 Sep 2026 16:17:00 +0530 Subject: [PATCH] fix: run canvas teardown in Renderer3D.remove() Renderer3D declared remove() twice. JS keeps only the last definition, so the first - which detaches the canvas and clears wrappedElt, canvas and elt - has been dead since the second was added for _textCanvas cleanup in ef28cbc7. Renderer2D.remove() has the identical body it was meant to mirror. Fold the teardown into the surviving method so WebGL and WebGPU canvases are actually detached on remove(). --- src/core/p5.Renderer3D.js | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/src/core/p5.Renderer3D.js b/src/core/p5.Renderer3D.js index e59f60fb60..7fbbbabae2 100644 --- a/src/core/p5.Renderer3D.js +++ b/src/core/p5.Renderer3D.js @@ -437,13 +437,6 @@ export class Renderer3D extends Renderer { } } - remove() { - this.wrappedElt.remove(); - this.wrappedElt = null; - this.canvas = null; - this.elt = null; - } - ////////////////////////////////////////////// // Geometry Building ////////////////////////////////////////////// @@ -2176,6 +2169,10 @@ export class Renderer3D extends Renderer { if (this._textCanvas) { this._textCanvas.parentElement.removeChild(this._textCanvas); } + this.wrappedElt.remove(); + this.wrappedElt = null; + this.canvas = null; + this.elt = null; super.remove(); } }