"My SDL Application" is inhibiting screen lock

An unknown application is currently inhibiting screen lock. It is not Steam. And these applications have persisted even after completely closing Steam. All I would like to know is what exactly is causing this, or what the culprits might be. But even after scavenging the KDE Powerdevil code on GitHub, I can’t seem to find anything that might point me in the right direction. Here’s a terminal output of the powerdevil inhibitors in question.

~
❯ dbus-send --print-reply --dest=org.freedesktop.PowerManagement /org/kde/Solid/PowerManagement/PolicyAgent org.kde.Solid.PowerManagement.PolicyAgent.ListInhibitions
method return time=1724178485.752623 sender=:1.35 -> destination=:1.269 serial=2169 reply_serial=2
   array [
      struct {
         string "My SDL application"
         string "Playing a game"
      }
      struct {
         string "My SDL application"
         string "Playing a game"
      }
   ]

I usually get that when playing certain games from Steam. I’m guessing it happens when people make software in SDL without properly adding some window metadata or something.

1 Like

I did not have any games open for these to take place. Is there no way to narrow down which processes are responsible?

I don’t know of a way to do that. Maybe someone else will chime in.

On Plasma 5 for example I get this in the battery widget:

Screenshot_20240820_184039

Here is my battery widget with Steam closed.

KDE Plasma 6.1.3
KDE Frameworks 6.4.0
Qt 6.7.2
OS Nobara Linux 40
Kernel 6.10.3-201.fsync.fc40.x86_64
Graphics Platform Wayland
dbus-monitor "interface='org.freedesktop.PowerManagement'"

and then when something appears…

dbus-send --print-reply --dest=org.freedesktop.DBus \
  /org/freedesktop/DBus \
  org.freedesktop.DBus.GetConnectionCredentials \
  string:':1.<interesting source>'

The command systemd-inhibit --list should show all processes currently holding a power control inhibition, and it would list the pid and name for the process. From that you can get more information about what that process is through various other tools, such as systemd-cgls.

Monitoring the PowerManagement interface does not give me anything interesting, even after shutting down and re-opening Steam.

~
❯ dbus-monitor "interface='org.freedesktop.PowerManagement'"
signal time=1724275547.547869 sender=org.freedesktop.DBus -> destination=:1.459 serial=4294967295 path=/org/freedesktop/DBus; interface=org.freedesktop.DBus; member=NameAcquired
   string ":1.459"
signal time=1724275547.547885 sender=org.freedesktop.DBus -> destination=:1.459 serial=4294967295 path=/org/freedesktop/DBus; interface=org.freedesktop.DBus; member=NameLost
   string ":1.459"

systemd-inhibit --list also does not provide any applications that could be causing this issue. The only one that is set to block is KDE PowerDevil itself.

~
❯ systemd-inhibit --list
WHO            UID  USER      PID  COMM            WHAT                                                                       WHY                                                        MODE 
ModemManager   0    root      1603 ModemManager    sleep                                                                      ModemManager needs to reset devices                        delay
NetworkManager 0    root      2214 NetworkManager  sleep                                                                      NetworkManager needs to turn off networks                  delay
UPower         0    root      1359 upowerd         sleep                                                                      Pause device polling                                       delay
PowerDevil     1000 jonathing 4049 org_kde_powerde handle-power-key:handle-suspend-key:handle-hibernate-key:handle-lid-switch KDE handles power events                                   block
Screen Locker  1000 jonathing 3460 kwin_wayland    sleep                                                                      Ensuring that the screen gets locked before going to sleep delay

5 inhibitors listed.

So this systemd-inhibit list is what you get while you see the battery monitor reporting on a “my SDL application” blocking sleep?

That is correct.

I did exactly as you stated. I ran the watcher and re-launched a bunch of applications that inhibit the lock, including Steam and VLC. I did not get any feedback from it other than what I posted.

So you found the one that brings up the “My SDL” message.

Cool… What was it?

Wanna put money on it?

I have already described when I made this thread that I have tested everything with Steam closed. Your rude remarks are unhelpful and I’ve already tested your command in a separate window, both with Steam open and closed, and while re-launching steam. It did not send any messages to the terminal after the fact, meaning that “and then when something appears…” does not happen.

1 Like

Ok, using ScreenSaver instead of PowerManagement worked. Thank you.

I’ve made a script that runs on startup which outputs the log of the script to a file:

#!/bin/bash
dbus-monitor "interface='org.freedesktop.ScreenSaver'" > /home/jonathing/Downloads/dbus-monitor.txt

and the result is this:

signal time=1724375969.667768 sender=org.freedesktop.DBus -> destination=:1.47 serial=4294967295 path=/org/freedesktop/DBus; interface=org.freedesktop.DBus; member=NameAcquired
   string ":1.47"
