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

MPV not preventing blank screen while watching a video #5459

Closed
zakora opened this issue Jan 29, 2018 · 35 comments
Closed

MPV not preventing blank screen while watching a video #5459

zakora opened this issue Jan 29, 2018 · 35 comments

Comments

@zakora
Copy link

zakora commented Jan 29, 2018

mpv version and platform

> mpv --version
mpv 0.28.0 (C) 2000-2017 mpv/MPlayer/mplayer2 projects
 built on UNKNOWN
ffmpeg library versions:
   libavutil       56.7.100
   libavcodec      58.9.100
   libavformat     58.3.100
   libswscale      5.0.101
   libavfilter     7.11.101
   libswresample   3.0.101
ffmpeg version: git-2018-01-15-93028f4

OS: Fedora 27
Gnome 3.26.2 on Wayland

Reproduction steps

  1. In Gnome, configure blank screen to 1 min.
  2. mpv --no-config TalkativeCat2012.mp4 or mpv --fullscreen --no-config TalkativeCat2012.mp4

Expected behavior

Video playing without getting a blank screen after 1 min.

Actual behavior

After 1 min, the blank screen appears.

Log file

https://gist.github.com/zakora/4474d0e31996a9befda59336d8774750#file-mpv-log

Sample files

https://ia800609.us.archive.org/26/items/TheTalkativeCat/TalkativeCat2012.mp4

@zakora
Copy link
Author

zakora commented Jan 29, 2018

After some testing I found that if I run mpv under a "Gnome on X.org" session then the blank screen doesn't appear during video playback, which solves the problem.

I also tested the --stop-screensaver option under a Wayland session but it doesn't work.

@zakora
Copy link
Author

zakora commented Jan 29, 2018

Maybe a duplicate of #5015 .

Also, running mpv with gnome-session-inhibit solves the problem, although I find it a bit hacky and would prefer that mpv does inhibit idle by itself:

gnome-session-inhibit mpv TalkativeCat2012.mp4

@orbea
Copy link
Contributor

orbea commented Jan 29, 2018

If I understand correctly mpv uses xdg-screensaverand if gnome 3 does not respect that the possible reasons are: A gnome bug, missing dependencies (I have seen missing xprop result with similar issues in other programs) and/or a misconfiguration. Is it possible to bring this up with gnome devs and so that it can be ensured that gnome3 is properly respecting xdg-screensaver?

@glaubersm
Copy link

is your mpv running under wayland or xwayland?
https://bugzilla.gnome.org/show_bug.cgi?id=709500

@zakora
Copy link
Author

zakora commented Feb 4, 2018

@orbea Sure, I'll try to find a way to check that Gnome 3 respects xdg-screensaver. All I can tell for now is that running xdg-screensaver lock in my normal session (Gnome 3 on Wayland) actually locks the screen.

@glaubersm my mpv is running under Wayland. I will follow the Gnome bug thread you mentioned. It is not exactly the same issue that I have though, since the screen blanking during playback is only happening with mpv (Firefox and VLC are fine).

@zakora
Copy link
Author

zakora commented Feb 5, 2018

After some testing I can say that Gnome 3 seems to respect xdg-screensaver. Running xdg-screensaver suspend WINDOW_ID (with WINDOW_ID being the mpv window ID given by xwininfo) actually works: the screen blanking is inhibited during video playback for mpv.

Note for Fedora users: xdg-utils, which provides xdg-screensaver, appears to be missing some dependencies and the previous suspend command might not work out of the box. In this case you need to install perl-Net-DBus and perl-X11-Protocol, see https://bugzilla.redhat.com/show_bug.cgi?id=1541980.

Digging deeper into mpv, I found that it doesn't use the wayland code though my Gnome session runs on Wayland.
In fact, looking at the verbose mpv logs when playing a video shows two lines related to screensaver

[ 0.114][v][vo/gpu/x11] Disabling screensaver.

and

[ 2.616][v][vo/gpu/x11] Enabling screensaver.

See https://gist.github.com/zakora/8f004063d2d32b39bdcd706fdc4481fe#file-mpv-log-L747 (lines 747 and 762).

I would have expected to see the logging strings Enabling idle inhibitor and Disabling the idle inhibitor, from the wayland_common.c file.
Instead it prints the Disabling screensaver and Enabling screensaver logging strings from x11_common.c.

The git history shows that there was a lot of work done on Wayland recently by @atomnuker . Maybe he could give us some insights?

@CounterPillow
Copy link
Contributor

Can you try with --gpu-backend=wayland?

@zakora
Copy link
Author

zakora commented Feb 5, 2018

This option is not available in mpv 0.28.0:

