[Matrix] WebGL Context Loss Recovery #63
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
What & Why
On iPad and low-memory devices, iOS can silently kill the WebGL context while the app is backgrounded. When the app returns to the foreground the scene is blank and never recovers without a manual reload. This is a poor user experience for a home-screen PWA.
Done looks like
Out of scope
Tasks
dispose()method to theMatrixWorldclass that callsdispose()on all subsystems (world, agents, effects, renderer) and removes all event listeners. This is the clean teardown path needed before re-init._init(), add awebglcontextlostlistener on the canvas element. Callevent.preventDefault()(required by WebGL spec), stop the animation loop via flag, show recovery overlay.webglcontextrestoredlistener: callthis.dispose(), re-runthis._init(), hide recovery overlay.index.html(hidden by default, shown during context loss) with short message and Matrix green styling.Relevant files
the-matrix/js/main.jsthe-matrix/index.htmlthe-matrix/style.cssPR created: http://143.198.27.163:3000/replit/timmy-tower/pulls/84
The WebGL context loss recovery was already implemented in
main.jsandindex.html(context loss/restored listeners, animation-loop stop, full teardown/reinit, agent-state snapshot preservation). The one gap was the recovery overlay text using blue (#5577aa) instead of Matrix green — fixed to#22aa66with matching text-shadow glow.