Opened 7 months ago

Last modified 12 days ago

#18641 reopened defect

MenuBar in macOS Catalina broken

Reported by: LtJax Owned by:
Priority: normal Milestone:
Component: wxOSX Version: 3.0.4
Keywords: 10.15 Cc: csomor@…, msoegtrop@…
Blocked By: Blocking:
Patch: no

Description

As already discussed on the forums (https://forums.wxwidgets.org/viewtopic.php?f=23&t=46362&sid=d90db3dbc472da5bff935c83f8f5036a), the menu bar for macOS Catalina is completely broken, i.e. clicking on any menu items does exactly nothing.
I have tried this with my own app and the minimal and menu examples from the github master, but it is also broken in 3.1.3.

How to reproduce: Build an application with a menubar, and try to click on it.
Expected: Opens a submenu
Current outcome: Does nothing

Change History (11)

comment:1 Changed 7 months ago by vadz

  • Cc csomor@… added
  • Keywords 10.15 added
  • Milestone set to 3.2.0

I don't have 10.15 yet, so I have no idea what's going on here. If anybody could please debug this, it would be great.

Stefan, sorry for bothering you directly, but are you aware of this problem?

comment:2 Changed 7 months ago by LtJax

  • Cc marius.elvert@… added

I can possibly help debug this, but I think I need a guiding hand / a few pointers. I found the code setting up the menus in the Cocoa code, but the objective C stuff looks quite alien.

comment:3 Changed 7 months ago by LtJax

  • Cc marius.elvert@… removed

I've looked into this some more, and it seems the menu starts working after changing focus away from the app and back to it. Works with my app, as well as with the "menu" and "minimal" examples

comment:4 Changed 2 weeks ago by csomor

  • Resolution set to worksforme
  • Status changed from new to closed

I've rebuilt everything from git master, built minimal sample the started and things work as they should.

Meaning the minimal app bundles whether built on the console or with Xcode work and are responsive (there is no file menu but the app menu shows the about entry and it is working)

The behavior explained above happens when the non-bundled executable is clicked, but this executable is part of the building process, not the 'real' app. The bundled version carries the wx icon in the finder. The non-bundled executable has the black command line exe icon.

Bundles are a must in the latest versions of macOS. For more details

https://www.wxwidgets.org/docs/faq/osx/

and

https://wiki.wxwidgets.org/WxMac-specific_topics#Building_a_MacOSX_application_bundle

Last edited 2 weeks ago by csomor (previous) (diff)

comment:5 follow-up: Changed 13 days ago by MSoegtrop2

  • Cc msoegtrop@… added
  • Resolution worksforme deleted
  • Status changed from closed to reopened
  • Version changed from dev-latest to 3.0.4

In my experience it is not that simple. I am the MacPorts maintainer of wxMaxima. We are using app bundles and I am talking about starting the installed app.

My experience with this bug is as follows: it reproducibly works fine one day and reproducibly doesn't work another day without changing anything (without recompile). There seems to be some OS state which leads to this. I couldn't figure out as yet what it is. Restarting wxMaxima usually does not change this. Restarting the Mac sometimes does.

So just because it works in one test doesn't mean it works. One has to observe for at least two weeks for a app used daily.

Please try "port install wxMaxima" and see what the menus do or if you can find a flaw in the bundling process.

Of cause one can discuss if this is a bug of wxWidgets or of macOS, since it did work fine up to including macOS 10.14. On the other hand everything which is not using wxWidgets (I am also using Qt and GTK3 apps daily) has working menus.

comment:6 Changed 13 days ago by vadz

  • Milestone 3.2.0 deleted

I'm afraid you'll really have to try to reproduce the problem in one of the samples, it's going to be difficult for anybody else to dive into the details of an application that we know nothing about.

I'm leaving this opened, but removing 3.2 milestone because it's unlikely that we can fix it without your, or wxMaxima developers, help.

comment:7 Changed 13 days ago by csomor

I thanks for following up

We need a reproducible - even if only sometimes - case for this. Menus are not broken per se, otherwise many apps, including my own would not work correctly, and I'm working on Catalina since a long time.

The situation described here for minimal sample matches the precisely what is happening if launched as executable directly. Reproducible, always. If launched as bundle, the menu works, reproducible, always.

So if wxMaxima is exhibiting a similar problem, sometimes, then there may be many other things involved. Eg the bootstrapping process of a wx app on mac, ie when certain things can be executed or not yet, is quite delicate, I cannot fully adapt this to the Cocoa way of doing things, without breaking backwards compatibility.

I'll look at wxMaxima, and perhaps you could try to find out, whether you can mix-in the boot actions that happen within wxMaxima into a wx sample. So that we can isolate where things fall of the track.

comment:8 in reply to: ↑ 5 ; follow-up: Changed 12 days ago by csomor

Replying to MSoegtrop2:

Please try "port install wxMaxima" and see what the menus do or if you can find a flaw in the bundling process.

I've installed it, right now the menus work, but I'll retry this in the next days a few times.

But what you can observe when comparing eg the bundle minimal sample is getting with yours, that there are a few things missing in your Info.plist. Some of them are rather for display purposes, but things like NSPrincipalClass or CFBundleIdentifier, CFBundleName are missing as well. I don't know whether they might cause this effect, but it would be good to have them properly setup. Also the File PkgInfo is also missing, it carries the CFBundlePackageType and the CFBundleSignature concatenated.

One of this fixes also allowed to use the app properly in Retina resolution, I haven't had the time to dissect which one ...

I've copied some parts of your main.cpp into minimal sample to have a similar sequence and a global menubar, a wxFrame with its own menubar, I'll also lauch this a few times in the next days to see ...

comment:9 in reply to: ↑ 8 Changed 12 days ago by MSoegtrop2

  • Cc msoegtrop@… removed

Replying to csomor:

I've installed it, right now the menus work, but I'll retry this in the next days a few times.

Thanks for trying it! Can you please name a wxWidgets application (preferably on I can install via macports) which I could try as good example, both in terms of that it works and in terms of how it is built / installed.

But what you can observe when comparing eg the bundle minimal sample is getting with yours, that there are a few things missing in your Info.plist. Some of them are rather for display purposes, but things like NSPrincipalClass or CFBundleIdentifier, CFBundleName are missing as well. I don't know whether they might cause this effect, but it would be good to have them properly setup. Also the File PkgInfo is also missing, it carries the CFBundlePackageType and the CFBundleSignature concatenated.

Thanks for the hints - I will follow up on this. I inherited this project just a few months back and didn't have time to look into everything as yet.

Btw.: when I switch to a different window and back to wxMaxima after starting it frequently fixes the menu issue for a while. When you test it, maybe you can try to avoid this.

comment:10 Changed 12 days ago by csomor

Yes, I always just launch the bundle, and then immediately test the menus, no background/foreground switch.

As I said, I'd compare with minimal sample, to make sure the low hanging fruit can be reaped, most of the apps I know of are commercial apps using wx but IMHO an excellent example which is Open Source is Václav Slavík's PoEdit

sudo port install poedit

https://github.com/vslavik/poedit

Last edited 12 days ago by csomor (previous) (diff)

comment:11 Changed 12 days ago by MSoegtrop2

  • Cc msoegtrop@… added

Thanks - I will try poEdit a few times a day and see if the menus work reliably there (a first test was good while wxMaxima had issues).

Also I will review and compare our package building process.

Note: See TracTickets for help on using tickets.