> mpv --gpu-backend=wayland --no-config -v TalkativeCat2012.mp4 
[cplayer] Command line options: '--gpu-backend=wayland' '--no-config' '-v' 'TalkativeCat2012.mp4'
[cplayer] mpv 0.28.0 (C) 2000-2017 mpv/MPlayer/mplayer2 projects
[cplayer]  built on UNKNOWN
[cplayer] ffmpeg library versions:
[cplayer]    libavutil       56.7.100
[cplayer]    libavcodec      58.9.100
[cplayer]    libavformat     58.3.100
[cplayer]    libswscale      5.0.101
[cplayer]    libavfilter     7.11.101
[cplayer]    libswresample   3.0.101
[cplayer] ffmpeg version: git-2018-01-15-93028f4
[cplayer] 
[cplayer] Configuration: ./waf configure --prefix=/usr --bindir=/usr/bin --libdir=/usr/lib64 --mandir=/usr/share/man --docdir=/usr/share/doc/mpv --confdir=/etc/mpv --disable-build-date --enable-libmpv-shared --enable-sdl2 --enable-dvdread --enable-dvdnav --enable-cdda --enable-dvb --enable-libarchive --enable-zsh-comp --disable-lgpl --enable-encoding
[cplayer] List of enabled features: 51fbsd alsa asm atomics cdda cplayer cplugins cuda-hwaccel debug-build drm dvbin dvdnav dvdread dvdread-common egl-drm egl-helpers egl-x11 encoding fchmod ffmpeg gbm gbm.h gl gl-x11 glibc-thread-name glob glob-posix gnuc gpl iconv jack jpeg lcms2 libaf libarchive libass libass-osd libav-any libavcodec libavdevice libbluray libdl libm libmpv-shared librt linux-fstatfs lua optimize oss-audio plain-gl posix posix-or-mingw posix-spawn posix-spawn-native pthreads pulse rubberband sdl2 stdatomic uchardet vaapi vaapi-drm vaapi-egl vaapi-glx vaapi-x-egl vaapi-x11 vdpau vdpau-gl-x11 vt.h x11 xv zlib zsh-comp
[cplayer] Error parsing option gpu-backend (option not found)
[cplayer] Setting commandline option --gpu-backend=wayland failed.
[cplayer] 
[cplayer] Exiting... (Fatal error)

Also, wayland is not listed as a GPU context:

> mpv --gpu-context=help
GPU contexts (APIs):
    auto (autodetect)
    x11probe (opengl)
    x11egl (opengl)
    x11 (opengl)
    drm (opengl)
    vdpauglx (opengl)

@mia-0
Copy link
Member

mia-0 commented Feb 5, 2018 via email

@glaubersm
Copy link

I just tested mpv 0.27 in Gnome 3.26.2, Wayland session, Arch Linux
mpv -opengl-backend=wayland video.mp4
A borderless mpv window plays the video and my screen turns off during playback.
This problem also happens under KDE Plasma Wayland session. It's very annoying and there is no precise explanation or solution so far.

@mia-0
Copy link
Member

mia-0 commented Feb 6, 2018

0.27.0 is too old and lacks many bugfixes for Wayland support. Also, the lack of window decorations is a Wayland protocol/compositor issue, not our problem. We won’t implement client-side decorations in the foreseeable future.

@glaubersm
Copy link

installed 0.28 from AUR some minutes ago.
Same problem.

@zakora
Copy link
Author

zakora commented Feb 6, 2018

@lachs0r Indeed, my mpv was not build with Wayland support. I'll try to build it manually or ask the package maintainer to enable wayland support.

@glaubersm Could you check mpv -v with mpv 0.28.0 and check that wayland is in "[cplayer] List of enabled features"?
If you used the mpv-full PKGBUILD, then mpv should be compiled with Wayland support according to https://aur.archlinux.org/cgit/aur.git/tree/PKGBUILD?h=mpv-full#n100

@glaubersm
Copy link

I installed mpv-full. Wayland support is enabled.

@CounterPillow
Copy link
Contributor

installed 0.28 from AUR some minutes ago.
Same problem.

Probably using a GTK/Gnome version without the server side decoration protocol then. I'm fairly sure atomnuker implemented it.

@mc4man
Copy link

mc4man commented Feb 6, 2018

As far as gnome that bug report does seem relevant. Doesn't matter if mpv builds with support for the protocol as the current compositor doesn't support it. Ex.
$ strings /usr/bin/mpv |grep inhibit
Enabling idle inhibitor
Disabling the idle inhibitor
zwp_idle_inhibit_manager_v1
zwp_idle_inhibitor_v1
create_inhibitor

0.024][v][vo/gpu/opengl] Initializing GPU context 'wayland'
[ 0.024][v][vo/gpu] Enabling event driven renderloop!
[ 0.024][v][vo/gpu/wayland] Registered for protocol wl_compositor
[ 0.024][v][vo/gpu/wayland] Registered for protocol wl_shm
[ 0.024][v][vo/gpu/wayland] Registered for protocol wl_output
[ 0.024][v][vo/gpu/wayland] Registered for protocol wl_data_device_manager
[ 0.024][v][vo/gpu/wayland] Registered for protocol zxdg_shell_v6
[ 0.024][v][vo/gpu/wayland] Registered for protocol wl_seat
[ 0.024][v][vo/gpu/wayland] Compositor doesn't support the org_kde_kwin_server_decoration_manager protocol!
[ 0.024][v][vo/gpu/wayland] Compositor doesn't support the zwp_idle_inhibit_manager_v1 protocol!

