Skip to content

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

Merged
jkleinsc merged 3 commits into
mainfrom
fix/wayland-menu-gtk-fallback
Oct 12, 2026
Merged

jkleinsc merged 3 commits into
mainfrom
fix/wayland-menu-gtk-fallback

Conversation

@ckerr

@ckerr ckerr commented Oct 8, 2026 •

Copy link
Copy Markdown
Member

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.

@ckerr ckerr added semver/patch backwards-compatible bug fixes target/44-x-y PR should also be added to the "44-x-y" branch. target/45-x-y PR should also be added to the "45-x-y" branch. target/43-x-y PR should also be added to the "43-x-y" branch. labels Oct 8, 2026
ckerr and others added 2 commits October 8, 2026 22:31
Guard GTK menu color lookups on toolkit theme availability and fall back to Views menu colors when GTK initialization fails. Cover framed window creation and theme refresh with an incompatible Wayland GSettings schema.

Fixes #54594

Co-authored-by: Copilot <[email protected]>
Add gtk_util::IsGtkAvailable() and use it for the menu bar's GTK color lookup.
Also use it in the icon lookup behind app.getApplicationInfoForProtocol(),
which called into GTK the same way and crashed when GTK was not loaded.

Run api-menu.spec.ts on the Wayland CI leg so the new spec runs in CI,
and describe the fallback menu colors accurately in the docs.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@ckerr
ckerr force-pushed the fix/wayland-menu-gtk-fallback branch from d23443a to 4b557d6 Compare October 9, 2026 03:31
In CI there is no accessibility D-Bus service and no accessibility env var,
so Chromium's accessibility check falls back to reading toolkit-accessibility
from org.gnome.desktop.interface.
The spec's minimal schema lacked that key, so GLib aborted the app with SIGTRAP.
Real schemas that predate font-antialiasing still have toolkit-accessibility.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

@deepak1556 deepak1556 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Nice mocked spec!

@jkleinsc
jkleinsc merged commit 9cb9173 into main Oct 12, 2026
75 checks passed
@jkleinsc
jkleinsc deleted the fix/wayland-menu-gtk-fallback branch October 12, 2026 14:08
@release-clerk

release-clerk Bot commented Oct 12, 2026

Copy link
Copy Markdown

Release Notes Persisted

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

@trop

trop Bot commented Oct 12, 2026

Copy link
Copy Markdown
Contributor

I was unable to backport this PR to "44-x-y" cleanly;
you will need to perform this backport manually.

@trop

trop Bot commented Oct 12, 2026

Copy link
Copy Markdown
Contributor

I was unable to backport this PR to "43-x-y" cleanly;
you will need to perform this backport manually.

@trop trop Bot added needs-manual-bp/44-x-y needs-manual-bp/43-x-y and removed target/44-x-y PR should also be added to the "44-x-y" branch. target/43-x-y PR should also be added to the "43-x-y" branch. labels Oct 12, 2026
@trop

trop Bot commented Oct 12, 2026

Copy link
Copy Markdown
Contributor

I have automatically backported this PR to "45-x-y", please check out #54846

@trop trop Bot added in-flight/45-x-y merged/45-x-y PR was merged to the "45-x-y" branch. and removed target/45-x-y PR should also be added to the "45-x-y" branch. in-flight/45-x-y labels Oct 12, 2026
@trop

trop Bot commented Oct 12, 2026

Copy link
Copy Markdown
Contributor

claude[bot] has manually backported this PR to "44-x-y", please check out #54859

dsanders11 pushed a commit that referenced this pull request Oct 13, 2026
fix: avoid menu bar crash when GTK cannot initialize (#54777)

* fix: avoid menu bar crash when GTK cannot initialize

Guard GTK menu color lookups on toolkit theme availability and fall back to Views menu colors when GTK initialization fails. Cover framed window creation and theme refresh with an incompatible Wayland GSettings schema.

Fixes #54594



* fix: check GTK availability with one helper

Add gtk_util::IsGtkAvailable() and use it for the menu bar's GTK color lookup.
Also use it in the icon lookup behind app.getApplicationInfoForProtocol(),
which called into GTK the same way and crashed when GTK was not loaded.

Run api-menu.spec.ts on the Wayland CI leg so the new spec runs in CI,
and describe the fallback menu colors accurately in the docs.



* test: give the no-GTK menu spec's schema the toolkit-accessibility key

In CI there is no accessibility D-Bus service and no accessibility env var,
so Chromium's accessibility check falls back to reading toolkit-accessibility
from org.gnome.desktop.interface.
The spec's minimal schema lacked that key, so GLib aborted the app with SIGTRAP.
Real schemas that predate font-antialiasing still have toolkit-accessibility.



---------



(cherry picked from commit 9cb9173)


Claude-Session: https://claude.ai/code/session_015GReMcdLqJ1Grhw5C8TvVx

Co-authored-by: Claude <[email protected]>
@trop trop Bot added merged/44-x-y PR was merged to the "44-x-y" branch. and removed in-flight/44-x-y labels Oct 13, 2026
@trop

trop Bot commented Oct 13, 2026

Copy link
Copy Markdown
Contributor

claude[bot] has manually backported this PR to "43-x-y", please check out #54884

claude Bot pushed a commit that referenced this pull request Oct 13, 2026
Manual backport of #54777 to 43-x-y.

Conflicts:
- shell/browser/ui/gtk_util.cc: 43-x-y also includes SkUnPreMultiply.h;
  kept it and added the new ui/color and ui/linux includes after it.
- script/wayland-test-allowlist.txt: 43-x-y's allowlist has no
  api-clipboard.spec.ts entry; added only api-menu.spec.ts.

(cherry picked from commit 9cb9173)

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01Cn8pbCoCtwodWGX6aQ94o4
MarshallOfSound pushed a commit that referenced this pull request Oct 14, 2026
fix: avoid menu bar crash when GTK cannot initialize (#54777)

Manual backport of #54777 to 43-x-y.

Conflicts:
- shell/browser/ui/gtk_util.cc: 43-x-y also includes SkUnPreMultiply.h;
  kept it and added the new ui/color and ui/linux includes after it.
- script/wayland-test-allowlist.txt: 43-x-y's allowlist has no
  api-clipboard.spec.ts entry; added only api-menu.spec.ts.

(cherry picked from commit 9cb9173)


Claude-Session: https://claude.ai/code/session_01Cn8pbCoCtwodWGX6aQ94o4

Co-authored-by: Claude <[email protected]>
@trop trop Bot added merged/43-x-y PR was merged to the "43-x-y" branch. and removed in-flight/43-x-y labels Oct 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

46-x-y merged/43-x-y PR was merged to the "43-x-y" branch. merged/44-x-y PR was merged to the "44-x-y" branch. merged/45-x-y PR was merged to the "45-x-y" branch. semver/patch backwards-compatible bug fixes

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

[Bug]: SIGSEGV in MenuBar::RefreshColorCache when creating a framed BrowserWindow with a menu on Wayland (GTK not loaded)

3 participants