Repository navigation
[macOS] Workaround for main menu bar items not shown on macOS 27 - #3757
HeikoKlare wants to merge 1 commit into
Conversation
fd2f49f to
c6e844b
Compare
|
Thanks for this. I did a quick test with our RCP app and the snippets in #3540 and can confirm that this does work. |
In practice for me they are blank/hidden forever or until mouse over. |
Sometimes (very seldom) they show up for me automatically after some time. But I can confirm that they usually stay blank until one of these two events happens:
|
|
Thank you Heiko. Should we maybe place a comment in form of a |
On macOS 27, items inserted into the main menu are not shown on screen until the mouse hovers over the menu bar or the application is activated again. This happens when the menu bar is swapped while a dialog becomes or stops being the key window, and when an item is added to the active menu bar. It also occurs in plain AppKit applications, so it is a macOS regression whose root cause is unknown. As a workaround, re-assert the main menu by setting it to null and back, which makes AppKit resync the menu bar. NSMenu.update() or setting the same main menu again do not help. The refresh is done asynchronously, since it is sometimes ignored while a shell is still becoming the key window, which also coalesces a series of menu bar item additions. Contributes to eclipse-platform#3540 Assisted-by: Claude Opus 5.5 <noreply@anthropic.com>
c6e844b to
e427468
Compare
|
Thank you @Phillipus and @gravemalte for testing and for your feedback! Your comments are addressed with the latest push:
I have posted additional insights into the cause in the issue: #3540 (comment) @soethoff @BeckerWdf @sratz since you probably have a particular interest in regressions of the SWT macOS port, I would appreciate the feedback from anyone of you on this change as well. |
|
@HeikoKlare Thanks for your work on this. For my own part I will test each macOS 27.x release to test if this might be fixed by Apple. |
|
The menu problem is fixed in macOS 27.2 RC. See #3540 (comment) |
|
Closing this as obsolete according to #3540 (comment) The issue will be fixed with macOS 27.2. |
Contributes to #3540
Problem
On macOS 27, items inserted into the main menu bar are not shown on screen until the mouse hovers over the menu bar or the application is activated again (e.g. by switching to another application and back). This affects:
MenuItemto the active menu bar (e.g. while the workbench fills its menu bar at startup).SWT updates the
NSMenucorrectly and in time; the update gets lost between AppKit and the system's menu bar. Removing or renaming top-level items is not affected.Workaround
After inserting items into the main menu, re-assert it via
NSApp.setMainMenu(nil)followed byNSApp.setMainMenu(menu), which forces AppKit to resync the menu bar. The menu is retained around the calls, asNSAppmay hold the only reference to it.Display.setMenuBar()and afterMenu.createItem()adds an item to the active menu bar. Doing it synchronously within the key window change is sometimes ignored by AppKit (observed while a sheet closes). Being asynchronous, consecutive changes are coalesced into a single refresh.Lighter alternatives were tested and do not help:
[NSMenu update], setting the same main menu again, and either of those executed asynchronously.We do not know why macOS 27 stops showing newly inserted menu bar items, and we could not find any documentation of a related AppKit change. This change does not fix a root cause in SWT; it forces AppKit to resync the menu bar. It may become unnecessary, or need adjusting, with future macOS updates, and it should be revisited once the cause is understood.
Still, it is the best solution we currently have, and we think it is better to ship this workaround for 2026-12 than to leave the menu bar broken for all SWT/Eclipse applications on macOS 27.
Testing (macOS 27, aarch64)
Verified with screenshots of the menu bar over time, with and without the change:
MessageBoxAlso checked manually: menus open normally after a refresh, and Cmd+H / Cmd+Q from the application menu still work.
Test_org_eclipse_swt_widgets_Menu,MenuItem,ShellandDisplaypass with the same results as without the change.🤖 Generated with Claude Code