You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When a font asset is unloaded the font’s textures are not destroyed and still consume VRAM.
Is there a reason for that or is it a bug?
The font class does not have a destroy method so asset.unload cannot call it.
I attempted a work around in the test project https://playcanvas.com/project/1264902/overview/unloading-a-font-asset.
In this project the user can press the space bar to toggle between a large VRAM font and a small VRAM font.
To show the bug, comment out the workaround in this function.
Test.prototype.unloadFontAsset = function(fontAsset) {
// When unloading a font asset the font's texture(s) are not destroyed.
// which is a waste of VRAM.
let textures = fontAsset.resource.textures;
for (let i = 0; i < textures.length; i++) {
let texture = textures[i];
// Destroy to free resources associated with this texture.
// see https://api.playcanvas.com/classes/Engine.Texture.html#destroy
texture.destroy();
// Clear the font texture from the resource loader cache.
// see https://api.playcanvas.com/classes/Engine.ResourceLoader.html#clearCache
this.app.loader.clearCache(texture.name,'texture');
}
fontAsset.unload();
};
The text was updated successfully, but these errors were encountered:
When a font asset is unloaded the font’s textures are not destroyed and still consume VRAM.
Is there a reason for that or is it a bug?
The font class does not have a destroy method so asset.unload cannot call it.
I attempted a work around in the test project https://playcanvas.com/project/1264902/overview/unloading-a-font-asset.
In this project the user can press the space bar to toggle between a large VRAM font and a small VRAM font.
To show the bug, comment out the workaround in this function.
The text was updated successfully, but these errors were encountered: