Quick answer: Construct 3 game blacking out after the player switches tabs and returns? Browser dropped the WebGL context - listen for the context lost event and rebuild via Runtime.restart().

Player tabs away to read Discord, tabs back, game is a black square. Console: WebGL: CONTEXT_LOST_WEBGL.

Listen for the event

In a Browser plugin's On window event handler, listen for webglcontextlost. Call Browser.ExecJS with a restart routine. The game can't recover the in-flight context but can rebuild a fresh one.

Or preserve context

For embedded games, pass {preserveDrawingBuffer: true, powerPreference: 'high-performance'} when creating the WebGL context. The browser is less aggressive about reclaiming it.

Save game state pre-emptively

Auto-save to localStorage every 30 seconds. When the context drops, the worst case is rewinding 30 seconds instead of the player losing everything.

“WebGL is a resource the browser can reclaim. Your code is the one that decides what to do about it.”

Mobile Safari is the worst offender. If your audience is mobile-heavy, treat context-lost as a normal event, not an exceptional one.