From fdcee3536fcbf6358a9b7cc48d5bb05e118e26b1 Mon Sep 17 00:00:00 2001 From: Hiren Kangad Date: Tue, 10 Mar 2026 12:24:17 +0530 Subject: [PATCH] fix(refboard): guard loadServerPoster against repeated culling calls Add _serverPosterLoading flag so repeated 200ms culling ticks don't call textures.load() multiple times before the first resolves. Also release the texture ref if the sprite was destroyed or started playing during the async load. --- frontend/src/canvas/sprites/VideoSprite.ts | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/frontend/src/canvas/sprites/VideoSprite.ts b/frontend/src/canvas/sprites/VideoSprite.ts index 09e0243..1983a81 100644 --- a/frontend/src/canvas/sprites/VideoSprite.ts +++ b/frontend/src/canvas/sprites/VideoSprite.ts @@ -31,6 +31,7 @@ export class VideoSprite extends Container { private videoTexture: Texture | null = null; private posterTexture: Texture | null = null; private _serverPosterLoaded = false; + private _serverPosterLoading = false; private _sprite: Sprite | null = null; private _shadow: Graphics; private _overlay: Graphics; @@ -99,10 +100,14 @@ export class VideoSprite extends Container { /** Load server poster. Called by culling system when within poster budget. */ async loadServerPoster(): Promise { - if (!this.posterAssetKey || !this.textures || this.destroyed) return; + if (this._serverPosterLoading || !this.posterAssetKey || !this.textures || this.destroyed) return; + this._serverPosterLoading = true; try { const tex = await this.textures.load(this.posterAssetKey); - if (this.destroyed || this._isPlaying) return; + if (this.destroyed || this._isPlaying) { + this.textures!.release(this.posterAssetKey!); + return; + } this.posterTexture = tex; this._hasPoster = true; @@ -112,6 +117,8 @@ export class VideoSprite extends Container { this._removePlaceholder(); } catch { // Server poster failed — will fall back to client capture if needed + } finally { + this._serverPosterLoading = false; } }