Skip to content

Commit dc46121

Browse files
committed
fix: prevent cleanup of SDF Font Face textures for now
1 parent e97e717 commit dc46121

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/core/text-rendering/font-face-types/SdfTrFontFace/SdfTrFontFace.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,14 @@ export class SdfTrFontFace<
8989
// Load the texture
9090
stage.txManager.loadTexture(this.texture, true);
9191

92-
this.texture.once('loaded', () => {
92+
// FIXME This is a stop-gap solution to avoid Font Face textures to be cleaned up
93+
// Ideally we do want to clean up the textures if they're not being used to save as much memory as possible
94+
// However, we need to make sure that the font face is reloaded if the texture is cleaned up and needed again
95+
// and make sure the SdfFontRenderer is properly guarded against textures being reloaded
96+
// for now this will do the trick and the increase on memory is not that big
97+
this.texture.preventCleanup = true;
98+
99+
this.texture.on('loaded', () => {
93100
this.checkLoaded();
94101
// Make sure we mark the stage for a re-render (in case the font's texture was freed and reloaded)
95102
stage.requestRender();

0 commit comments

Comments
 (0)