Skip to content

A fast 2D and 3D game engine — TypeScript SDK, C++/WebAssembly core, visual editor. Ship one project to web, desktop, WeChat MiniGames, playable ads, and native Android / iOS.

fix: texture reference counting leak with flip parameter

esengine6902c082c354
diff --git a/sdk/src/asset/AssetServer.ts b/sdk/src/asset/AssetServer.ts
index eb69ca8f1..8ad8aa64b 100644
--- a/sdk/src/asset/AssetServer.ts
+++ b/sdk/src/asset/AssetServer.ts
@@ -200,10 +200,13 @@ export class AssetServer {
const rm = this.module_.getResourceManager();
for (const flip of [true, false]) {
const key = this.textureCacheKey(source, flip);
+ const refCount = this.textureRefCounts_.get(key);
+ if (refCount === undefined) continue;
+
const info = this.textureCache_.get(key);
if (!info) continue;
- const count = (this.textureRefCounts_.get(key) ?? 1) - 1;
+ const count = refCount - 1;
if (count <= 0) {
rm.releaseTexture(info.handle);
this.textureCache_.delete(key);