Skip to content

fix(v3/windows): guard FillRect against nil client rect in WM_ERASEBKGND#5687

Merged
leaanthony merged 2 commits into
masterfrom
salvage-fillrect-guard-5636
Jul 6, 2026
Merged

fix(v3/windows): guard FillRect against nil client rect in WM_ERASEBKGND#5687
leaanthony merged 2 commits into
masterfrom
salvage-fillrect-guard-5636

Conversation

@taliesin-ai

@taliesin-ai taliesin-ai commented Jun 28, 2026

Copy link
Copy Markdown
Collaborator

During minimise/restore transitions GetClientRect can legitimately return nil; passing that to FillRect crashes when painting the solid background in WM_ERASEBKGND. This guards the call.

Salvaged from #5636 — that PR's main change (moving resizePending to a per-window field) was superseded by #5596 (which removed the resize-debounce mechanism entirely) and #5616, but this nil-rect guard was a genuine, still-unfixed hardening. Credit to @sinspired for spotting it.

Builds clean for GOOS=windows.

Summary by CodeRabbit

  • Bug Fixes
    • Fixed a Windows crash during minimize/restore transitions when the window client area was temporarily unavailable.
    • Fixed a macOS crash that could occur when screens changed.
    • Fixed a Linux (GTK4) issue where the native menu could fail to rebuild correctly.
  • Chores
    • Updated the unreleased changelog with the latest fixes.

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.
@coderabbitai

coderabbitai Bot commented Jun 28, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 6bda33bd-82e6-45bc-981c-fe086fbc9a07

📥 Commits

Reviewing files that changed from the base of the PR and between 3b35600 and 0694292.

📒 Files selected for processing (1)
  • v3/UNRELEASED_CHANGELOG.md

Walkthrough

Adds a nil check in the Windows WM_ERASEBKGND handler so painting is skipped when GetClientRect returns nil, and updates the unreleased changelog with related fixed crash entries.

Changes

Windows repaint crash guard

Layer / File(s) Summary
Nil rect guard and changelog
v3/pkg/application/webview_window_windows.go, v3/UNRELEASED_CHANGELOG.md
WM_ERASEBKGND now checks GetClientRect for nil before calling FillRect; the changelog adds fixed bullets for GTK4 Linux, macOS, and Windows crash issues.

Estimated code review effort: 1 (Trivial) | ~3 minutes

Possibly related PRs

  • wailsapp/wails#5596: Changes the same Windows WM_ERASEBKGND painting path in webview_window_windows.go.
  • wailsapp/wails#5616: Also touches Windows minimize/restore handling in webview_window_windows.go.
  • wailsapp/wails#5683: Updates v3/UNRELEASED_CHANGELOG.md with overlapping unreleased fixed entries.

Suggested labels: Bug, Documentation, go, Windows, v3, v3-alpha, size:XS

Suggested reviewers: leaanthony, atterpac

Poem

A bunny saw a nil and said, “No paint today!”
The brush stayed tucked away, the crash hopped far away.
On Windows screens, the repaint path is lean and bright,
A tiny guard keeps minimise/restore safe tonight.
Hop hop, fixed! 🐇

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description summarizes the fix and context, but it omits the required fixed issue reference and most template sections. Add the issue number with 'Fixes #' and fill the template sections for type of change, testing, and wails doctor output.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title is concise and accurately describes the main change: guarding FillRect against a nil client rect in WM_ERASEBKGND.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch salvage-fillrect-guard-5636

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.

@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.

Actionable comments posted: 1

🤖 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.

Inline comments:
In `@v3/pkg/application/webview_window_windows.go`:
- Around line 1634-1638: The nil check in the paint path is ineffective because
`w32.GetClientRect` in `user32.go` panics on failure and never returns nil on
success, so the minimize/restore case still crashes before `FillRect` runs. Fix
this at the wrapper boundary by adding a non-panicking client-rect helper such
as `TryGetClientRect` or `GetClientRectOK` that returns both the `RECT` and a
success flag, then update the `w.hwnd` rendering code to use that helper and
skip painting when the call fails.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 8adc84a0-b907-44f1-a828-957f30a455b8

📥 Commits

Reviewing files that changed from the base of the PR and between 885963f and 3b35600.

📒 Files selected for processing (2)
  • v3/UNRELEASED_CHANGELOG.md
  • v3/pkg/application/webview_window_windows.go

Comment thread v3/pkg/application/webview_window_windows.go
@leaanthony leaanthony merged commit 97f5f46 into master Jul 6, 2026
12 of 17 checks passed
@leaanthony leaanthony deleted the salvage-fillrect-guard-5636 branch July 6, 2026 06:13
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.

2 participants