Skip to content

Commit

Permalink
Fix memory leak for video base texture after spritesheet generation
Browse files Browse the repository at this point in the history
  • Loading branch information
Codas committed Oct 4, 2024
1 parent 9eb42c7 commit 9e8ef43
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/canvas-effects/sequencer-sprite-manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ class VideoAsset extends Asset {
// @ts-expect-error can only be null after destroy
this.video = null;
} catch (err) {}
this.texture.destroy();
this.texture.destroy(true);
}
}
class VideoSpritesheetAsset extends Asset {
Expand Down Expand Up @@ -360,11 +360,14 @@ export class SequencerSpriteManager extends PIXI.Container {
if (!spritesheet) {
return
}
const previousAsset = this.activeAsset
const asset = new VideoSpritesheetAsset({ filepath: filePath, spritesheet })
this.#relatedAssets.set(filePath, asset);
if (!this.destroyed && this.#activeAssetPath === filePath) {
this.#activateAsset(asset)
if (this.destroyed || this.#activeAssetPath !== filePath) {
return
}
this.#activateAsset(asset)
previousAsset?.destroy()
})
}
}
Expand Down

0 comments on commit 9e8ef43

Please sign in to comment.