fyne-io / systray

a cross platfrom Go library to place an icon and menu in the notification area
Apache License 2.0
227 stars 42 forks source link

Linux XFCE submenu empty #12

Open mrpalide opened 2 years ago

mrpalide commented 2 years ago

Hey there! We have an app that use systray, and now I want to submit this report as issue. On Gnome works like a charm. But XFCE is unstable in submenu!, and KDE Plasma is really strange and useless on submenus. You can see bellow screencasts:

Screen Cast

Ubuntu

OS: Ubuntu 22.04 (Minimal Installation) Desktop: Gnome 42.0

https://user-images.githubusercontent.com/79150699/167568719-9211a4c6-570d-43c5-8d81-73499bd43209.mp4

Nitrux (Debianbased)

OS: Nitrux 2.1.1 Desktop: KDE Plasma 5.24.4

https://user-images.githubusercontent.com/79150699/167568652-ef396dcb-4a39-42ca-b193-424b9e290699.mov

Manjaro (Archbased)

OS: Manjaro 21.2.6 Desktop: XFCE

https://user-images.githubusercontent.com/79150699/167568666-b2287651-70f4-4d41-9368-17e8e373f59a.mov

andydotxyz commented 2 years ago

@mrpalide can you please try the fixes on https://github.com/fyne-io/systray/pull/11

mrpalide commented 2 years ago

@mrpalide can you please try the fixes on #11

I test on #11 actually.

andydotxyz commented 2 years ago

OK thanks. Can you please test the example app in this repo and report whether the submenu appears there?

mrpalide commented 2 years ago

I found a huge problem actually on example app! About 100 data race actually appear on that simple example! First built it with -race flag as go build -race example/main.go, then run it ./main.

Use Quit button on systray app to see this on console:

Quit2 now...
Exit at 2022-05-11 13:15:54.215513558 +0430 +0430 m=+4.429888999
Found 100 data race(s)

Also this is a shot of submenu problem of example app on XFCE desktop: image

andydotxyz commented 2 years ago

Also this is a shot of submenu problem of example app on XFCE desktop:

Can you please confirm which version of XFCE? I cannot replicate the problem with 4.16. Be sure to also test the latest master of the systray repo :)

mrpalide commented 2 years ago

Test, and the same result. Chick this video:

https://user-images.githubusercontent.com/79150699/168971528-19f8076a-aa55-4568-85a4-7be53de2024b.mp4

andydotxyz commented 2 years ago

Thank you for this. Can you please confirm if you have any plugins on or configuration regarding the panel? I will try to build a minimal arch to see if I can replicate in the same OS, but so far I can't make it not work in this way.

mrpalide commented 2 years ago

Hey andy, sorry for late response. Yes, I can confirm that no plugin or configuration on panel added.

slytomcat commented 2 years ago

Also this is a shot of submenu problem of example app on XFCE desktop: I found such problem not only in Status Notification Plugin (that serves D-Bus org.kde.StatusNotifierWatcher in XFCE) but also in Indicator plugin (can be used via GTK+ AppIndicator API). So, it seems (for me at least) that this problem is somewhere deeper in GTK, but not in even the panel plugins.

It appears periodically and sometimes it require 10+ restarts of example app to catch the problem.

slytomcat commented 2 years ago

About data races - I fixed a lot of them in my fork. It was a big problem for my project yd-go where menu is used very actively (it's updated rather often). In my case those data races even leads to paincs due to concurrent access to map objects.

slytomcat commented 2 years ago

I also can confirm that KDE notification tray plugin always show submenu on the wrong side (partly outside the screen) during the first opening of submenu. I see such behaviour in my tests on Kubuntu 22.04 (fresh install without and with latest updates). And from my point of view it is also not a systray issue but it's an issue of KDE notification tray plugin or problem is somewhere deeper.

andydotxyz commented 2 years ago

About data races - I fixed a lot of them in my fork.

Great news, if you could open some pull requests I am sure they would be gladly received :).

andydotxyz commented 2 years ago

