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.
TypeScript 2d-game-engine3d3d-game-engineandroidcppecsgame-editorgame-enginegamedeviostypescriptwebassemblywebglwebgpuwechat-minigame
fix(sdk): spine listeners are cleaned by entity, not instance id
esengine7bf275a214d6
diff --git a/sdk/src/spine/ModuleBackend.ts b/sdk/src/spine/ModuleBackend.tsindex 0aed3fdd3..1c8f4c5b5 100644--- a/sdk/src/spine/ModuleBackend.ts+++ b/sdk/src/spine/ModuleBackend.ts@@ -259,6 +259,7 @@ export class ModuleBackend {const info = this.entities_.get(entity);if (!info) return;this.controller_.destroyInstance(info.instanceId);+ this.controller_.removeAllListeners(entity); // keyed by entity, not instanceIdthis.releaseSkeleton_(info);this.entities_.delete(entity);this.disabledEntities_.delete(entity);diff --git a/sdk/src/spine/SpineController.ts b/sdk/src/spine/SpineController.tsindex 40b6512ef..11f82fe18 100644--- a/sdk/src/spine/SpineController.ts+++ b/sdk/src/spine/SpineController.ts@@ -135,7 +135,10 @@ export class SpineModuleController {destroyInstance(instanceId: number): void {this.api_.destroyInstance(instanceId);- this.listeners_.delete(instanceId as Entity);+ // Listeners are keyed by ENTITY, not instanceId — the entity-removal path+ // clears them via removeAllListeners(entity). Deleting by instanceId here+ // was a no-op at best and could evict a different entity's listeners when+ // an instanceId happened to equal an entity id.}// =========================================================================diff --git a/sdk/tests/spine-dedup.test.ts b/sdk/tests/spine-dedup.test.tsindex 7be3a8341..06bbb54cd 100644--- a/sdk/tests/spine-dedup.test.ts+++ b/sdk/tests/spine-dedup.test.ts@@ -21,6 +21,7 @@ function makeController() {setAtlasPageTexture: vi.fn(),createInstance: vi.fn(() => nextInst++),destroyInstance: vi.fn(),+ removeAllListeners: vi.fn(),unloadSkeleton: vi.fn(),} as unknown as SpineModuleController & Record<string, ReturnType<typeof vi.fn>>;}