From 2df61459386cd9f43ed35661dda325656402662b Mon Sep 17 00:00:00 2001 From: zplata Date: Mon, 20 Nov 2023 14:37:26 +0000 Subject: [PATCH] patch: Only clean up the Renderer object if it is a CanvasRenderer, as WebGL Renderer does not need to be deleted Original issue: https://github.com/rive-app/rive-wasm/issues/333 Only the canvas renderer can have its emscripten object deleted on cleanup, but not the WebGL one. So just adding a quick check to only delete if it detects the runtime has a canvas renderer. Diffs= c579540d1 patch: Only clean up the Renderer object if it is a CanvasRenderer, as WebGL Renderer does not need to be deleted (#6037) Co-authored-by: Zachary Plata --- .rive_head | 2 +- js/src/rive.ts | 7 +++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/.rive_head b/.rive_head index 50b6c71a..18657e5d 100644 --- a/.rive_head +++ b/.rive_head @@ -1 +1 @@ -fdad661369bfa0092a2de92c02bf106da87977de +c579540d144e3f89bc92149920e37eb78540888e diff --git a/js/src/rive.ts b/js/src/rive.ts index abe8be88..5a22bcda 100644 --- a/js/src/rive.ts +++ b/js/src/rive.ts @@ -1678,8 +1678,11 @@ export class Rive { this.stopRendering(); // Clean up any artboard, animation or state machine instances. this.cleanupInstances(); - // Delete the renderer - this.renderer?.delete(); + // Only CanvasRenderer needs a delete for now, not WebGL.. might be a better + // way to detect this in the future + if (this.runtime?.CanvasRenderer) { + this.renderer?.delete(); + } this.renderer = null; // Delete the rive file this.file?.delete();