And from my point of view it is also not a systray issue but it's an issue of KDE notification tray plugin or problem is somewhere deeper.

Agreed, we don't control how the menu will be rendered so can't fix that particular issue I think

slytomcat commented 2 years ago

Ok. I'll do the PR with my fixes.

slytomcat commented 2 years ago

The results of my investigations on the XFCE sub-menu problem.

I've made a huge amount of tests with watching over DBUS communications (using dbus-monitor).

I've found that there are only three possible scenarios leads to 3 different results of the example app work (my comments after # based on info from more detailed dbus-monitor output).

CASE 1 DBUS messages sequence: (type timestamp serial sender destination path interface member # my comment)

Result: both sub-middle and sub-bottom are displayed

CASE 2 DBUS messages sequence: (type timestamp serial sender destination path interface member # my comment)

Result: sub-bottom is not displayed, sub-middle is displayed

CASE 3 DBUS messages sequence: (type timestamp serial sender destination path interface member # my comment)

Result: neither sub-middle nor sub-bottom are displayed


So, the problem is caused by response messages sequence. The only working sequence is exact first-in-first-out.

Unfortunately there is no control on response messages sequence available at the level of systray lib. This is under the control of dbus lib.

slytomcat commented 2 years ago

It. seems that it it not dbus lib issue as there is no requirements in D-Bus specs to handle calls strictly in the same order as they arrived. D-Bus provides calls/response's serial numbers to sort the messages. And it's a caller task to handle responses in the right order.

I've opened the issue in the gitlab.xfce.org/panel-plugins project for fixing this problem.

andydotxyz commented 2 years ago

Thank you so much @slytomcat - let's see what they say. Seems to be some activity so thanks for kicking this off https://gitlab.xfce.org/xfce/xfce4-panel/-/issues/582

slytomcat commented 2 years ago

That's why I love the Open Source World: you 'almost always' :) can find people who can help you.

slytomcat commented 2 years ago

https://gitlab.xfce.org/xfce/xfce4-panel/-/issues/582 is closed as wrong working lib is not maintained any more :(

There is my simply workaround (deployed into my yd-go project):

PATH_TO_PATCH="$(go env GOMODCACHE)/$(cat go.mod | grep 'github.com/godbus/dbus/v5' | sed 's/\s*\(\S\+\) \(.*\)$/\1@\2/')"
chmod a+w $PATH_TO_PATCH
patch <conn.patch -f $PATH_TO_PATCH/conn.go

while conn.patch file contains:

@@ -432,7 +432,7 @@
        case TypeSignal:
            conn.handleSignal(sequence, msg)
        case TypeMethodCall:
-           go conn.handleCall(msg)
+           conn.handleCall(msg)
        }

    }

Patching code can be added to build script like I done it here

Unfortunately I see no better solution at the moment.

BTW: there is some plans to move XFCE panel back-end to Ayatana indicator project. But Ayatana has another big issue: It dosn't support IconPixmap property of org.freedesktop.StatusNotifierItem interface.

andydotxyz commented 2 years ago

Should we open a bug in the godbus project with this patch as the use of a goroutine is causing us problems?

slytomcat commented 2 years ago

https://github.com/godbus/dbus/issues/327 - there is already one opened and closed later about this.

The patch is just a simplest workaround but not the fix of real issue (in libdbusmenu)

andydotxyz commented 2 years ago

Ah yes I see, thanks for all of this. Sadly I'm not sure that we can do anything more in this ticket then, perhaps should just close it - the docs you provide and workaround leave a nice trail for others to find

mrpalide commented 2 years ago

So we should hide sub-menus on XFCE desktops, right? :)

slytomcat commented 2 years ago

@mrpalide no, you can apply the patch to the godbus for your build and sub-menus on XFCE will work fine (because your app will handle the requests from libdbusmenu in the sequense as they comes). It's not perfect solution, but it works.

slytomcat commented 2 years ago

C is not my favorite language but I'll try to find the problem in that lib.

Probably there is someone more experienced in C who can find and fix this issue in libdbusmenu.