Skip to content

fix(ui): White screen when hedgehog mode loses its WebGL context#3243

Merged
charlesvien merged 3 commits into
mainfrom
fix/hedgehog-canvas-white-screen
Jul 7, 2026
Merged

fix(ui): White screen when hedgehog mode loses its WebGL context#3243
charlesvien merged 3 commits into
mainfrom
fix/hedgehog-canvas-white-screen

Conversation

@charlesvien

@charlesvien charlesvien commented Jul 7, 2026

Copy link
Copy Markdown
Member

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 the HedgehogModeHost seam: the adapter fires an onContextLost callback and exposes isContextLost() 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?

  • 8 unit tests: teardown and reporting on loss, poll and refocus detection, bounded remount, toggle cycle, unmount.
  • Typecheck and Biome pass for @posthog/ui and apps/code.
  • Live: with hedgehog mode on, run WEBGL_lose_context.loseContext() on the game canvas in devtools; hedgehogs respawn instead of white-screening.

Automatic notifications

  • Publish to changelog?
  • Alert Sales and Marketing teams?

@trunk-io

trunk-io Bot commented Jul 7, 2026

Copy link
Copy Markdown

Merging to main in this repository is managed by Trunk.

  • To merge this pull request, check the box to the left or comment /trunk merge below.

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

@github-actions

github-actions Bot commented Jul 7, 2026

Copy link
Copy Markdown

React Doctor found no issues in the changed files. 🎉

Reviewed by React Doctor for commit b60227d.

@greptile-apps

greptile-apps Bot commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

Reviews (1): Last reviewed commit: "remount hedgehog mode on WebGL context l..." | Re-trigger Greptile

Comment thread packages/ui/src/shell/HedgehogMode.tsx
@charlesvien charlesvien changed the title fix(ui): Remount hedgehog mode on WebGL context loss fix(ui): White screen when hedgehog mode loses its WebGL context Jul 7, 2026
@charlesvien charlesvien added Create Release This will trigger a new release Stamphog This will request an autostamp by stamphog on small changes labels Jul 7, 2026

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@charlesvien charlesvien merged commit 4fd5613 into main Jul 7, 2026
30 checks passed
@charlesvien charlesvien deleted the fix/hedgehog-canvas-white-screen branch July 7, 2026 19:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Create Release This will trigger a new release Stamphog This will request an autostamp by stamphog on small changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant