fix(v3): guard nil AllowDarkModeForWindow to avoid startup panic#5793
Conversation
…indows 1809 pkg/w32/theme.go loads the undocumented dark-mode uxtheme exports (including AllowDarkModeForWindow) only on Windows build >= 18334, so on older builds such as Windows 10 1809 / Windows Server 2019 (build 17763) the package-level AllowDarkModeForWindow is nil. The Dark and system-dark branches of (*windowsWebviewWindow).run called it unguarded, so a window with Windows.Theme == Dark (or SystemDefault while the OS is in dark mode) panicked on startup with a nil pointer dereference before the window was shown. w32.SetMenuTheme already guards the identical call. Extract the call into an applyDarkMode method, which nil-guards it, and use it from both branches so the window degrades gracefully instead of crashing. Fixes wailsapp#5792
|
Important Review skippedReview was skipped as selected files did not have any reviewable changes. 💤 Files selected but had no reviewable changes (1)
⛔ Files ignored due to path filters (110)
⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Plus Run ID: ⛔ Files ignored due to path filters (110)
📒 Files selected for processing (1)
You can disable this status message by setting the Use the checkbox below for a quick retry:
WalkthroughWindows dark-theme initialization now uses a nil-safe helper before invoking the optional dark-mode API. Both dark system-default and explicit dark themes avoid startup panics on builds without that API, and the fix is documented in the unreleased changelog. ChangesWindows dark-mode startup fix
Estimated code review effort: 1 (Trivial) | ~5 minutes Possibly related PRs
Suggested labels: Suggested reviewers: Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
leaanthony
left a comment
There was a problem hiding this comment.
Correct: AllowDarkModeForWindow is a lazily-resolved uxtheme export that is nil on builds below 18334 (Windows 10 1809 / Server 2019), and the two call sites in run() were the only unguarded ones. Folding them into applyDarkMode matches the guard already used by w32.SetMenuTheme, so the pattern stays consistent. Changelog entry included.
Resolves the UNRELEASED_CHANGELOG conflict by keeping both entries: the 32-bit updater fix that just landed on master and this PR's dark-mode nil guard. Claude-Session: https://claude.ai/code/session_01FigQqUQbNu9ngE4a2CSNm8
…lowDarkModeForWindow to avoid startup panic
…mitting the renders (#5827) Two problems, one cause. The d2 diagrams were never localised: every label in every locale is English. What the per-locale copies actually held was drift. The translation pipeline copied the d2 block when a page was translated and never re-synced it when the English diagram changed, so seven locales rendered an older architecture diagram than the English page, with English labels, on a page explaining how Wails works. de, fr, ja and ru were byte-identical to each other and different from English, which is the signature of a stale copy rather than a translation. Separately, 110 generated SVGs were committed to the repository in #5793. They are build output: astro-d2 writes one per diagram per locale, so the count scales with locales x diagrams and grows as translation coverage improves. - Sync the d2 source from each English page into its translated counterparts, where the diagram counts line up. Prose is untouched, verified by stripping the d2 blocks and confirming the remainder is byte-identical. - Untrack docs/public/d2 and gitignore it. Nine files are deliberately not synced because they need a human. zh-cn's architecture page has four diagrams where English has eight, and eight locales have one lifecycle diagram where English has two: the English pages gained diagrams the translations never received. Inserting a diagram into translated prose is not a mechanical substitution, so the tool reports these and stops. Verified: clean rebuild, 1711 pages, no page loss. architecture-0 went from three variants across locales to one shared render everywhere except zh-cn, which is one of the deliberately skipped files. Every other diagram is now a single variant across all locales. All 110 diagram references in the built HTML resolve to a file on disk, so no broken images. Claude-Session: https://claude.ai/code/session_01FigQqUQbNu9ngE4a2CSNm8 Co-authored-by: taliesin-ai <lea.anthony@gmail.com>
…mitting the renders (#5833) docs: make English the single source for diagram source, and stop committing the renders (#5827) Two problems, one cause. The d2 diagrams were never localised: every label in every locale is English. What the per-locale copies actually held was drift. The translation pipeline copied the d2 block when a page was translated and never re-synced it when the English diagram changed, so seven locales rendered an older architecture diagram than the English page, with English labels, on a page explaining how Wails works. de, fr, ja and ru were byte-identical to each other and different from English, which is the signature of a stale copy rather than a translation. Separately, 110 generated SVGs were committed to the repository in #5793. They are build output: astro-d2 writes one per diagram per locale, so the count scales with locales x diagrams and grows as translation coverage improves. - Sync the d2 source from each English page into its translated counterparts, where the diagram counts line up. Prose is untouched, verified by stripping the d2 blocks and confirming the remainder is byte-identical. - Untrack docs/public/d2 and gitignore it. Nine files are deliberately not synced because they need a human. zh-cn's architecture page has four diagrams where English has eight, and eight locales have one lifecycle diagram where English has two: the English pages gained diagrams the translations never received. Inserting a diagram into translated prose is not a mechanical substitution, so the tool reports these and stops. Verified: clean rebuild, 1711 pages, no page loss. architecture-0 went from three variants across locales to one shared render everywhere except zh-cn, which is one of the deliberately skipped files. Every other diagram is now a single variant across all locales. All 110 diagram references in the built HTML resolve to a file on disk, so no broken images. Claude-Session: https://claude.ai/code/session_01FigQqUQbNu9ngE4a2CSNm8 Co-authored-by: taliesin-ai <lea.anthony@gmail.com>
Description
Fixes a nil-pointer panic on startup when a window uses a Dark (or system-dark) native title bar on Windows builds that do not load the dark-mode
uxthemeAPIs — e.g. Windows 10 1809 / Windows Server 2019 (build 17763).pkg/w32/theme.goloadsAllowDarkModeForWindow(and siblings) only on build>= 18334, so on 1809 the package-levelw32.AllowDarkModeForWindowisnil.(*windowsWebviewWindow).runcalled it unguarded in theDarkand darkSystemDefaultbranches (webview_window_windows.go), whilew32.SetMenuTheme` already guards the identical call.The fix extracts the call into a small applyDarkMode helper that nil-guards it (mirroring the guard w32.SetMenuTheme already uses) and calls it from both branches, so the window degrades gracefully (default title bar) instead of panicking. No behavior change on builds that load the procs; no new dependencies.
Fixes #5792
Type of change
How Has This Been Tested?
Built a minimal v3 app with
Windows: application.WindowsWindow{Theme: application.Dark}and ran it on Windows Server 2019 (build 17763): before, it panicked on startup; after, the window opens normally.Reproduction repo: https://github.com/roachadam/wails-1809-dark-title-bar-poc.
Test Configuration
Wails is not installed on this VM, so there is no wails3 doctor output. Reproduced with a minimal app instead: my existing app (built on v3.0.0-alpha.68) failed to start on Windows Server 2019 Standard Evaluation (build 17763). I reproduced the panic in isolation using the POC above built against the tagged v3.0.0-alpha2.117 release, then rebuilt the POC against this fix and confirmed the window opens normally.
Checklist:
website/src/pages/changelog.mdxwith details of this PR (v3 changelog entries are added automatically)Summary by CodeRabbit