fix: prevent white window flash when Hidden option is true - #4612
Conversation
Fixes #4611 When creating a window with Hidden: true, the window was briefly visible as a white window before disappearing. This was caused by CreateWindowEx using WS_OVERLAPPEDWINDOW style which includes WS_VISIBLE by default. The fix excludes WS_VISIBLE from the window style when the Hidden option is set to true, ensuring the window remains invisible until explicitly shown via window.Show().
WalkthroughThe Windows webview window creation now clears the Changes
Sequence Diagram(s)sequenceDiagram
autonumber
participant App as Application
participant WV as WebviewWindow
participant Win as Windows API
App->>WV: NewWithOptions(options)
alt options.Hidden == true
note right of WV #d3f9d8: Clear WS_VISIBLE from window style
else options.Hidden == false
note right of WV #f0f0f0: Keep WS_VISIBLE in window style
end
WV->>Win: CreateWindowEx(style)
Win-->>WV: HWND created
opt Later
App->>WV: Show()/Hide() as needed
end
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related PRs
Suggested labels
Poem
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing touches🧪 Generate unit tests
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🧪 Early access (Sonnet 4.5): enabledWe are currently testing the Sonnet 4.5 model, which is expected to improve code review quality. However, this model may lead to increased noise levels in the review comments. Please disable the early access features if the noise level causes any inconvenience. Note:
Comment |
|
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (1)
v3/pkg/application/webview_window_windows.go (1)
371-376: Fix is correct, but clarify the comment.The bitwise operation correctly clears
WS_VISIBLEwhenoptions.Hiddenis true. However, the comment on line 372 states thatWS_OVERLAPPEDWINDOWincludesWS_VISIBLEby default, which is technically incorrect.WS_OVERLAPPEDWINDOWis a composite ofWS_OVERLAPPED | WS_CAPTION | WS_SYSMENU | WS_THICKFRAME | WS_MINIMIZEBOX | WS_MAXIMIZEBOXand does not includeWS_VISIBLE. The actual issue is thatCreateWindowExmay show windows by default depending on thenCmdShowparameter or system behavior, so explicitly excludingWS_VISIBLEensures the window starts hidden.Consider updating the comment for accuracy:
- // If the window should be hidden initially, exclude WS_VISIBLE from the style - // This prevents the white window flash reported in issue #4611 + // If the window should be hidden initially, ensure WS_VISIBLE is not set + // This prevents the window from briefly appearing (white flash) as reported in issue #4611
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
v3/pkg/application/webview_window_windows.go(1 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
v3/pkg/application/webview_window_windows.go (1)
v3/pkg/w32/constants.go (1)
WS_VISIBLE(345-345)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (5)
- GitHub Check: Run Go Tests v3 (ubuntu-latest, 1.24)
- GitHub Check: Run Go Tests v3 (windows-latest, 1.24)
- GitHub Check: Run Go Tests v3 (macos-latest, 1.24)
- GitHub Check: semgrep/ci
- GitHub Check: Analyze (go)
🔇 Additional comments (2)
v3/pkg/application/webview_window_windows.go (2)
307-307: LGTM! Initialization aligns with visibility fix.The
showRequestedflag is correctly initialized based onoptions.Hidden, ensuring that hidden windows are not automatically shown after navigation completes.
2172-2179: LGTM! Visibility management is consistent with the fix.The
navigationCompleted()method correctly respectsoptions.Hiddenby only auto-showing windows whenHiddenis false. This works seamlessly with the style fix at line 374-375, ensuring hidden windows remain invisible until explicitly shown viaShow().
|
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (1)
v3/UNRELEASED_CHANGELOG.md (1)
26-26: Consider using "flash" for clarity.The PR title uses "white window flash" which is more precise than "appearing" for describing the brief visual artifact. Consider:
-- Fix the white window appearing on Windows when creating a hidden window by @leaanthony in [#4612](https://github.com/wailsapp/wails/pull/4612) +- Fix white window flash on Windows when creating a hidden window by @leaanthony in [#4612](https://github.com/wailsapp/wails/pull/4612)
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
v3/UNRELEASED_CHANGELOG.md(1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (4)
- GitHub Check: Run Go Tests v3 (macos-latest, 1.24)
- GitHub Check: Run Go Tests v3 (ubuntu-latest, 1.24)
- GitHub Check: Run Go Tests v3 (windows-latest, 1.24)
- GitHub Check: Cloudflare Pages
…4612) * fix: prevent white window flash when Hidden option is true Fixes wailsapp#4611 When creating a window with Hidden: true, the window was briefly visible as a white window before disappearing. This was caused by CreateWindowEx using WS_OVERLAPPEDWINDOW style which includes WS_VISIBLE by default. The fix excludes WS_VISIBLE from the window style when the Hidden option is set to true, ensuring the window remains invisible until explicitly shown via window.Show(). * Update Changelog




Fixes #4611
When creating a window with Hidden: true, the window was briefly visible as a white window before disappearing. This was caused by CreateWindowEx using WS_OVERLAPPEDWINDOW style which includes WS_VISIBLE by default.
The fix excludes WS_VISIBLE from the window style when the Hidden option is set to true, ensuring the window remains invisible until explicitly shown via window.Show().
Summary by CodeRabbit