Files
hyperframes/packages
Miguel Angel Simon Sierra c81482b3fc fix(shader-transitions): survive WebGL context loss instead of relying on GC
Browsers cap concurrent WebGL contexts (~16) and silently drop the oldest.
HyperShader had no `webglcontextlost` listener, so a dropped context was
permanent and surfaced as a transition that stopped rendering with no
diagnostic; the context itself was only reclaimed when the canvas became
collectable.

Generalise the pattern already used by the runtime colour grader:

- `manageContextLoss()` in webgl.ts cancels the default (unrecoverable) loss
  action, reports loss/restore, and returns a teardown that calls
  `WEBGL_lose_context.loseContext()` explicitly.
- While the context is lost, HyperShader routes active transitions through the
  existing DOM crossfade and skips all texture uploads, so the composition
  keeps playing and no GL call touches a dead context.
- On restore, programs, the quad buffer, the blend program and both
  interpolation render targets are rebuilt as a unit and the cached snapshot
  textures are re-uploaded from their blobs.
- The shared vertex shader is no longer cached in a module-level singleton: it
  outlived its context, so every program linked after a restore would have
  linked against a dead shader.

Verified in headless Chrome with real WebGL (SwiftShader): a shader transition
under a forced `loseContext()` drops to 0 GL draws and crossfades in the DOM,
then resumes real rendering after `restoreContext()`.
2026-08-03 22:05:03 -07:00
..
2026-08-02 21:57:19 -07:00
2026-08-02 21:57:19 -07:00
2026-08-02 21:57:19 -07:00