fix: release GIF ref on sprite destroy to prevent gifCache leak

Override destroy() in AnimatedGifSprite to call releaseGif() when
a loaded GIF item is deleted from the board. Without this, the
gifCache refCount stays elevated until full canvas teardown.
This commit is contained in:
Hiren Kangad
2026-03-10 20:09:24 +05:30
parent 1f5ab883ce
commit 9af4051b67
@@ -128,6 +128,19 @@ export class AnimatedGifSprite extends Container {
}
}
/** Release ref-counted GIF source on destroy (handles deletion while loaded). */
override destroy(options?: any): void {
if (this.loaded) {
if (this._gif) {
this._gif.stop();
this._playing = false;
}
this.textures.releaseGif(this.assetKey);
this.loaded = false;
}
super.destroy(options);
}
/** Unload GIF to free memory (ref-counted). Called by viewport culling. */
unloadTexture(): void {
if (!this.loaded) return;