fix(ui): White screen when hedgehog mode loses its WebGL context#3243
Conversation
|
Merging to
After your PR is submitted to the merge queue, this comment will be automatically updated with its status. If the PR fails, failure details will also be posted here |
|
React Doctor found no issues in the changed files. 🎉 Reviewed by React Doctor for commit |
|
Reviews (1): Last reviewed commit: "remount hedgehog mode on WebGL context l..." | Re-trigger Greptile |
There was a problem hiding this comment.
Solid bug fix with well-structured effects, proper cleanup of all listeners/timers/subscriptions, a defensive fallback polling mechanism, and comprehensive tests covering toggle cycles, repeated context losses, and unmount. The bot comment was on an older commit and is resolved; the new code's effect dependency on gameDead eliminates the re-registration gap the comment identified.
Problem
Hedgehog mode mounts a full-window game canvas at z-index 999998. When its WebGL context dies (GPU reset, context eviction after sleep or occlusion), Chromium composites the dead canvas as an opaque white sheet covering the entire app. The app keeps running underneath (the overlay is pointer-events: none) and nothing ever recovers it: the white screen of death.
Changes
On context loss the game is destroyed and removed from the DOM immediately, reported via
captureException, then remounted after 2s (max 3 attempts, after which the overlay stays hidden until the setting is toggled). Detection goes through theHedgehogModeHostseam: the adapter fires anonContextLostcallback and exposesisContextLost()on the handle, which a 10s poll (skipped while hidden) and a re-check on window refocus consult, so a swallowed loss event still tears the canvas down.How did you test this?
@posthog/uiandapps/code.WEBGL_lose_context.loseContext()on the game canvas in devtools; hedgehogs respawn instead of white-screening.Automatic notifications