fix(babylon): a texture or environment that fails to load stays in the scene until Stop

Aperta
#185 1 commento 0 reazioni 1 assegnatario Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

@kalwalt ci sta già lavorando.

Dal 19/11/2026.

Valutazione

Questa issue non è ancora stata valutata.

Descrizione

Babylonjs bug runtime
Problem

Found by Qodo's review of the v0.4.0 release PR (#184), and checked on dev at 8dce01f:

  • In the Babylon.js adapter (src/runtime/renderers/babylon-adapter.ts), a texture that fails to load is not disposed:
    • environmentTexture() (line 372): the HDRCubeTexture's error callback (line 380) revokes the blob URL and rejects, but leaves the texture in the scene;
    • createTexture(), an image by its URL (line 599): the Texture's onError rejects and leaves the texture in the scene.
  • At init this costs nothing for long: the node's init fails, the runtime stops, and the scene's teardown disposes every texture it holds.
  • A live environment change is different. setEnvironment() (line 773) loads the new source while the scene keeps running; when the load fails (a .hdr file that does not parse), it keeps the texture shown, as it should, and the failed HDRCubeTexture stays in scene.textures until Stop. Each failed change adds one.
  • The Three.js adapter has no such case: it parses the .hdr itself and makes its textures only from a parse that succeeded.
Design
  1. In both error callbacks, dispose the texture before rejecting.
  2. Disposing fires the texture's onDisposeObservable, whose handler (lines 383 and 603) revokes the URL and rejects again. A settled promise ignores the second reject, but the URL must still be revoked once: make done() in environmentTexture() run once (a flag), and keep the "torn down" rejection for a dispose that comes first, from a Stop.
  3. No change to the error messages, nor to what setEnvironment() keeps on screen after a failed load.
Tasks
  • A failing unit test first, in tests/unit/conformance/environment-babylon.test.ts, which runs the adapter on NullEngine with a fake HDRCubeTexture: the fake made to call its error callback, a live change to an .hdr that does not parse rejects, keeps the texture shown, and leaves scene.textures as long as before the change.
  • The same for createTexture() with an image URL that fails, if the test environment can make one fail; otherwise say so in the PR.
  • The fix of points 1 and 2.
  • A CHANGELOG line under Fixed.
Files

src/runtime/renderers/babylon-adapter.ts, tests/unit/, CHANGELOG.md.

Acceptance
  • After a failed live environment change, the scene holds no more textures than before it.
  • Every texture and environment test passes on both renderers.
Lingua principale
TypeScript
Stelle
1
Fork
0
Merge medio
2h 36m
PR unite (30g)
92

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di webarkit/webarkit-studio

Tutte le issue di webarkit/webarkit-studio

Issue simili

Altre issue su TypeScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.