ckerr

#54777: fix: avoid menu bar crash when GTK cannot initialize

Merged
Created: Oct 8, 2026, 12:01:05 PM
Merged: Oct 12, 2026, 9:08:40 AM
5 comments
Target: main

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.ts to 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.ts passed (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

Release Notes

Notes: Fixed a Linux crash creating a window with a menu bar when GTK failed to load.

Backports

43-x-y
Pending
Waiting for a manual backport
44-x-y
Merged
PR Number
#54859
Merged At
Oct 13, 2026, 1:41:33 AM
Released In
Not yet
Release Date
Not yet
45-x-y
Merged
PR Number
#54846
Merged At
Oct 12, 2026, 1:08:31 PM
Released In
v45.0.0-beta.2
Release 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