Bug 483170

Summary: appmenu (global menu) doesn't work with krita on plasma 6
Product: [Applications] krita Reporter: sansan2111
Component: UsabilityAssignee: Krita Bugs <krita-bugs-null>
Status: RESOLVED FIXED    
Severity: normal CC: daf.public, halla, mikesmith929+kde, saileshpoudel0, wks1986, zxq5
Priority: NOR Keywords: qt6
Version: 5.2.2   
Target Milestone: ---   
Platform: Arch Linux   
OS: Linux   
Latest Commit: Version Fixed In:
Sentry Crash Report:
Attachments: Screenshot
Script for reproducing the dbus behavior of Krita

Description sansan2111 2024-03-10 21:18:08 UTC
Created attachment 166915 [details]
Screenshot

SUMMARY
After upgrading my system to the latest version of  KDE plasma 6 my global menu stopped working with krita. Menu is completely missing from both app and panel.


STEPS TO REPRODUCE
1. upgrade to the latest plasma version (plasma-desktop 6.0.1-1)
2. upgrade to the latest krita version (5.2.2-7)
3. have a global menu set up with a widget for global menu in a panel (applet-window-appmenu 0.8.0)

OBSERVED RESULT
Menu does not appear neither inside the app, nor on the panel 

EXPECTED RESULT
Menu should appear inside the panel 

SOFTWARE/OS VERSIONS
Linux: Arch Linux 6.7.9-zen1-1-zen
KDE Plasma Version: 6.0.1-1
KDE Frameworks Version: 6.0.0
Qt Version: 6.6.2
Graphics Platform:X11

ADDITIONAL INFORMATION
 I think menu does "blink" for a sec when i launch krita, but it might be just a visual.  Other apps appear to be working as expected. Launching krita with "KDE_NO_GLOBAL_MENU=1" does make menu to appear inside the app.  Downgrading krita to 5.1.5-11 solves this issue, menu does show up in the panel as expected. Installing krita from  flatpak  version (5.2.2) also solves this issue, menu does appear inside the panel. Snap version also doesn't work with global menu
Comment 1 Kunshan Wang 2024-03-11 02:49:09 UTC
I can confirm this.  When I open Krita, the global menu is simply empty (sometimes only the "search" item).  There is no menu in the main window of Krita, either.

When invoking "KDE_NO_GLOBAL_MENU=1 krita" from the command line, the menu appears in the main window of Krita.

SOFTWARE/OS VERSIONS
Operating System: Arch Linux 
KDE Plasma Version: 6.0.1
KDE Frameworks Version: 6.0.0
Qt Version: 6.6.2
Kernel Version: 6.7.9-arch1-1 (64-bit)
Graphics Platform: Wayland
Comment 2 zxq5 2024-03-12 23:39:25 UTC
can confirm i'm also getting this issue (arch / plasma 6.0.1)
Comment 3 Antonio Rojas 2024-03-13 14:25:44 UTC
*** Bug 483443 has been marked as a duplicate of this bug. ***
Comment 4 Halla Rempt 2024-03-14 09:28:26 UTC
Given that there's nothing that was changed in Krita with regards to menu handling, I doubt we can do anything about it.
Comment 5 Kunshan Wang 2024-03-14 10:09:42 UTC
Created attachment 167159 [details]
Script for reproducing the dbus behavior of Krita

I tried to introspect the session bus of the `krita` process (in my case its name is ":1.130").  But if I do this with QDBusViewer, it freezes for about half a minute, and fails with the following message:

   Error: Call to object / at :1.130: org.freedesktop.DBus.Error.NoReply (Did not receive a reply. Possible causes include: the remote application did not send a reply, the message bus security policy blocked the reply, the reply timeout expired, or the network connection was broken.) failed 

And if I do this with D-Spy, then after about half a minute, it pops up a window showing "DBus connection failed.  Timeout was reached".

I think Krita failed to respond to requests via DBus for some reasons.  But that's strange.  I think the menu is handled by the Qt library internally.  I wrote a simple Python script that uses PySide to create a main window and some menus, and it works fine with the Global Menu widget, and can be introspected using D-Spy.

But I found one way to reproduce this problem.  That is, not executing QApplication.exec, but block in some other way.  I have attached my Python script that can reproduce the same behavior.

I have never hacked Krita before, but I guess similar thing is happening for Krita.  Some code may be overriding its normal event loop, causing some DBus-related events to be ignored.

---

My current environment:
Operating System: Arch Linux 
KDE Plasma Version: 6.0.2
KDE Frameworks Version: 6.0.0
Qt Version: 6.6.2
Kernel Version: 6.7.9-arch1-1 (64-bit)
Graphics Platform: Wayland