@CounterPillow
Copy link
Contributor

So to summarise:

  1. make sure you're using the wayland gpu backend (and have actually built with wayland support)
  2. make sure your compositor is up-to-date enough to support both of these protocols
  3. make sure your mpv version is up-to-date enough to support both of these protocols (i.e. 0.28 or newer)
  4. if all of these 3 points are fulfilled, post a log generated with --log-file.

If points 1 through 3 are not applicable, it's not upstream mpv's issue.

@glaubersm
Copy link

Both Gnome and mpv 0.28 use Wayland backend on my system.
My compositor (mutter) is updated.
My mpv is updated (0.28)

Monitor turns off during video playback anyway.

@CounterPillow
Copy link
Contributor

Where's the full debug log then, @glaubersm ?

@glaubersm
Copy link

See attachment. Thanks.
mpvlog.txt

@CounterPillow
Copy link
Contributor

[   0.385][v][vo/gpu/wayland] Compositor doesn't support the org_kde_kwin_server_decoration_manager protocol!
[   0.385][v][vo/gpu/wayland] Compositor doesn't support the zwp_idle_inhibit_manager_v1 protocol!

Well there's your problem.

@glaubersm
Copy link

Which Wayland compositor currently supports any of these protocols?

@CounterPillow
Copy link
Contributor

KWin supports both of them. Sway supports the decorations protocol. GNOME should be supporting the decorations protocol too in an upcoming release of Gtk, if I remember correctly.

@glaubersm
Copy link

Thanks. I will test mpv 0.28 under KDE Plasma 5.12 Wayland later.

@glaubersm
Copy link

Just tested... mpv 0.28 keeps my monitor active under KDE Plasma Wayland.

@zakora
Copy link
Author

zakora commented Feb 6, 2018

To sum up, in order to circumvent the screen blanking under a Wayland session:

  • users need at least mpv 0.28, since there was a lot of work done for Wayland since 0.27
  • users need an mpv version compiled with Wayland support (not the case currently for Fedora 27)
  • users need a compositor that respects the zwp_idle_inhibit_manager_v1 protocol (so if I understand correctly, mpv will not use xdg-screensaver under Wayland)

If this is correct we should close the issue, as mpv is not at fault.

@glaubersm
Copy link

I can be wrong, but I think Gnome currently does not support screensavers.

@emersion
Copy link
Contributor

emersion commented Feb 7, 2018

Sway supports the decorations protocol.

The idle-inhibit protocol is being implemented.

GNOME should be supporting the decorations protocol too in an upcoming release of Gtk, if I remember correctly.

GTK supports it, but GNOME (aka Mutter) doesn't. It means mpv won't be able to use the decorations protocol in a GNOME session.

@zakora
Copy link
Author

zakora commented Feb 7, 2018

Closing for now, as the original screen blanking issue is solved by having the latest mpv and capable environment.
I will reopen if I have the issue when I can test mpv 0.28 with Wayland support under Gnome Wayland.

@zakora zakora closed this as completed Feb 7, 2018
@mc4man
Copy link

mc4man commented Feb 7, 2018 via email

@zakora
Copy link
Author

zakora commented Feb 7, 2018

Thanks for the valuable info @mc4man , I'll keep on eye on the Gnome issue.

@MrMagne
Copy link

MrMagne commented Mar 24, 2018

I know this issue is closed, but on gnome it works to set up an inhibitor. It works with the dbus API of 'org.gnome.SessionManager'. I made a small example in python for inhibiting when mpd is playing, code is very simple: https://github.com/MrMagne/mpdIdleInhibitor/blob/master/mpdIdleInhibitor.py

@All3xJ
Copy link

All3xJ commented Feb 15, 2022

Bug still present. To fix: https://wiki.archlinux.org/title/Mpv#GNOME_Blank_screen_(Wayland)

@RevAngel7
Copy link

Same issue under ubuntu 22.04 (20.04 was fine), wayland, mpv 2.0.33-focal1

@HubKing
Copy link

HubKing commented Dec 14, 2022

Bug still present.

Well, I had the same problem in almost 2023, and that is why I came here in the first place. But it may not be a "bug". Installing this solved the problem, and its author says:

This is needed because neither mpv supports GNOME's inhibition protocol, nor GNOME supports the standard inhibition protocol (yet).

I do not know well about Linux, but if Gnome's way is not "the standard", then maybe it is Gnome's fault that it does not follow the standard.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests