diff --git a/src/main-api/Inspector.ts b/src/main-api/Inspector.ts index b8aae5a..724a416 100644 --- a/src/main-api/Inspector.ts +++ b/src/main-api/Inspector.ts @@ -297,7 +297,10 @@ export class Inspector { private width = 1920; private scaleX = 1; private scaleY = 1; - private textureMetrics = new Map(); + // Keyed weakly: a texture that is swapped off a node is never revisited by + // the inspector, and a strong map would pin it (and its bitmap) for the + // lifetime of the renderer. + private textureMetrics = new WeakMap(); // Stable reference so the same function can be passed to both // add/removeEventListener — `.bind()` returns a new fn each call, so binding // inline in destroy() would never actually remove the listener. @@ -1042,6 +1045,15 @@ export class Inspector { }); coreNodeListeners.clear(); + // Animations still running when the node goes away never emit + // `stopped`, so their entry — and the controller it holds — would stay + // in the static activeAnimations map for the lifetime of the page. + Inspector.activeAnimations.forEach((animation, animationId) => { + if (animation.nodeId === node.id) { + this.trackAnimationEnd(animationId, 'cancelled'); + } + }); + this.destroyNode(node); originalDestroy.call(node, isChild); },