fix(refboard): hide sprite when texture unloaded to prevent render error

PixiJS v8 crashes with 'Cannot read alphaMode of null' when rendering
a Sprite with Texture.EMPTY. Fix: set sprite.visible = false until a
real texture is loaded, re-hide on unload.
This commit is contained in:
Hiren Kangad
2026-03-10 11:02:20 +05:30
parent 21ee4b2601
commit b3a15726f1
+4 -1
View File
@@ -43,10 +43,11 @@ export class ImageSprite extends Container {
this._drawShadow(SHADOW_REST); this._drawShadow(SHADOW_REST);
this.addChild(this._shadow); this.addChild(this._shadow);
// Main sprite // Main sprite — hidden until texture loads (prevents PixiJS render errors with EMPTY)
this._sprite = new Sprite(Texture.EMPTY); this._sprite = new Sprite(Texture.EMPTY);
this._sprite.width = w; this._sprite.width = w;
this._sprite.height = h; this._sprite.height = h;
this._sprite.visible = false;
this.addChild(this._sprite); this.addChild(this._sprite);
// Placeholder: dark rect shown until texture is loaded by culling system // Placeholder: dark rect shown until texture is loaded by culling system
@@ -90,6 +91,7 @@ export class ImageSprite extends Container {
this._sprite.texture = tex; this._sprite.texture = tex;
this._sprite.width = this._naturalWidth; this._sprite.width = this._naturalWidth;
this._sprite.height = this._naturalHeight; this._sprite.height = this._naturalHeight;
this._sprite.visible = true;
this.loaded = true; this.loaded = true;
// Remove placeholder after successful load // Remove placeholder after successful load
@@ -114,6 +116,7 @@ export class ImageSprite extends Container {
this.textures.unload(this.assetKey); this.textures.unload(this.assetKey);
this._sprite.texture = Texture.EMPTY; this._sprite.texture = Texture.EMPTY;
this._sprite.visible = false;
this.loaded = false; this.loaded = false;
// Restore placeholder // Restore placeholder