From 00b369d3911da4ee10cce2cb1fee1eddd06a5e01 Mon Sep 17 00:00:00 2001 From: Chris Lorenzo Date: Wed, 10 Jun 2026 08:55:21 -0400 Subject: [PATCH] fix(examples): replace textureOptions wholesale instead of mutating frozen default Nodes created without textureOptions share a frozen EMPTY_TEXTURE_OPTIONS object (Stage.ts), so in-place mutation throws "Cannot add property, object is not extensible". Assign a new options object through the setter instead, per the documented contract. Fixes the TypeError spam on ?test=test (Character.ts) and the same latent pattern in texture-cleanup-critical.ts. Co-Authored-By: Claude Fable 5 --- examples/common/Character.ts | 4 +++- examples/tests/texture-cleanup-critical.ts | 5 ++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/examples/common/Character.ts b/examples/common/Character.ts index 0895378..dc28567 100644 --- a/examples/common/Character.ts +++ b/examples/common/Character.ts @@ -72,12 +72,14 @@ export class Character { const nextFrame = () => { // eslint-disable-next-line @typescript-eslint/no-non-null-assertion this.node.texture = this.rightFrames[curI]!; - this.node.textureOptions.flipX = flipX; curI++; if (curI > iEnd) { curI = iStart; } }; + // textureOptions must be replaced wholesale, never mutated in place — + // nodes created without options share a frozen default object. + this.node.textureOptions = { flipX }; nextFrame(); this.curIntervalAnimation = setInterval(nextFrame, intervalMs); } diff --git a/examples/tests/texture-cleanup-critical.ts b/examples/tests/texture-cleanup-critical.ts index 187d70d..73531e3 100644 --- a/examples/tests/texture-cleanup-critical.ts +++ b/examples/tests/texture-cleanup-critical.ts @@ -51,6 +51,10 @@ See docs/ManualRegressionTests.md for more information. fontSize: 40, }); + // textureOptions must be replaced wholesale, never mutated in place — + // nodes created without options share a frozen default object. + screen.textureOptions = { preload: true }; + // Create a new random texture every 10ms setInterval(() => { screen.texture = renderer.createTexture('NoiseTexture', { @@ -58,6 +62,5 @@ See docs/ManualRegressionTests.md for more information. h: 500, cacheId: Math.floor(Math.random() * 100000), }); - screen.textureOptions.preload = true; }, 100); }