Krita version: 5.2.2-7 (Arch Linux)
Comment 6 Halla Rempt 2024-03-14 10:49:09 UTC
I think I've found it...

It's probably 

commit ea5fde3df58e67aa044959f1dd055ac0d9daf9a3
Author: Dmitry Kazakov <dimula73@gmail.com>, Fri Nov 25 12:59:37 2022 +0300 (1 year, 4 months ago)
Committer: Sharaf Zaman <shzam@sdf.org>, Fri Dec 23 10:04:39 2022 +0000 (1 year, 3 months ago)
Branches: <Local>: krita/5.2, master, mr/1323, ..., work/rempt/refactor_toqcolor_fromqcolor, work/rempt/sponsorstab, work/rempt/updated_dependencies and 23 more
          origin: HEAD -> origin/master, bug-464032-potential-rss-feed-crash-fix, kazakov/for-5.2, ..., work/rempt/updated_dependencies, work/update_mr_template, xuche/T15555-pixel-perfect-ellipse-gsoc-2022 and 25 more
Precedes: 5.2.0-beta2
Follows: v5.2.0-prealpha

Disable prober workaround for plasma

This workaround causes Krita to crash on Windows with Qt 5.15.7

The patch basically reverts 8d6a2a5d123c90bfb2a4cabdff78a8fc54584e20
and theoretically may introduce bug 408015.

CCBUG:408015
Comment 7 Bug Janitor Service 2024-03-14 10:59:39 UTC
A possibly relevant merge request was started @ https://invent.kde.org/graphics/krita/-/merge_requests/2098
Comment 8 Halla Rempt 2024-03-14 11:34:58 UTC
Git commit 5dfe4918fa178a5870b2320e4c04bef346d87c08 by Halla Rempt.
Committed on 14/03/2024 at 10:57.
Pushed by dkazakov into branch 'master'.

Re-enable the workaround for plasma global menu

M  +12   -3    libs/ui/opengl/KisOpenGLModeProber.cpp

https://invent.kde.org/graphics/krita/-/commit/5dfe4918fa178a5870b2320e4c04bef346d87c08
Comment 9 Dmitry Kazakov 2024-03-14 11:35:14 UTC
Git commit a6fa8056b442b1b9efc07f7b89f3e3e0bd325aff by Dmitry Kazakov, on behalf of Halla Rempt.
Committed on 14/03/2024 at 11:35.
Pushed by dkazakov into branch 'krita/5.2'.

Re-enable the workaround for plasma global menu


(cherry picked from commit 5dfe4918fa178a5870b2320e4c04bef346d87c08)

M  +12   -3    libs/ui/opengl/KisOpenGLModeProber.cpp

https://invent.kde.org/graphics/krita/-/commit/a6fa8056b442b1b9efc07f7b89f3e3e0bd325aff
Comment 10 Halla Rempt 2024-03-15 07:14:17 UTC
Thank you, Kunshah, for providing the hint that made it possible for me to find the culprit!
Comment 11 Halla Rempt 2024-05-23 10:38:47 UTC
*** Bug 482791 has been marked as a duplicate of this bug. ***
Comment 12 Halla Rempt 2024-05-27 20:05:10 UTC
*** Bug 487643 has been marked as a duplicate of this bug. ***
Comment 13 zxq5 2024-06-16 22:12:59 UTC
Hey I'm still having this issue intermittently. Anyone else experiencing this?

When I open the application it has the global menu, but usually within a few minutes, often when de-focussing the app the global menu disappears and doesn't come back. I'm running an up-to-date arch system with a version of krita in which the bug should have been patched (according to the changelog here https://gitlab.archlinux.org/archlinux/packaging/packages/krita/-/commits/main)

I'll see if I can reproduce the issue now and screenshot it / find some logs.
Comment 14 zxq5 2024-06-16 22:19:25 UTC
Ok, in reference to my previous comment, what seems to cause the global menu to disappear is using the menu to do any kind of effect / adjustment to the image. I'm able to pretty consistently reproduce this, with it disappearing as the dialog is opened, and not appearing after said dialog is closed again.
The global menu will sometimes but not always reappear after focussing another application and then refocussing krita
Comment 15 sansan2111 2024-09-09 22:42:07 UTC
(In reply to zxq5 from comment #14)
> Ok, in reference to my previous comment, what seems to cause the global menu
> to disappear is using the menu to do any kind of effect / adjustment to the
> image. I'm able to pretty consistently reproduce this, with it disappearing
> as the dialog is opened, and not appearing after said dialog is closed again.
> The global menu will sometimes but not always reappear after focussing
> another application and then refocussing krita

I've experienced the same behavior, but i think it's not to related to this particular bug that is discussed here. I've filed a bug report on this if you want to join and confirm this. Link to said bug report: https://bugs.kde.org/show_bug.cgi?id=492925