FeralInteractive / gamemode

Optimise Linux system performance on demand
BSD 3-Clause "New" or "Revised" License
4.69k stars 185 forks source link

gamemoderun dose not release lock when killed #426

Open axet opened 1 year ago

axet commented 1 year ago

Describe the bug

gamemoderun does not release lock when process got killed.

To Reproduce

list gnome inhibitors - lock is not present.

gamemoderun sleep 1d &
ps aux|grep sleep
kill 8888

list gnome inhibitors - lock still present.

Expected behavior

I hope killing or crashing process will clear gnome inhibitors.

System Info (please complete the following information):

HenrikHolst commented 1 year ago

Not entirely sure what happens there on your system, with "list gnome inhibitors" I assume that you mean "systemd-inhibit --list" ?

With "gamemoderun sleep 1d &" I got no added entry from "systemd-inhibit --list". I also somewhat fail to understand what gamemode would cause here since AFAIK it does not add any locks to gnome.

But perhaps we could start with what the output is from the list of gnome inhibitors is on your system with sleep running?

axet commented 1 year ago

gnome inhibitors != systemd inhibitors. So here we are:

dbus-send --print-reply --dest=org.gnome.SessionManager /org/gnome/SessionManager org.gnome.SessionManager.GetInhibitors
HenrikHolst commented 1 year ago

ah ok, well there we go I knew it was something I had no clue on :), well at least it is a start for some one to perform debugging

HenrikHolst commented 1 year ago

interesting, one does not need to kill the process, a pure "gamemoderun sleep 1" suffices, after one second and sleep terminates on its own dbus is still showing an inhibitor. Stopping gamemoded does not solve it either.

What is also fascinating is that gamemode-simulate-game created such an inhibitor when running but once terminated it was gone so the initial suspicion is that this is caused by gamemoderun and not gamemoded.

edit: no scratch all that, I was looking at the wrong output here.

axet commented 1 year ago

Basically gnome inhibitor == screen lock / screen saver inhibitor.

Workaround would be disabling (inhibit_screensaver=0) in cofing file.

I hope crashing / killing PID would not affect resuming normal screen saver behavior without a workaround.

axet commented 1 year ago

For better gnome inhibit managment you can use this script:

caffeine --list

HenrikHolst commented 1 year ago

Have you tried running on the latest version from github? Aka compiling from main? Now once I did look at the correct place I could see the inhibitor disappear after one second I had killed the sleep 1d process.

axet commented 1 year ago

I'm using 1.7 version from debian repo, it is save as from github. How exactly do you kill the process? For example, 'killall sleep' will not work (inhibitors will be released). But when I kill it by PID it stops working. Please make sure you are killing the correct process by PID.

It is not just 'sleep' not working. I'm having a few games which I had to kill they are causing inhibitors to keep a live.

HenrikHolst commented 1 year ago

I did kill by pid.

method return time=1687716719.985134 sender=:1.31 -> destination=:1.183 serial=402 reply_serial=2
   array [
   ]`

henrik@Sineya:~$ gamemoderun sleep 1d &
[1] 14761

henrik@Sineya:~$ dbus-send --print-reply --dest=org.gnome.SessionManager /org/gnome/SessionManager org.gnome.SessionManager.GetInhibitors

method return time=1687716770.372350 sender=:1.31 -> destination=:1.186 serial=409 reply_serial=2
   array [
      object path "/org/gnome/SessionManager/Inhibitor6"
   ]

henrik@Sineya:~$ kill 14761

henrik@Sineya:~$ dbus-send --print-reply --dest=org.gnome.SessionManager /org/gnome/SessionManager org.gnome.SessionManager.GetInhibitors
method return time=1687716837.761010 sender=:1.31 -> destination=:1.187 serial=410 reply_serial=2
   array [
      object path "/org/gnome/SessionManager/Inhibitor6"
   ]

henrik@Sineya:~$ dbus-send --print-reply --dest=org.gnome.SessionManager /org/gnome/SessionManager org.gnome.SessionManager.GetInhibitors
method return time=1687716847.424518 sender=:1.31 -> destination=:1.189 serial=416 reply_serial=2
   array [
   ]

So it took one second or a bit more for gamemoded to shut down so when I fetched the list directly after killing the sleep process the inhibitor was still there but pausing for one second and the refetching the list and it was gone. Now I am ofc running a self compiled version from master (and from my fork) and not the 1.7 release so it's possible that there are some commit since the latest release that fixes this. I'll see if I can get hold of a debian to try with, which version of debian are you running?

edit: omg how horrible the code block comment is on github, it doesn't respect newlines...

axet commented 1 year ago

Debian Bookworm (recent release, Debian 12)


class JavaComments {
  public: String testCommentSegment = "ok";
}
HenrikHolst commented 1 year ago

Debian Bookworm (recent release, Debian 12)

class JavaComments {
  public: String testCommentSegment = "ok";
}

ok I'll try to download and run debian in a vm sometime later. ok so the trick is to have three ticks at the start to have github include newlines?!

HenrikHolst commented 1 year ago

Well it is not due to the version, I just tried it with Debian 12 in VirtualBox, isntalled gamemode and gamemode-deamon, run "gamemoderun sleep 1d &", listed that inhibitors to see that gamemode inhibited the screen saver, killed the sleep pid and the inhibiter dissapeared.

So there is something special with your system/setup that is causing this, next step would be to determine what that is. Since you also have those other automode log problems I think they are connected (I also checked the journal on the Debian VM and no such logs there from the sleep session) in that gamemoded for some reason fails to remove the inhibition of the screen saver.

axet commented 1 year ago

My provided "steps to reproduce" are not correct. Sometimes lock got released. Sometimes screen never went off. I had to test it.