Skip to content

Commit

Permalink
feat: dispose unused Pixi textures [PT-186784013]
Browse files Browse the repository at this point in the history
  • Loading branch information
pjanik committed Sep 27, 2024
1 parent b779c10 commit 4e74c80
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 @@ -168,6 +168,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()

Check warning on line 171 in v3/src/components/data-display/pixi/pixi-points.ts

View check run for this annotation

Codecov / codecov/patch

v3/src/components/data-display/pixi/pixi-points.ts#L171

Added line #L171 was not covered by tests
}
this.renderer?.render(this.stage)
}
Expand Down Expand Up @@ -500,7 +501,16 @@ export class PixiPoints {
}

cleanupUnusedTextures() {
// TODO PIXI
const texturesInUse: Set<PIXI.Texture> = new Set()
this.points.forEach(point => {
texturesInUse.add(point.texture)

Check warning on line 506 in v3/src/components/data-display/pixi/pixi-points.ts

View check run for this annotation

Codecov / codecov/patch

v3/src/components/data-display/pixi/pixi-points.ts#L504-L506

Added lines #L504 - L506 were not covered by tests
})
for (const [key, texture] of this.textures) {

Check warning on line 508 in v3/src/components/data-display/pixi/pixi-points.ts

View check run for this annotation

Codecov / codecov/patch

v3/src/components/data-display/pixi/pixi-points.ts#L508

Added line #L508 was not covered by tests
if (!texturesInUse.has(texture)) {
texture.destroy()
this.textures.delete(key)

Check warning on line 511 in v3/src/components/data-display/pixi/pixi-points.ts

View check run for this annotation

Codecov / codecov/patch

v3/src/components/data-display/pixi/pixi-points.ts#L510-L511

Added lines #L510 - L511 were not covered by tests
}
}
}

setupBackgroundEventDistribution(options: IBackgroundEventDistributionOptions) {
Expand Down

0 comments on commit 4e74c80

Please sign in to comment.