From 3b53a2461ac106164aedfc9c9ae9fa1331aab06c Mon Sep 17 00:00:00 2001 From: Guilherme Simoes Date: Thu, 30 Jul 2026 15:35:48 +0100 Subject: [PATCH 1/2] Fix freeTextureSource() leaving stale entries in textureSourceHashmap --- src/tree/TextureManager.mjs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/tree/TextureManager.mjs b/src/tree/TextureManager.mjs index ff2e2179..cef136af 100644 --- a/src/tree/TextureManager.mjs +++ b/src/tree/TextureManager.mjs @@ -53,7 +53,7 @@ export default class TextureManager { for (let i = 0, n = this._uploadedTextureSources.length; i < n; i++) { this._nativeFreeTextureSource(this._uploadedTextureSources[i]); } - + this.textureSourceHashmap.clear(); this._usedMemory = 0; } @@ -95,7 +95,7 @@ export default class TextureManager { nativeTexture.update = this.stage.frameCounter; this._uploadedTextureSources.push(textureSource); - + this.addToLookupMap(textureSource); // add VRAM tracking if using the webgl renderer @@ -140,7 +140,7 @@ export default class TextureManager { gc() { this.freeUnusedTextureSources(); } - + freeUnusedTextureSources() { let remainingTextureSources = []; for (let i = 0, n = this._uploadedTextureSources.length; i < n; i++) { @@ -195,6 +195,8 @@ export default class TextureManager { this._nativeFreeTextureSource(textureSource); } + this.textureSourceHashmap.delete(textureSource.lookupId); + // Should be reloaded. textureSource.loadingSince = null; } From 0df55f82a20c9d01b190fbcff2fb8ed6b2112206 Mon Sep 17 00:00:00 2001 From: Guilherme Simoes Date: Fri, 31 Jul 2026 12:17:37 +0100 Subject: [PATCH 2/2] Also update VRAM usage when calling freeTextureSource() --- src/tree/TextureManager.mjs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/tree/TextureManager.mjs b/src/tree/TextureManager.mjs index cef136af..060be21b 100644 --- a/src/tree/TextureManager.mjs +++ b/src/tree/TextureManager.mjs @@ -190,6 +190,7 @@ export default class TextureManager { if (textureSource.isLoaded()) { if (managed) { this._addMemoryUsage(-textureSource.w * textureSource.h); + this._updateVramUsage(textureSource, -1); this._uploadedTextureSources.splice(index, 1); } this._nativeFreeTextureSource(textureSource);