J-Lentz / iwgtk

Lightweight wireless networking GUI (front-end for iwd)
GNU General Public License v3.0
203 stars 14 forks source link

Tray icon shows up and crashes on Fedora 37 / Gnome 43 #37

Open d3-X-t3r opened 1 year ago

d3-X-t3r commented 1 year ago

I'm using the AppIndicator and KStatusNotifierItem Support extension on Fedora 37 / Gnome 43. The extension works itself works fine, all other apps have no problem showing a tray icon, however, the iwgtk icon only shows up briefly before automatically exiting. I don't see any error messages. The full version of the app works just fine though, so it's only the tray icon that's having the issue.

Any ideas what could be wrong, or any logs that I can submit which might help?

J-Lentz commented 1 year ago

If you run iwgtk -i in a terminal, do you see any error messages?

sfrieske commented 1 year ago

Got the same issue, running gnome-shell (although on Arch). The icon shows up for 1..2 seconds and then goes away. iwgtk -i in a terminal shows no error in the terminal and keeps running. The log output is below:

Jan 04 16:00:55 linus gnome-shell[622]: Received property WindowId with type u does not match expected type i in the expected interface Jan 04 16:00:56 linus appindicatorsupport@rgcjonas.gmail.com[622]: While initalizing proxy for org.kde.StatusNotifierItem-1374-1: Gio.DBusError: GDBus.Error:org.freedesktop.DBus.Error.UnknownProperty: Property 'Menu' is not implemented Jan 04 16:00:56 linus gnome-shell[622]: Unhandled promise rejection. To suppress this warning, add an error handler to your promise chain with .catch() or a try-catch block around your await expression. Stack trace of the failed promise: _setupProxy@/usr/share/gnome-shell/extensions/appindicatorsupport@rgcjonas.gmail.com/appIndicator.js:111:22 AppIndicatorsAppIndicator@/usr/share/gnome-shell/extensions/appindicatorsupport@rgcjonas.gmail.com/appIndicator.js:100:14 _registerItem@/usr/share/gnome-shell/extensions/appindicatorsupport@rgcjonas.gmail.com/statusNotifierWatcher.js:97:31 _ensureItemRegistered@/usr/share/gnome-shell/extensions/appindicatorsupport@rgcjonas.gmail.com/statusNotifierWatcher.js:142:20 RegisterStatusNotifierItemAsync@/usr/share/gnome-shell/extensions/appindicatorsupport@rgcjonas.gmail.com/statusNotifierWatcher.js:207:24 async*_handleMethodCall@resource:///org/gnome/gjs/modules/core/overrides/Gio.js:368:35

J-Lentz commented 1 year ago

This implies that there's no crash occurring; rather, our implementation of the StatusNotifierItem API doesn't seem to mesh with that of the Gnome shell extension.

According to the freedesktop.org version of the SNI spec [1], WindowId should be a UINT32 (u), while KDE's implementation [2] uses a signed int32 (i). We've implemented the former, while the Gnome shell extension seems to prefer (or require?) the latter. Since we're using the org.kde namespace, it might be best to ditch the spec and go with the KDE standard.

However, my suspicion is that the problem lies in our implementation of the Menu property (or alternatively, in the Gnome shell extension's implementation). The spec doesn't specify how this property should be set when the application has no menu. Currently, iwgtk returns a DBus UnknownProperty error, but perhaps we should return an empty string instead. The Gnome shell extension should arguably be more forgiving in how it handles this, since the lack of a menu can be inferred from the ItemIsMenu property.

[1] https://freedesktop.org/wiki/Specifications/StatusNotifierItem/StatusNotifierItem/ [2] https://github.com/KDE/knotifications/blob/master/src/org.kde.StatusNotifierItem.xml

sfrieske commented 1 year ago

A quite quick reply :) Your conclusions make some sense to me. I was wondering myself about the kde namespace because Gnome Shell doesn't normally use it (AFAIK). I don't know a lot about the intrisics of Gnome and it's extensions. My suspicion is that this a side effect of upgrading to Gnome 43 or 42, it used to work in Gnome 40 (and maybe 41). I'm not a good developer but I can run make as long as I have a (complete) zip package and try it out, if this helps any. The application is really great and I'll do what I can to help you get it working again with Gnome. Probably you just need to think for a couple of ours and then change a singe line :)

sfrieske commented 1 year ago

Noticed your code update ('refactored agent.c') and tried it out. Sadly no change w/ respect to the vanishing icon.

J-Lentz commented 1 year ago

After reproducing the issue in Gnome, I tried changing the type of WindowId, and returning an empty string for Menu (instead of issuing an UnknownProperty error). Unfortunately, these didn't fix it.

Commit ad13595443ceca25e76f2a30e4bf03f566df27b1 is unrelated.

It wouldn't hurt to open a bug on the gnome-shell-extension-appindicator bug tracker, since they might have a better idea of what's going wrong here. With that said, the real problem is the lack of a well-defined, widely adopted tray icon standard.

sfrieske commented 1 year ago

While the tray icon itself is useful to see the WiFi status, I use the menu only to open the app. What do you think about removing the menu completely and adding a click action to open the app instead? Alternately you could (please, please) add a cmdline switch like --nomenu (-m).

J-Lentz commented 1 year ago

iwgtk has no menu, which gnome-shell-extension-appindicator should be able to infer from the ItemIsMenu=false DBus property. But despite this, dbus-monitor indicates that gnome-shell-extension-appindicator attempts to access the Menu property (as well as the Id property) twice and then subsequently unregisters the icon. My suspicion is that gnome-shell-extension-appindicator unregisters the icon due to some unmet expectation regarding the Menu property. But it might also be some other problem, unrelated to Menu.

sfrieske commented 1 year ago

After some experiments with the code of gnome-shell-extension-appindicator I was able to catch the specific exception that occurs on the start of iwgtk -i. Removing the destroy() there makes iwgtk work as expected and is a good workaround for me.

By accident I found this line: const NEEDED_PROPERTIES = ['Id', 'Menu'];. It supports your suspicion. A couple of comments in the different files clearly indicate that this Gnome shell extension is a port from KDE and they seem to struggle with a couple of (in general minor) issues making it not yet matching Freedesktop.org's requirements. I'll try to get this issue addressed with the appindicator devs.

In summary I tend to suggest to close this issue (cannot do it myself as it's not mine). Thank you very much for your interest in this topic and your quick support!

sfrieske commented 1 year ago

Opened issues #390 and #389 for gnome-shell-extension-appindicator.

J-Lentz commented 1 year ago

Cool, thanks for investigating this. I'd be happy to add a workaround on the iwgtk side, but neither of the prospective solutions that I attempted (making WindowId an int32, and returning an empty string for Menu instead of a DBus UnknownProperty error) worked.