Skip to content

Commit

Permalink
Merge pull request #1521 from concord-consortium/186784013-dispose-un…
Browse files Browse the repository at this point in the history
…used-textures

Dispose unused Pixi textures
  • Loading branch information
pjanik authored Sep 30, 2024
2 parents 7778563 + 4e74c80 commit cb6c017
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion v3/src/components/data-display/pixi/pixi-points.ts
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,7 @@ export class PixiPoints {
} else {
// The only reason for ticker to run is to handle ongoing transitions. If there are no transitions, we can stop.
this.ticker.stop()
this.cleanupUnusedTextures()
}
this.renderer?.render(this.stage)
}
Expand Down Expand Up @@ -529,7 +530,16 @@ export class PixiPoints {
}

cleanupUnusedTextures() {
// TODO PIXI
const texturesInUse: Set<PIXI.Texture> = new Set()
this.points.forEach(point => {
texturesInUse.add(point.texture)
})
for (const [key, texture] of this.textures) {
if (!texturesInUse.has(texture)) {
texture.destroy()
this.textures.delete(key)
}
}
}

setupBackgroundEventDistribution(options: IBackgroundEventDistributionOptions) {
Expand Down

0 comments on commit cb6c017

Please sign in to comment.