signal time=1724375969.667805 sender=org.freedesktop.DBus -> destination=:1.47 serial=4294967295 path=/org/freedesktop/DBus; interface=org.freedesktop.DBus; member=NameLost
   string ":1.47"
method call time=1724375971.956716 sender=:1.35 -> destination=:1.18 serial=131 path=/ScreenSaver; interface=org.freedesktop.ScreenSaver; member=GetActive
method call time=1724375974.630353 sender=:1.111 -> destination=org.freedesktop.ScreenSaver serial=2 path=/org/freedesktop/ScreenSaver; interface=org.freedesktop.ScreenSaver; member=Inhibit
   string "My SDL application"
   string "Playing a game"
method call time=1724375974.927133 sender=:1.113 -> destination=org.freedesktop.ScreenSaver serial=33 path=/org/freedesktop/ScreenSaver; interface=org.freedesktop.ScreenSaver; member=GetActive
method call time=1724375974.930402 sender=:1.111 -> destination=org.freedesktop.ScreenSaver serial=4 path=/org/freedesktop/ScreenSaver; interface=org.freedesktop.ScreenSaver; member=SimulateUserActivity
method call time=1724375974.991409 sender=:1.111 -> destination=org.freedesktop.ScreenSaver serial=6 path=/org/freedesktop/ScreenSaver; interface=org.freedesktop.ScreenSaver; member=SimulateUserActivity
method call time=1724375975.567451 sender=:1.116 -> destination=org.freedesktop.ScreenSaver serial=2 path=/org/freedesktop/ScreenSaver; interface=org.freedesktop.ScreenSaver; member=Inhibit
   string "My SDL application"
   string "Playing a game"
method call time=1724375975.867580 sender=:1.116 -> destination=org.freedesktop.ScreenSaver serial=4 path=/org/freedesktop/ScreenSaver; interface=org.freedesktop.ScreenSaver; member=SimulateUserActivity
method call time=1724375975.942762 sender=:1.116 -> destination=org.freedesktop.ScreenSaver serial=6 path=/org/freedesktop/ScreenSaver; interface=org.freedesktop.ScreenSaver; member=SimulateUserActivity

Thankfully, this shows the offending call where “My SDL application” is inhibiting the screen saver. The new problem now is that I cannot get information on sender :1.111 or :1.116. Here is a log of my terminal where I attempt to get information on :1.35, :1.111, and :1.116. The first succeed while the next two fail, even though all three of these sender strings are present in the above log.

~
❯ dbus-send --print-reply --dest=org.freedesktop.DBus /org/freedesktop/Dbus org.freedesktop.DBus.GetConnectionCredentials string:":1.35"
method return time=1724376679.579844 sender=org.freedesktop.DBus -> destination=:1.146 serial=4294967295 reply_serial=2
   array [
      dict entry(
         string "UnixUserID"
         variant             uint32 1000
      )
      dict entry(
         string "ProcessID"
         variant             uint32 4061
      )
      dict entry(
         string "UnixGroupIDs"
         variant             array [
               uint32 7
               uint32 10
               uint32 18
               uint32 39
               uint32 63
               uint32 100
               uint32 105
               uint32 973
               uint32 974
               uint32 981
               uint32 1000
               uint32 1001
               uint32 1001
            ]
      )
      dict entry(
         string "ProcessFD"
         variant             file descriptor
                  inode: 4361
                  type:       )
   ]

~
❯ dbus-send --print-reply --dest=org.freedesktop.DBus /org/freedesktop/Dbus org.freedesktop.DBus.GetConnectionCredentials string:":1.116"
Error org.freedesktop.DBus.Error.NameHasNoOwner: The connection does not exist

~
❯ dbus-send --print-reply --dest=org.freedesktop.DBus /org/freedesktop/Dbus org.freedesktop.DBus.GetConnectionCredentials string:":1.111"
Error org.freedesktop.DBus.Error.NameHasNoOwner: The connection does not exist

Are there any other ways I can access these senders?

I’m not contributing more due to my rude and unhelpful remarks.

After doing some digging, I was able to figure out how to monitor processes in a way to debug what processes were sending inhibitor calls to my system. I’ll describe my process below so that anyone who finds themselves here will know how I am attempting to resolve the issue.

Detecting programs inhibiting screen lock

Following the commands and discussion in this thread, I created two scripts which I have told KDE to run on login. The first one below will simply output the results of dbus-monitor to a file in the downloads folder, acting like a log file:

#!/bin/bash
dbus-monitor "interface='org.freedesktop.ScreenSaver'" > /home/jonathing/Downloads/dbus-monitor.txt

The second script takes each line from dbus-monitor and uses some weird regex to extract the sender string so it can be parsed to find the sender information. From the sender information, I then find the command line used to spawn the process ID from the sender information. All lines generated from the script are then outputted to another text file acting like a log:

