Skip to content

Commit 9ed53da

Browse files
authored
fix: prevent cleanup of SDF Font Face textures for now (#481)
Stop gap solution, ideally we do want SDF Font Face textures cleaned up if we can detect they have no renderable owners anymore to save as much memory as we can in case we hit critical levels. However for now prevent Font Face textures from being cleaned up until we have proper guards/reloads in the SDF Font Renderer at the expense of keeping the Font atlas always in memory regardless if its being used.
2 parents e97e717 + dc46121 commit 9ed53da

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)