Skip to content

fix(v3/windows): remove ResizeDebounceMS and fix resize background painting - #5596

Merged
leaanthony merged 4 commits into
masterfrom
worktree-abstract-scribbling-sparkle
Jun 14, 2026
Merged

leaanthony merged 4 commits into
masterfrom
worktree-abstract-scribbling-sparkle

Conversation

@leaanthony

@leaanthony leaanthony commented Jun 13, 2026 •

Copy link
Copy Markdown
Member

Summary

Fixes #5594 — white areas appear after window resize on Windows.

  • Remove ResizeDebounceMS from WindowsWindow options. The debounce delayed WebView2 resizing for performance, but inherently left newly-exposed areas undrawn for the debounce period — a content gap no amount of mitigation can fully hide. Modern WebView2 handles live resize well without it. The default was already 0 (no debounce), so this only breaks callers who explicitly opted in.

  • Fix WM_ERASEBKGND to actually fill the client area with the configured BackgroundColour before returning 1. Previously the handler claimed to handle the erase without drawing anything, leaving white pixels wherever WebView2 hadn't yet painted. WebView2 paints on top, so this has no effect on normal rendering — it only matters for the brief moment during resize when the client area is larger than the WebView2 surface.

Test plan

  • Create a v3 app with BackgroundColour: application.NewRGB(15, 17, 23) and resize the window — no white flash should appear
  • Confirm apps that previously set ResizeDebounceMS compile after removing the field (breaking change, alpha only)
  • Frameless window minimize/restore still works correctly (the WebView2 suppress-on-minimize path is preserved)

Summary by CodeRabbit

  • Breaking Changes

    • Removed Windows resize debounce configuration option
  • Improvements

    • Updated Windows window resizing behavior during minimize
    • Enhanced background rendering for Windows windows
    • Improved frameless window handling on Windows

…inting

ResizeDebounceMS delayed WebView2 resizing to improve performance, but
inherently left newly-exposed window areas undrawn for the debounce
period. No mitigation can fully hide the content gap, so the option is
removed — modern WebView2 handles live resize well enough without it.

Also fix WM_ERASEBKGND to fill the client area with the configured
background colour before returning, so any area momentarily not covered
by WebView2 during a resize shows the correct colour instead of white.

Fixes #5594
Copilot AI review requested due to automatic review settings June 13, 2026 23:34
@coderabbitai

coderabbitai Bot commented Jun 13, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

Walkthrough

Removes the ResizeDebounceMS field from the WindowsWindow public options struct and eliminates all internal resize debouncer machinery (resizeDebouncer field, its initialization, and the resizePending variable). WM_ERASEBKGND now fills the client area with the configured solid background color. WM_SIZE suppresses WebView2 resize only for frameless minimized windows; otherwise calls ResizeWithBounds directly and emits WindowDidResize.

Changes

Resize Debouncer Removal and Background Painting Fix

Layer / File(s) Summary
Remove ResizeDebounceMS option and internal debouncer infrastructure
v3/pkg/application/webview_window_options.go, v3/pkg/application/webview_window_windows.go
Removes the exported ResizeDebounceMS field from WindowsWindow, the resizeDebouncer field from windowsWebviewWindow, its initialization in run(), and the package-level resizePending gating variable.
Rewrite WM_SIZE and WM_ERASEBKGND handlers
v3/pkg/application/webview_window_windows.go
WM_ERASEBKGND now optionally fills the client rect with the configured solid background color and always returns 1. WM_SIZE skips chromium.ResizeWithBounds only when the window is both frameless and minimizing; otherwise it computes bounds from lparam, calls ResizeWithBounds via InvokeSync, and emits WindowDidResize.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

  • wailsapp/wails#5572: Modifies the same WM_SIZE/minimized path in webview_window_windows.go, specifically adding DPI/rasterization resync on minimize/restore, intersecting with this PR's changes to the same code region.

Suggested labels

Bug, Windows, v3-alpha, size:M

Poem

🐇 Hop hop, the debouncer's gone away,
No more pending resizes causing dismay!
White flashes begone, the background now shows,
Solid as carrots wherever the window grows.
InvokeSync calls chromium, quick and direct —
The frameless minimized path stays correct! 🎉

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and specifically describes the two main changes: removing ResizeDebounceMS and fixing resize background painting.
Description check ✅ Passed The description covers the issue, changes made, rationale, and includes a test plan, but lacks explicit testing section checkboxes completion.
Linked Issues check ✅ Passed The PR directly addresses issue #5594 by removing ResizeDebounceMS and fixing WM_ERASEBKGND to paint background color, matching the issue's requirements.
Out of Scope Changes check ✅ Passed All code changes are directly related to fixing the resize white-flash issue and removing the ResizeDebounceMS option as scoped in issue #5594.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch worktree-abstract-scribbling-sparkle

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 golangci-lint (2.12.2)

