Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use Linux OS suspend inhibitors to avoid standby #4049

Closed

Conversation

ghubstan
Copy link
Contributor

On linux hosts, AvoidStandbyService checks for executables
gnome-session-inhibit and systemd-inhibit in that order, then starts
the first found to prevent suspend or sleep while Bisq is running.

Although the hide avoid standby mode button is not displayed on linux,
the inhibitors can be toggled off/on when and if that button is
displayed. An installed shutdown hook will turn the inhibitor off,
but they should always die when the parent process dies.

To check when an inhibitor is enabled or disabled from a linux terminal:

If the desktop is gnome...

$ dbus-send --session --print-reply --dest=org.gnome.SessionManager \
	/org/gnome/SessionManager org.gnome.SessionManager.GetInhibitors

If Bisq falls back to systemd-inhibit on a non gnome desktop...

$ systemd-inhibit --list
$ systemd-inhibit --list | grep Bisq

If neither gnome-session-inhibit nor systemd-inhibit are present, the
standby service falls back to playing the silent audio file.

This does not cover all linux desktop types, but other inhibitors
exist for desktops I have not set up, such as mate, and it will not
be difficult to make changes to support them.

Memory use reduction varies from machine to (virtual) machine, but on my
Ubuntu 18 laptop, playing the audio file to block suspension is allocating
about 1 GB of native memory per hour -- via malloc() -- which this PR elminates.
On the same machine, virtual memory use goes from 10.4 GB to 10.1 GB.

This has been tested on Ubuntu 18 (gnome) and the following VMs:

Debian 10.3 (gnome)
Arch Linux 9.2.1 (gnome)
Fedora 31.1.9 (cinnamon)

But, VMs not running an inhibitor or audio file did not always go into suspend mode
as expected.

This does not work on Windows Cygwin, but minor changes might make it work if
cygwin inhibitor tools like gnome-session-inhibit.exe and mate-session-inhibit.exe
are installed.

Addresses native / virtual memory allocation issues.

Fixes #replaceWithIssueNr, fixes #replaceWithIssueNr

Your PR description here.

On linux hosts, AvoidStandbyService checks for executables
gnome-session-inhibit and systemd-inhibit in that order, then starts
the first found to prevent suspend or sleep while Bisq is running.

Although the hide avoid standby mode button is not displayed on linux,
the inhibitors can be toggled off/on when and if that button is
displayed.  An installed shutdown hook will turn the inhibitor off,
but they should always die when the parent process dies.

To check when an inhibitor is enabled or disabled from a linux terminal:

	If the desktop is gnome...

	$ dbus-send --session --print-reply --dest=org.gnome.SessionManager \
		/org/gnome/SessionManager org.gnome.SessionManager.GetInhibitors

	If Bisq falls back to systemd-inhibit on a non gnome desktop...

	$ systemd-inhibit --list
	$ systemd-inhibit --list | grep Bisq

If neither gnome-session-inhibit nor systemd-inhibit are present, the
standby service falls back to playing the silent audio file.

This does not cover all linux desktop types, but other inhibitors
exist for desktops I have not set up, such as mate, and it will not
be difficult to make changes to support them.

Memory use reduction varies from machine to (virtual) machine, but on my
Ubuntu 18 laptop, playing the audio file to block suspension is allocating
about 1 GB of native memory per hour -- via malloc() -- which this PR elminates.
On the same machine, virtual memory use goes from 10.4 GB to 10.1 GB.

This has been tested on Ubuntu 18 (gnome) and the following VMs:

	Debian 10.3 (gnome)
	Arch Linux 9.2.1 (gnome)
	Fedora 31.1.9 (cinnamon)

But, VMs not running an inhibitor or audio file did not always go into suspend mode
as expected.

This does not work on Windows Cygwin, but minor changes might make it work if
cygwin inhibitor tools like gnome-session-inhibit.exe and mate-session-inhibit.exe
are installed.

Addresses native / virtual memory allocation issues.
@ghubstan
Copy link
Contributor Author

Closing this PR and will create another with OSX standby mode disabler functionality merged into AvoidStandbyService.

Right now, in master, it seems both caffeinate and audio player are running on OSX. I will verify by testing on OSX.

@ghubstan ghubstan closed this Mar 12, 2020
@ghubstan ghubstan deleted the linux-avoid-standby-mode branch March 13, 2020 18:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant