Bug 452334 - Compositor freezes when locking the screen
Summary: Compositor freezes when locking the screen
Status: RESOLVED FIXED
Alias: None
Product: kwin
Classification: Plasma
Component: wayland-generic (show other bugs)
Version: master
Platform: Compiled Sources Linux
: NOR normal
Target Milestone: ---
Assignee: KWin default assignee
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2022-04-06 15:19 UTC by oiiu19
Modified: 2023-03-27 16:46 UTC (History)
2 users (show)

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description oiiu19 2022-04-06 15:19:20 UTC
SUMMARY
The compositor very occasionally (git master) or always (5.24 branch) freezes when locking the screen. Per git bisect, the offending commit is https://invent.kde.org/plasma/kwin/-/commit/c16a8e09d7e80b2130a0ba041b62b956b8c8ceb3.

If kscreenlocker emits aboutToLock and fails later, LockScreenPresentationWatcher still calls lockScreenShown, making the compositor believe the screen is locked. A similar possibility is when the first check in LockScreenPresentationWatcher never succeeds (due to screen configuration issues or because the greeter shows up before LockScreenPresentationWatcher runs, which are rare but possible) and the user unlocks within the 1000ms timeout. The case of 5.24 branch seems to be a simple mistake, where LockScreenPresentationWatcher is put in the 'unlocked' callback instead of the 'aboutToLock' one. (https://invent.kde.org/plasma/kwin/-/blob/9d38f57d84fb9a6f2c4e60f7051f685842f34e0f/src/wayland_server.cpp#L622)

STEPS TO REPRODUCE
1. Lock screen.

OBSERVED RESULT
The screen becomes black.

EXPECTED RESULT
The compositor should work when unlocked or locking fails.

SOFTWARE/OS VERSIONS
Linux/KDE Plasma: Debian testing
KDE Plasma Version: git master / git 5.24.4
KDE Frameworks Version: 5.93.0
Qt Version: 5.15.3
Comment 1 oiiu19 2022-04-06 17:41:06 UTC
Bug 451290 may be a manifestation of this race condition, just much harder to trigger. As long as dbus messages are handled in a different thread than the wayland server thread, there is a chance logind unlock callback gets scheduled earlier than lockScreenShown. The 1000ms timeout introduced in this commit makes the race condition much more likely to happen.
Comment 2 Zamundaaa 2022-04-06 22:11:08 UTC
Git commit 388402c3b1b37d9f72597aae8d6670e8c0edeb14 by Xaver Hugl.
Committed on 06/04/2022 at 19:08.
Pushed by zamundaaa into branch 'Plasma/5.24'.

waylandserver: move LockScreenPresentationWatcher to the correct place

M  +2    -2    src/wayland_server.cpp

https://invent.kde.org/plasma/kwin/commit/388402c3b1b37d9f72597aae8d6670e8c0edeb14
Comment 3 Bug Janitor Service 2022-05-17 11:51:01 UTC
A possibly relevant merge request was started @ https://invent.kde.org/plasma/kwin/-/merge_requests/2210
Comment 4 Zamundaaa 2023-03-27 16:46:17 UTC
This should no longer be happening. If it's still an issue in Plasma 5.27, please reopen the bug report