#54777: fix: avoid menu bar crash when GTK cannot initialize
Merged
Description of Change
Fixes #54594
On Linux, MenuBar::RefreshColorCache() always read the menu bar colors from GTK.
When GTK cannot initialize, for example on GNOME 3.32 under Wayland, whose org.gnome.desktop.interface schema lacks keys Chromium requires, GTK is never loaded.
The gtk:: helpers then call through null function pointers, so creating a framed BrowserWindow with a menu crashed.
#54365 fixed the same problem in the title bar; this fixes the menu bar.
- Add
gtk_util::IsGtkAvailable(), which is true only when Chromium's GTK UI initialized. - Without GTK, the menu bar uses the widget's built-in light or dark menu colors, which follow
nativeTheme. - The icon lookup behind
app.getApplicationInfoForProtocol()called into GTK the same way. It now returns no icon instead of crashing, so the promise rejects with the existing "Failed to get file icon." error. - Add a Wayland spec that makes GTK initialization fail with an incomplete GSettings schema, then creates and re-themes a window menu.
- Add
api-menu.spec.tsto the Wayland CI allowlist so that spec runs in CI.
Validation
Ran on a local Linux testing build of main under headless weston, the same way as CI's Wayland leg:
- All of
api-menu.spec.tspassed (128 passed; the rest skipped by their own platform conditions). - The new spec ran and passed on its own.
- clang-format and markdownlint pass.
🤖 Generated with Claude Code
Checklist
- I have built and tested this change
- I have filled out the PR description
- I have reviewed and verified the changes
-
npm testpasses - tests are changed or added
- relevant API documentation, tutorials, and examples are updated and follow the documentation style guide
- PR release notes describe the change in a way relevant to app developers, and are capitalized, punctuated, past tense, and no longer than 80 characters.
Release Notes
Notes: Fixed a Linux crash creating a window with a menu bar when GTK failed to load.
Backports
43-x-y
PendingWaiting for a manual backport
45-x-y
MergedPR Number
#54846Merged At
Oct 12, 2026, 1:08:31 PM
Released In
v45.0.0-beta.2Release Date
Oct 12, 2026, 3:00:48 PM
Semver Impact
Major
Breaking changes
Minor
New features
Patch
Bug fixes
None
Docs, tests, etc.
Semantic Versioning helps users understand the impact of updates:
- Major (X.y.z): Breaking changes that may require code modifications
- Minor (x.Y.z): New features that maintain backward compatibility
- Patch (x.y.Z): Bug fixes that don't change the API
- None: Changes that don't affect using facing parts of Electron