Direct answer
No—destroy(true) does not automatically remove the global TextureCache entry in PixiJS v6 or v7. Texture.from(url) reads TextureCache first, so a destroyed texture remains reachable until you explicitly evict it. Call PIXI.Texture.removeFromCache(texture) before destroy(true); if the base texture is separately cached, also call PIXI.BaseTexture.removeFromCache(texture.baseTexture).
Likely explanation vs. confirmed facts
Confirmed: Texture.from(string) returns TextureCache[string] when that key exists. destroy(true) releases the underlying BaseTexture resources but does not guarantee deletion from the texture-level cache registry.
Likely explanation: The URL or cacheId entry persists because TextureCache is an independent lookup table. Destroying the base texture invalidates the GPU resource, but the JavaScript wrapper object is still returned by the next Texture.from call until the cache key is removed.
Version uncertainty: v6 and v7 expose the same TextureCache/BaseTextureCache and static addToCache/removeFromCache contract. v8 behavior is not confirmed here; verify against your installed release before relying on the same API.
Steps for this case
- Capture the texture instance before destruction.
- Call
PIXI.Texture.removeFromCache(texture). This removes every id tracked in texture.textureCacheIds from PIXI.utils.TextureCache.
- If you cached the base texture separately, call
PIXI.BaseTexture.removeFromCache(texture.baseTexture).
- Then call
texture.destroy(true).
Do not use delete PIXI.utils.TextureCache[url] as the primary fix: it evicts the lookup but leaves texture.textureCacheIds stale, which can cause inconsistent state if the texture is reused or inspected later.
Verification
const t = PIXI.Texture.from(url);
console.log(PIXI.utils.TextureCache[url] === t); // true
PIXI.Texture.removeFromCache(t);
if (t.baseTexture.cacheId) {
PIXI.BaseTexture.removeFromCache(t.baseTexture);
}
t.destroy(true);
console.log(PIXI.utils.TextureCache[url]); // undefined
const t2 = PIXI.Texture.from(url);
console.log(t2 === t); // false
After eviction and destruction, the next Texture.from(url) creates a new texture and base texture, which may reload or re-decode the source.
Assumptions and cautions
- This assumes the texture entered the cache through
Texture.from or Texture.addToCache, so textureCacheIds is populated. Manually assigned TextureCache[id] = texture entries are not tracked by removeFromCache.
destroy(true) destroys a base texture shared by all textures that reference it. Avoid it for shared base textures, or evict and recreate carefully.
- Remove cache entries before destroy, or capture
texture.textureCacheIds first; calling removeFromCache after destroy may find no ids if destroy clears them.
One diagnostic detail needed
Which PixiJS major version is deployed in your project? If you are on v8, the v6/v7 cache-removal steps above need validation against the installed release before you apply them in production.