level=error msg="[linters_context] typechecking error: pattern ./...: directory prefix . does not contain modules listed in go.work or their selected dependencies"


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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes Windows resize “white gap” artifacts in the v3 WebView2 window by removing resize debouncing (which intentionally delayed WebView2 resizing) and ensuring the native window erases its background using the configured solid background colour during resize.

Changes:

  • Removed ResizeDebounceMS from WindowsWindow options and eliminated the associated resize debouncer logic on Windows.
  • Updated WM_ERASEBKGND handling to actually paint the client area with BackgroundColour (for solid backgrounds) to prevent white/unpainted regions during live resize.
  • Simplified the WM_SIZE resize path to always resize WebView2 immediately (while preserving the frameless minimize suppression workaround).

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
v3/pkg/application/webview_window_windows.go Removes resize debouncing and paints solid background on WM_ERASEBKGND to avoid white gaps during resize.
v3/pkg/application/webview_window_options.go Removes the ResizeDebounceMS option from WindowsWindow.
Comments suppressed due to low confidence (1)

v3/pkg/application/webview_window_windows.go:1599

  • WM_ERASEBKGND now always returns 1 even if CreateSolidBrush fails (returns 0). In that failure case, the handler would claim to have erased the background without actually painting anything, reintroducing the white/unpainted area problem (at least under low-memory conditions). Guard the brush handle and return 0 on failure so the default erasing path can run.
		w.moveDebouncer(func() {
			w.parent.emit(events.Windows.WindowDidMove)
		})
	case w32.WM_SHOWWINDOW:
		if wparam == 1 {
			w.parent.emit(events.Windows.WindowShow)
			w.updateContentProtection()
		} else {
			w.parent.emit(events.Windows.WindowHide)
		}
	case w32.WM_WINDOWPOSCHANGED:
		windowPos := (*w32.WINDOWPOS)(unsafe.Pointer(lparam))

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
v3/pkg/application/webview_window_windows.go (1)

1607-1618: 💤 Low value

Consider adding a nil check for GetClientRect return value.

Other code in this file (lines 621-626) checks for nil from GetClientRect. While failure is extremely unlikely during WM_ERASEBKGND, adding a guard would be consistent with the existing pattern and prevent a potential nil dereference in edge cases.

♻️ Optional defensive check
 if w.parent.options.BackgroundType == BackgroundTypeSolid {
     col := w.parent.options.BackgroundColour
     hdc := w32.HDC(wparam)
     rc := w32.GetClientRect(w.hwnd)
+    if rc == nil {
+        return 1
+    }
     colorRef := w32.COLORREF(uint32(col.Red) | uint32(col.Green)<<8 | uint32(col.Blue)<<16)
     hbrush := w32.CreateSolidBrush(colorRef)
     w32.FillRect(hdc, rc, hbrush)
     w32.DeleteObject(w32.HGDIOBJ(hbrush))
 }
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@v3/pkg/application/webview_window_windows.go` around lines 1607 - 1618, The
code does not validate that GetClientRect returns a valid rectangle before using
it in FillRect, which could cause a nil dereference in edge cases. Add a nil
check on the return value from w32.GetClientRect(w.hwnd) immediately after
retrieving it, and skip the painting operations (FillRect and DeleteObject
calls) if the rectangle is nil. Follow the same defensive pattern used elsewhere
in the file at lines 621-626 to maintain consistency throughout the codebase.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@v3/pkg/application/webview_window_windows.go`:
- Around line 1607-1618: The code does not validate that GetClientRect returns a
valid rectangle before using it in FillRect, which could cause a nil dereference
in edge cases. Add a nil check on the return value from
w32.GetClientRect(w.hwnd) immediately after retrieving it, and skip the painting
operations (FillRect and DeleteObject calls) if the rectangle is nil. Follow the
same defensive pattern used elsewhere in the file at lines 621-626 to maintain
consistency throughout the codebase.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: bd12415f-1c45-4661-99cb-a17730c0fef9

📥 Commits

Reviewing files that changed from the base of the PR and between 9ab0a79 and 1fdc236.

📒 Files selected for processing (2)
  • v3/pkg/application/webview_window_options.go
  • v3/pkg/application/webview_window_windows.go
💤 Files with no reviewable changes (1)
  • v3/pkg/application/webview_window_options.go

@leaanthony
leaanthony merged commit 7ff9687 into master Jun 14, 2026
59 checks passed
@leaanthony
leaanthony deleted the worktree-abstract-scribbling-sparkle branch June 14, 2026 03:00
leaanthony added a commit that referenced this pull request Jul 6, 2026
…GND (#5687)

GetClientRect can return nil during minimise/restore transitions; passing
that to FillRect crashes. Guard before painting the solid background.

Salvaged from #5636 (reported by @sinspired); the rest of that PR was
superseded by #5596/#5616.

Co-authored-by: Lea Anthony <[email protected]>
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.

[v3] Unpainted white areas remain after window resize

2 participants