flathub / org.libretro.RetroArch

https://flathub.org/apps/details/org.libretro.RetroArch
Creative Commons Zero v1.0 Universal
18 stars 16 forks source link

Screen sleep isn't suppressed with the suspend screensaver option turned on #58

Open gmdvieira opened 6 years ago

gmdvieira commented 6 years ago

I don't have a screen saver, but my screen turns off after some time of inactivity. When running Retroarch, joypad input doesn't count as activity and the suspend screensaver option does not keep the screen from sleeping. After some research, I believe this option (suspend screensaver) should suppress screen sleep in Linux and that it is Dbus related: https://github.com/libretro/RetroArch/issues/2026 https://github.com/libretro/RetroArch/commit/05df632bd828d7cac1b4c2ca134e94fbdfabc1ab

Maybe the Retroarch flatpak doesn't support the correct Dbus interface?

RobLoach commented 6 years ago

Does this happen on the master branch? Without using Flatpak?

TingPing commented 6 years ago

Just add --talk-name=org.freedesktop.ScreenSaver

gmdvieira commented 6 years ago

I've only tested using Flatpak.

--talk-name=org.freedesktop.ScreenSaver when running doesn't solve the problem.

TingPing commented 6 years ago

Can you post the output of:

flatpak run --talk-name=org.freedesktop.ScreenSaver --log-session-bus org.libretro.RetroArch

(Up to the point where it should be inhibiting)

gmdvieira commented 6 years ago

Weird, there is no output at all on the terminal. Should I look somewhere alse?

RobLoach commented 6 years ago

--verbose will force stdout

TingPing commented 6 years ago

flatpak itself should absolutely be printing output...

gmdvieira commented 6 years ago

$ flatpak run --talk-name=org.freedesktop.ScreenSaver --log-session-bus --verbose org.libretro.RetroArch F: No installations directory in /etc/flatpak/installations.d. Skipping F: Opening user flatpak installation at path /home/gustavo/.local/share/flatpak F: Opening system flatpak installation at path /var/lib/flatpak F: Opening user flatpak installation at path /home/gustavo/.local/share/flatpak F: Opening system flatpak installation at path /var/lib/flatpak F: Allowing host-fs access F: Allowing x11 access F: Allowing wayland access F: Allowing pulseaudio access

I started Retroarch, started some content and did nothing until the screen faded.

This doesn't seem very helpful. Strange, I remember that when I first tried Retroarch flatpak a couple of weeks ago it printed more when started on the command line. I updated recently. Is there a way to downgrade to a previous flatpak release?

RobLoach commented 6 years ago

Is there a way to downgrade to a previous flatpak release?

Would like to fix this issue before we come to that... Does this happen on RetroArch 1.7.3 without Flatpak for you? There's been some updates in the gfx drivers.

gmdvieira commented 6 years ago

Well, I'm relying on Flatpak to get RetroArch effortlessly. :)

But, I can recognize when it's time to help nice people trying to help you. I'll try to make a local build this weekend and report my findings.

By the way, I've experienced a framerate reduction such that I can't really make any core run smoothly. This was running smoothly (after setting the framerate) in 1.7.2. I will test the local build and file an issue if it appears to be Flatpak related.

RobLoach commented 6 years ago

Wouldn't be one of these, right? https://github.com/flathub/org.libretro.RetroArch/pull/54/files

TingPing commented 6 years ago

--socket=system-bus very well could be relevant. but their flatpak apparently is broken and doesn't print logs, so we can't track it down...

TingPing commented 6 years ago

(Actually I can confirm retroarch breaks flatpak logging here too.. must be doing something naughty to stdout/stderr)

gmdvieira commented 6 years ago

Ok, I managed to compile 1.7.3 (and master, and 1.7.2) and the problem isn't related to Flatpak. The culprit appears to be Wayland support. Also the framerate problem seems to be Wayland related. If I compile without Wayland support both problems disappear. I will create bug reports directly to RetroArch.

gmdvieira commented 6 years ago

Well, this issue is more subtle than it appears. We have actually two different bugs that confused me.

The first is that (apparently) Suspend screensaver doesn't work under Wayland. This isn't Flatpak related and I've reported it here: https://github.com/libretro/RetroArch/issues/6830

However, when I've tried to run the Flatpak RetroArch under X the Suspend screensaver did not work, while it worked in a version I compiled and run under X. Luckily I managed to get logs working (the -v should be last!) and look what I've found!

[INFO] [Font]: Using font rendering backend: bitmap.
[INFO] [X11]: Suspending screensaver (X11, xdg-screensaver).
[INFO] [autoconf]: selected configuration: /home/jogos/.var/app/org.libretro.RetroArch/config/retroarch/autoconfig/sdl2/X360 Wireless Controller.cfg
sh: xdg-screensaver: command not found
[WARN] Could not suspend screen saver.
[INFO] [Video]: Found display server: x11

The problem, at least under X, seems to be Flatpak related after all. There is a binary missing. Reopening the bug.

gmdvieira commented 6 years ago

The plot thickens! I discovered something interesting peeking at the code: xdg-screensaver is a fallback, the primary way to inhibit the screensaver is Dbus. The default RetroArch build options have Dbus support disabled, and so did my own builds. If I enable Dbus support and recompile I get (under X):

[INFO] [Font]: Using font rendering backend: bitmap.
[INFO] [DBus]: Suspended screensaver via DBus.
[INFO] [Video]: Found display server: x11

It works perfectly. I'm not sure, but it appears that the Flatpak builds use the default configuration, then Dbus is disabled. Maybe it is better for the Flatpak build to enable Dbus instead of trying to add xdg-screensaver.

gmdvieira commented 6 years ago

Bug https://github.com/libretro/RetroArch/issues/6830 has been closed. Wayland support for suppressing the screensaver is Dbus only. So, I suppose the Flatpak build should support Dbus and handle both X11 and Wayland.

dmatavel commented 9 months ago

It's happening to me with RetroArch 1.16.0 Flatpak on Ubuntu 22.04.

Screenshot from 2024-01-07 16-01-44

dbnicholson commented 9 months ago

I'm pretty sure this is https://github.com/libretro/RetroArch/pull/15856, which isn't in released yet. What happens is that on wayland there are 2 ways to inhibit the screensaver:

  1. The preferred way is the Wayland zwp_idle_inhibit_manager_v1 protocol. The compositor uses the DBus org.freedesktop.ScreenSaver interface to inhibit the screensaver, but this is better since the compositor knows if the app is active.
  2. Since that's an unstable Wayland protocol, not all compositors support it. For example, GNOME's compositor mutter just recently merged support, so it won't be available until GNOME 45. That's likely why Ubuntu 22.04 is affected. As a fallback, RetroArch now uses the DBus method directly whenever it's started. This is worse since retroarch doesn't know if it's active or not so it inhibits all the time, but it's better than nothing. Unfortunately, the Wayland backend doesn't have that fix in 1.16.0.3, which the flatpak is currently using.

You can run retroarch with --verbose (like flatpak run org.libretro.RetroArch --verbose) and (if you have the screensaver inhibiting configured on), you'll see the following message:

[INFO] [DBus]: Suspended screensaver via DBus.

I can prep a PR to backport https://github.com/libretro/RetroArch/commit/e7a10b2326427383f66e0dd9fdf822b8197c81b6 until there's another release.

dbnicholson commented 9 months ago

BTW, if the compositor doesn't support the Wayland protocol like mutter before GNOME 45, you'll see this in the verbose messages:

[INFO] [Wayland]: Compositor doesn't support zwp_idle_inhibit_manager_v1 protocol
RobLoach commented 9 months ago

Thanks for the investigation. Had pushed a config to disable this until it's fixed, which we can revert once it's up. As for the PR that's not released yet, RetroArch 1.17 is coming out within the next couple weeks, so hopefully the release with the DBUS fix solves this :+1: #274

dbnicholson commented 9 months ago

Just to add one more comment. xdg-screensaver is in use as the fallback from DBus org.freedesktop.ScreenSaver on X11. It comes from xdg-utils, which is a suite of scripts providing pretty good compatibility across desktop environments. Unfortunately, the suspend action relies on accessing X11 and DBus via perl.

So, while it would be pretty easy to bundle the scripts, it would require also bundling a few perl libraries to actually work correctly. IMO, post-1.17 it would be best to just assume that the environment supports the org.freedesktop.ScreenSaver interface and ignore the xdg-screensaver fallback as unsupported or maybe a wishlist task. Otherwise, I'd probably push to get xdg-utils included in the FDO runtime.

To sum up, the post-1.17 suppress screensaver support would be: