Bug 469687 - Screen does not shut off when sleep inhibitor lock is created and released
Summary: Screen does not shut off when sleep inhibitor lock is created and released
Status: RESOLVED FIXED
Alias: None
Product: plasmashell
Classification: Plasma
Component: Screen locking (show other bugs)
Version: 6.2.4
Platform: Gentoo Packages Linux
: NOR normal
Target Milestone: 1.0
Assignee: Plasma Bugs List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2023-05-13 04:35 UTC by Eric G
Modified: 2025-02-13 00:34 UTC (History)
3 users (show)

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


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Eric G 2023-05-13 04:35:05 UTC
If a sleep inhibitor lock is repeatedly created and released during the duration of the "Screen Energy Saving" switch off period, the screen will never switch off on inactivity.  I believe this is unintended behavior based on the similar Bug 464119;  screen switch off and sleep should not be correlated.

***

STEPS TO REPRODUCE
1. Set the "Screen Energy Saving" to switch off after 1 minute in Power Devil
2. Run the below script as root:
```
#!/bin/bash

if (( $EUID != 0 )); then
  echo "Must run as root"
  exit 1
fi

trap exit 1 SIGINT

while true; do
  systemd-inhibit --what="sleep" --who="test" --why="test" --mode="block" sleep 5
done
```

OBSERVED RESULT
Screen will not switch off after 1 minute of inactivity.


EXPECTED RESULT
Screen should switch off after 1 minute of inactivity.


SOFTWARE/OS VERSIONS
Linux/KDE Plasma:  Gentoo (up to date stable branch 5-10-2023)
KDE Plasma Version: 5.27.4 
KDE Frameworks Version: 5.104.0
Qt Version: 5.15.9

ADDITIONAL INFORMATION
Similar behavior was observed on Debian 12, in this case the screen shut off momentarily and seconds later switched back on without any human interaction. 

Linux Version: Debian 12
KDE Plasma Version: 5.27.2
KDE Frameworks Version: 5.103.0
Qt Version: 5.15.8
Comment 1 Pedro V 2023-11-18 09:26:37 UTC
Can't reproduce on:
Operating System: Kubuntu 23.10
KDE Plasma Version: 5.27.8
KDE Frameworks Version: 5.110.0
Qt Version: 5.15.10
Kernel Version: 6.5.0-10-generic (64-bit)
Graphics Platform: Wayland

My screen turned off just a bit more than a minute later which seemed to be in the expected 60-65 seconds range with the reproducer steps, and `systemd-inhibit --list` confirms the inhibitor's existence even after waking up screen.
Comment 2 Eric G 2023-11-18 20:50:06 UTC
I'm now unable to reproduce on:
Operating System: Gentoo Linux 2.14
KDE Plasma Version: 5.27.8
KDE Frameworks Version: 5.110.0
Qt Version: 5.15.11
Kernel Version: 6.1.53-gentoo-r1 (64 bit)
Graphics Platform: Wayland

I recommend closing.  I'm not sure if something was up streamed which would affect behavior here. So I will leave it to someone with more experience with this project to tag resolution.  Thank you.
Comment 3 Bug Janitor Service 2025-01-31 09:10:57 UTC
A possibly relevant merge request was started @ https://invent.kde.org/plasma/kscreenlocker/-/merge_requests/263
Comment 4 David Redondo 2025-02-06 08:23:04 UTC
Git commit 6e1bff77a76ec89be797749a1408b1cd5451c5ec by David Redondo.
Committed on 05/02/2025 at 16:21.
Pushed by davidre into branch 'master'.

Remove and add idle timeout when inhibited and unhibited

Ensures that when a dbus inhibition is lifted the idle time
starts anew. Otherwise a new idle timeout would not start
until user activity and we would never lock.
The stored type of the the timeout is changed to double to
make testing with shorter timeouts possible.

M  +1    -0    autotests/CMakeLists.txt
M  +94   -0    autotests/ksldtest.cpp
M  +27   -12   ksldapp.cpp
M  +3    -6    ksldapp.h
M  +4    -1    powermanagement_inhibition.cpp
M  +2    -0    powermanagement_inhibition.h
M  +1    -1    settings/kscreenlockersettings.kcfg

https://invent.kde.org/plasma/kscreenlocker/-/commit/6e1bff77a76ec89be797749a1408b1cd5451c5ec
Comment 5 David Redondo 2025-02-06 08:37:25 UTC
Git commit 763721d8a22a4e564dc0ef43d58257b1d57f11a7 by David Redondo.
Committed on 06/02/2025 at 08:33.
Pushed by davidre into branch 'Plasma/6.3'.

Remove and add idle timeout when inhibited and unhibited

Ensures that when a dbus inhibition is lifted the idle time
starts anew. Otherwise a new idle timeout would not start
until user activity and we would never lock.
The stored type of the the timeout is changed to double to
make testing with shorter timeouts possible.


(cherry picked from commit 6e1bff77a76ec89be797749a1408b1cd5451c5ec)

Co-authored-by: David Redondo <kde@david-redondo.de>

M  +1    -0    autotests/CMakeLists.txt
M  +94   -0    autotests/ksldtest.cpp
M  +27   -12   ksldapp.cpp
M  +3    -6    ksldapp.h
M  +4    -1    powermanagement_inhibition.cpp
M  +2    -0    powermanagement_inhibition.h
M  +1    -1    settings/kscreenlockersettings.kcfg

https://invent.kde.org/plasma/kscreenlocker/-/commit/763721d8a22a4e564dc0ef43d58257b1d57f11a7
Comment 6 Ketan 2025-02-13 00:34:29 UTC
can you please confirm that the commit to fix this hasn't resulted in this bug here: https://bugs.kde.org/show_bug.cgi?id=499637