Skip to content

WebView (Windows): suppress background flash on creation and hide/show - #28

Merged
jakepenn merged 1 commit into
minimal_masterfrom
webview-win-suppress-bg-flash
May 26, 2026
Merged

WebView (Windows): suppress background flash on creation and hide/show#28
jakepenn merged 1 commit into
minimal_masterfrom
webview-win-suppress-bg-flash

Conversation

@jakepenn

Copy link
Copy Markdown
Member

Summary

Two complementary fixes that close the white-flash windows the embedded WebView2 exposes around hide/show and initial paint:

  • Switch background colour delivery to WEBVIEW2_DEFAULT_BACKGROUND_COLOR env var — replaces the chromium --default-background-color CLI switch (set via AdditionalBrowserArguments from WebView (Windows): fix startup flicker via --default-background-color #26). Same goal, but works through the Microsoft-documented runtime path, so it's less likely to drift across chromium versions.
  • Stamp the WebView2 host HWND's class background brush — WebView2's class defaults to a white brush, which the OS paints into the HWND's initial pixel buffer at creation and on some restore paths, visible as a one-frame flash before the renderer composites. We can only reach the direct browser-host child HWND — the deeper descendants (Chrome_WidgetWin_1, Intermediate D3D Window, Chrome_RenderWidgetHostHWND) live in the renderer process, and SetClassLongPtrW returns ERROR_ACCESS_DENIED for them. Stamping the one HWND we own covers the common case.

Used together with the consumer-side work in minimal_core (translation-based hide for the WebView2, no put_IsVisible round-trips), these two fixes eliminate the white flashes on cold boot, native overlay open, and native overlay dismiss.

Test plan

  • Cold-launch the standalone Memory Rites player — no white flash before the chrome backdrop
  • Toggle the Debug → Open Account View menu repeatedly — no flash on either direction
  • Minimize / restore the standalone window — no flash on restore

🤖 Generated with Claude Code

Two complementary fixes that together close the white-flash windows we've
been chasing in the embedded webview:

1. Switch the renderer's default background colour from a chromium CLI
   switch (--default-background-color via AdditionalBrowserArguments) to
   the WEBVIEW2_DEFAULT_BACKGROUND_COLOR environment variable. Same goal,
   but works through the Microsoft-documented runtime path so it's less
   likely to drift across chromium versions.

2. Stamp the WebView2 host HWND's class background brush with the
   configured background colour. WebView2's class defaults to a white
   brush, which the OS paints into the HWND's initial pixel buffer at
   creation and on some restore paths -- visible as a flash before the
   renderer composites its first frame. The deeper descendant HWNDs
   (Chrome_WidgetWin_1, Intermediate D3D Window, Chrome_RenderWidgetHostHWND)
   are owned by the WebView2 renderer process and SetClassLongPtrW
   returns ERROR_ACCESS_DENIED for them, so we only stamp the direct
   browser-host child we associated above.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@jakepenn
jakepenn force-pushed the webview-win-suppress-bg-flash branch from 372bd2f to a8b2868 Compare May 25, 2026 18:19
@jakepenn
jakepenn merged commit 1bc4a0d into minimal_master May 26, 2026
0 of 2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant