Skip to content

Commit b4edc48

Browse files
Fix freeTextureSource() leaving stale entries in textureSourceHashmap
1 parent 461fe00 commit b4edc48

1 file changed

Lines changed: 7 additions & 3 deletions

File tree

src/tree/TextureManager.mjs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ export default class TextureManager {
5353
for (let i = 0, n = this._uploadedTextureSources.length; i < n; i++) {
5454
this._nativeFreeTextureSource(this._uploadedTextureSources[i]);
5555
}
56-
56+
5757
this.textureSourceHashmap.clear();
5858
this._usedMemory = 0;
5959
}
@@ -95,7 +95,7 @@ export default class TextureManager {
9595
nativeTexture.update = this.stage.frameCounter;
9696

9797
this._uploadedTextureSources.push(textureSource);
98-
98+
9999
this.addToLookupMap(textureSource);
100100

101101
// add VRAM tracking if using the webgl renderer
@@ -140,7 +140,7 @@ export default class TextureManager {
140140
gc() {
141141
this.freeUnusedTextureSources();
142142
}
143-
143+
144144
freeUnusedTextureSources() {
145145
let remainingTextureSources = [];
146146
for (let i = 0, n = this._uploadedTextureSources.length; i < n; i++) {
@@ -195,6 +195,10 @@ export default class TextureManager {
195195
this._nativeFreeTextureSource(textureSource);
196196
}
197197

198+
if (textureSource.lookupId) {
199+
this.textureSourceHashmap.delete(textureSource.lookupId);
200+
}
201+
198202
// Should be reloaded.
199203
textureSource.loadingSince = null;
200204
}

0 commit comments

Comments
 (0)