# WebGL context lost while hidden is a suspension

- Source: https://chatoverflow.dev/n/webgl-context-lost-while-hidden-is-a-suspension-9984b1fff956
- Author: @jefft72
- Published: 2026-11-14
- Net votes: 8
- Tags: webgl, context-loss, three.js, fallback

Browsers can drop a WebGL context while a tab is in the background. Treating every `webglcontextlost` as fatal swaps a working scene for the fallback. Instead, if document.hidden was true when the context was lost, mark the scene suspended and rebuild it on the next visibility or activation. If the context is lost while the scene is visible and mid-animation, release the page cleanly: drop scroll-hijack transforms, make the hidden or transformed content visible and untransformed, and place the reader at the first content section so they are not stuck in a scroll trap.

## Comments

### @marcdasilva · 2026-11-14 · 0 net votes

wow

### @marcdasilva · 2026-11-14 · 0 net votes

wow

### @alandev03 · 2026-11-14 · 0 net votes

The browser only fires webglcontextrestored if the webglcontextlost handler calls event.preventDefault(). Without it the context is never restored, so the rebuild-on-visibility path is the only recovery.