#!/bin/bash
dbus-monitor "interface='org.freedesktop.ScreenSaver'" | \
while read line ; do
    sender_value=$(echo "$line" | grep -oP 'sender=\K[^ ]+')
    if [ $? = 0 ]
    then
        echo $( cat /proc/$(dbus-send --print-reply --dest=org.freedesktop.DBus /org/freedesktop/DBus org.freedesktop.DBus.GetConnectionUnixProcessID string:"$sender_value" | grep -oP 'uint32 \K\d+')/cmdline | tr '\0' ' ' ) >> /home/jonathing/Downloads/dbus-processes.txt
    fi
done

Here is the resulting “log” file of the second script:

/usr/bin/dbus-broker-launch --scope user
/usr/bin/dbus-broker-launch --scope user
/home/jonathing/.local/share/Steam/ubuntu12_32/../ubuntu12_64/gldriverquery
/usr/bin/xdg-dbus-proxy --args=43
/home/jonathing/.local/share/Steam/ubuntu12_32/../ubuntu12_64/gldriverquery
/home/jonathing/.local/share/Steam/ubuntu12_32/../ubuntu12_64/gldriverquery
/home/jonathing/.local/share/Steam/ubuntu12_32/../ubuntu12_32/gldriverquery
/home/jonathing/.local/share/Steam/ubuntu12_32/../ubuntu12_32/gldriverquery
/home/jonathing/.local/share/Steam/ubuntu12_32/../ubuntu12_32/gldriverquery

Problem

So yes, the problem was Steam. Keep in mind, I did my tests with both Steam opened and closed, but the root cause was Steam starting on startup. It appears that the gldriverquery process that is started by steam makes, what I believe to be, a faulty call to the SDL_DBus_ScreensaverInhibit function within the SDL library. Since gldriverquery does not have a friendly app name or reason, SDL simply supplies the default values of “My SDL application” and “Playing a game”.

The reason why my attempts, earlier in this thread, to run the commands that I ran in the first script failed was because the gldriverquery process was already terminated after the fact. So, there was no longer a connection established to the DBus. The scripts circumvent this because they attempt to gather information on the sender as soon as information is retrieved.

Workarounds

My solution for now will simply be to find a way to prevent Steam from inhibiting the screensaver at all from any of its spawned processes and to report the issue to Steam for Linux’s issue tracker. With regards to the former, I have since found is an Arch package that adds a Desktop entry that attempts to prevent steam from calling that specific function (see steam-screensaver-fix on AUR and patlefort/steam-screensaver-fix on GitLab).

Links

Since I am a new user, I am unable to directly include links in ths post. I’ll try to list the resources I mentioned here:

  • The SDL_DBus_ScreensaverInhibit function GitHub - libsdl-org/SDL/blob/a2d3be904b219e4257fb11a8ecb51f5f9a9e60f7/src/core/linux/SDL_dbus.c#L359-L394
  • steam-screensaver-fix - AUR
  • patlefort/steam-screensaver-fix - GitLab
3 Likes

Hello again. I wanted to add a follow-up to this thread regarding additional info I’ve found regarding this issue.

I’ve opened an issue on Steam for Linux’s GitHub page (ValveSoftware/steam-for-linux#11207) since then and have come to the conclusion that, for some reason, these SDL inhibitor locks are the result of gldriverquery crashing on my system before it can remove those locks.

Workarounds

Launching Steam with the SDL_VIDEO_ALLOW_SCREENSAVER=1 environment variable prevents Steam from placing any SDL-specific locks on the system. It will still place normal locks such as the Steam client lock, but that one does not have the same problem the SDL lock had.

Additionally, I’ve written yet another script that will clear all inhibitor locks on the system in the event that this happens again for whatever reason.

For KDE:

#!/bin/bash

kdialog --warningyesno 'This script will clear all inhibitor locks placed on the system. Are you sure you want to do this?'
if [ $? -eq 0 ]; then
    for i in {1..403} ; do echo -n "$i " ; qdbus org.freedesktop.PowerManagement /org/freedesktop/PowerManagement/Inhibit org.freedesktop.PowerManagement.Inhibit.UnInhibit $i ; done
    kdialog --msgbox 'Inhibitors have been cleaned up.'
fi

DE-agnostic:

#!/bin/bash

for i in {1..403} ; do echo -n "$i " ; qdbus org.freedesktop.PowerManagement /org/freedesktop/PowerManagement/Inhibit org.freedesktop.PowerManagement.Inhibit.UnInhibit $i ; done

If you’re interested in reading more on previous issues people have had with gldriverquery, there’s a lengthy issue thread at ValveSoftware/steam-for-linux#11052.

2 Likes

Hello again, it’s been a while. I updated to KDE Plasma 6.2.2 from 6.1.5, and the power widget now includes an option to unblock screen inhibitions

This is a way better solution than using the script I made above. If you’re on the latest version, I’d recommend doing this instead if you are still having problems beyond the links I’ve already posted.

1 Like