Bug 428817 - org.kde.KWin is not unregistered properly on logout
Summary: org.kde.KWin is not unregistered properly on logout
Status: RESOLVED FIXED
Alias: None
Product: kwin
Classification: Plasma
Component: platform-x11-standalone (show other bugs)
Version: unspecified
Platform: Fedora RPMs Linux
: NOR normal
Target Milestone: ---
Assignee: KWin default assignee
URL:
Keywords:
: 432793 (view as bug list)
Depends on:
Blocks:
 
Reported: 2020-11-08 03:59 UTC by ivz hh
Modified: 2021-02-11 17:11 UTC (History)
3 users (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description ivz hh 2020-11-08 03:59:48 UTC
SUMMARY


STEPS TO REPRODUCE
1. Use Xrdp to connect to Fedora 33, starting KDE
2. use `busctl --user monitor org.kde.KWin`
3. in plasma-workspace-5.19.5/startkde/startplasma.cpp, in function startPlasmaSession(), add one line `serviceWatcher.addWatchedService(QStringLiteral("org.kde.KWin"));` to make startplasma won't quit till org.kde.KWin is unregistered.
4. click "log out" in KDE
5. busctl process ends, last message is org.freedesktop.DBus.Local.Disconnected

OBSERVED RESULT

startkde (actually startplasma_x11) doesn't exit at all, as org.kde.KWin is *never* unregistered. `busctl --usr list` won't find any org.kde.KWin service.

EXPECTED RESULT

Unregistration of org.kde.KWin is properly called and startkde properly exits.


SOFTWARE/OS VERSIONS
Linux/KDE Plasma: Fedora 33/plasma-workspace-5.19.5
(available in About System)
KDE Plasma Version: plasma-workspace-5.19.5
KDE Frameworks Version: 5.75.0-1.fc33
Qt Version: 5.15.1-5.fc3

ADDITIONAL INFORMATION

I am debugging it for the past week. I still cannot figure out org.freedesktop.DBus.Local.Disconnected is signalled before unregistration. I can keep digging into this issue, but I need some help to understand this part.

Thank you!
Comment 1 ivz hh 2020-11-08 04:02:10 UTC
```diff
diff -ruN  plasma-workspace-5.19.5-vanilla/startkde/startplasma.cpp plasma-workspace-5.19.5/startkde/startplasma.cpp
--- plasma-workspace-5.19.5-vanilla/startkde/startplasma.cpp	2020-11-04 19:22:27.959634893 -0700
+++ plasma-workspace-5.19.5/startkde/startplasma.cpp	2020-11-06 15:05:53.189956319 -0700
@@ -406,6 +406,7 @@
     // This also closes if ksmserver crashes unexpectedly, as in those cases plasma-shutdown is not running
     serviceWatcher.addWatchedService(QStringLiteral("org.kde.ksmserver"));
     serviceWatcher.addWatchedService(QStringLiteral("org.kde.Shutdown"));
+    serviceWatcher.addWatchedService(QStringLiteral("org.kde.KWin"));
     serviceWatcher.setWatchMode(QDBusServiceWatcher::WatchForUnregistration);
 
     QObject::connect(&startPlasmaSession, QOverload<int, QProcess::ExitStatus>::of(&QProcess::finished), [&rc, &e](int exitCode, QProcess::ExitStatus) {
```
Comment 2 Bug Janitor Service 2020-11-13 13:26:00 UTC
A possibly relevant merge request was started @ https://invent.kde.org/plasma/plasma-workspace/-/merge_requests/454
Comment 3 Bug Janitor Service 2020-11-13 13:26:15 UTC
A possibly relevant merge request was started @ https://invent.kde.org/plasma/kwin/-/merge_requests/448
Comment 4 David Edmundson 2020-11-13 14:10:38 UTC
That patch in #1 makes sense, but we would still need to trigger kwin to close somehow.

I made a version above. It means patching kwin and workspace, but effectively it's the same idea as yours just a bit more explicit.
Comment 5 David Edmundson 2020-11-22 22:05:39 UTC
Git commit 71ce1f7a5b6c770e2ef7e3b1a0f2b76853c4124a by David Edmundson.
Committed on 22/11/2020 at 22:04.
Pushed by davidedmundson into branch 'master'.

Add an explicit quit mechanism controlled by plasma

On X Kwin's lifespan used to be managed by XSMP. This accidentally broke
in 5.20 as we made kwin start before ksmserver for speed purposes.

This leaves kwin to be killed by the display manager as the X connection
closes, but this can lead to deadlocks.
Related: bug 427688

On wayland kwin's lifespan is mapped to the lifespan of the ksmserver
binary. This is problematic as it makes our entire xwayland robustness
redundant if we ultimately rely on an application that /has/ to run in
xwayland.

M  +3    -0    org.kde.KWin.Session.xml
M  +5    -0    sm.cpp
M  +1    -0    sm.h

https://invent.kde.org/plasma/kwin/commit/71ce1f7a5b6c770e2ef7e3b1a0f2b76853c4124a
Comment 6 David Edmundson 2020-11-24 18:58:40 UTC
Git commit aea488be1e0d407c7c98a6166c1cbd37cd25f6f0 by David Edmundson.
Committed on 24/11/2020 at 18:58.
Pushed by davidedmundson into branch 'master'.

Add an explicit method to close kwin

On X Kwin's lifespan used to be managed by XSMP. This accidentally broke
in 5.20 as we made kwin start before ksmserver for speed purposes and
wayland preparation.

This leaves kwin to be killed by the display manager as the X connection
closes, but this can lead to deadlocks.

On wayland kwin's lifespan is mapped to the lifespan of the ksmserver
binary. This is problematic as it makes our entire xwayland robustness
redundant if we ultimately rely on an application that /has/ to run in
xwayland.

M  +3    -0    ksmserver/org.kde.KWin.Session.xml
M  +1    -0    startkde/plasma-shutdown/CMakeLists.txt
M  +7    -0    startkde/plasma-shutdown/shutdown.cpp

https://invent.kde.org/plasma/plasma-workspace/commit/aea488be1e0d407c7c98a6166c1cbd37cd25f6f0
Comment 7 Nate Graham 2021-02-11 17:11:57 UTC
*** Bug 432793 has been marked as a duplicate of this bug. ***