mpv icon indicating copy to clipboard operation
mpv copied to clipboard

vo_wlshm: hang with "interface 'xdg_toplevel' has no event 3" when running inside a container

Open ruihe774 opened this issue 1 year ago • 5 comments

Important Information

  • mpv version: v0.38.0-2e03e03
  • Linux Distribution and Version:
    • Host: Fedora Linux 40.20240424.0 (Silverblue) x86_64
    • Container: Ubuntu 22.04 LTS x86_64
  • Source of the mpv binary: I compiled it from Git HEAD
  • If known which version of mpv introduced the problem: IDK
  • Window Manager and version: Mutter (GNOME 46.1)
  • GPU model, driver and version: Intel DG2 [Arc A750], using i915 KMS driver; kernel version: 6.8.7
  • Possible screenshot or video of visual glitches: no window at all

Reproduction steps

Create a Podman container with shared network and IPC namespace:

$ podman run --network=host --ipc=host --userns=keep-id -v /run/user/60492:/run/user/60492 --user root --init jammy /usr/sbin/sshd -D -p 3333

The jammy image was built before with correct user entry and development tools installed. You can also use toolbox instead of podman to create such a containerized environment.

Set the environ in the container:

$ export DISPLAY=:0
$ export WAYLAND_DISPLAY=/run/user/60492/wayland-0

After that, I've checked it using:

$ weston-terminal

It works fine and the window of weston terminal pops up.

I run mpv using the following command:

$ mpv --no-config --profile=sw-fast --vo=wlshm --ao=null  test.mkv -v --log-file=mpv.log

Expected behavior

mpv opens a window and starts playback.

Actual behavior

mpv hangs and no window is opened. A message is shown in the terminal: interface 'xdg_toplevel' has no event 3. It is not printed by mpv and is not included in the log file.

The debugger shows mpv hangs at https://github.com/mpv-player/mpv/blob/2e03e0305caf851e305a7d73af1efe4a4fdf693a/video/out/wayland_common.c#L2272

Log file

[   0.000][d][global] user path: 'mpv.log' -> 'mpv.log'
[   0.001][v][cplayer] mpv 0.38.0-UNKNOWN Copyright © 2000-2024 mpv/MPlayer/mplayer2 projects
[   0.001][v][cplayer]  built on Apr 25 2024 08:20:51
[   0.001][v][cplayer] libplacebo version: v6.338.2
[   0.001][v][cplayer] FFmpeg version: 4.4.2-0ubuntu0.22.04.1
[   0.001][v][cplayer] FFmpeg library versions:
[   0.001][v][cplayer]    libavutil       56.70.100
[   0.001][v][cplayer]    libavcodec      58.134.100
[   0.001][v][cplayer]    libavformat     58.76.100
[   0.001][v][cplayer]    libswscale      5.9.100
[   0.001][v][cplayer]    libavfilter     7.110.100
[   0.001][v][cplayer]    libswresample   3.9.100
[   0.001][v][cplayer] 
[   0.001][v][cplayer] Configuration: -Dwayland=enabled -Dxv=enabled -Dpipewire=enabled -Dlua=enabled
[   0.001][v][cplayer] List of enabled features: build-date cplugins debug dvbin ffmpeg gl glibc-thread-name glob glob-posix gpl iconv libarchive libass libdl libplacebo linux-fstatfs lua51 memfd-create pipewire posix posix-shm ppoll pthread-condattr-setclock vector vt.h wayland x11 xv zlib
[   0.001][v][cplayer] Command line options: '--no-config' '--profile=sw-fast' '--vo=wlshm' '--ao=null' 'test.mkv' '-v' '--log-file=mpv.log'
[   0.001][v][cplayer] mpv 0.38.0-UNKNOWN Copyright © 2000-2024 mpv/MPlayer/mplayer2 projects
[   0.001][v][cplayer]  built on Apr 25 2024 08:20:51
[   0.001][v][cplayer] libplacebo version: v6.338.2
[   0.001][v][cplayer] FFmpeg version: 4.4.2-0ubuntu0.22.04.1
[   0.001][v][cplayer] FFmpeg library versions:
[   0.001][v][cplayer]    libavutil       56.70.100
[   0.001][v][cplayer]    libavcodec      58.134.100
[   0.001][v][cplayer]    libavformat     58.76.100
[   0.001][v][cplayer]    libswscale      5.9.100
[   0.001][v][cplayer]    libavfilter     7.110.100
[   0.001][v][cplayer]    libswresample   3.9.100
[   0.001][v][cplayer] 
[   0.001][v][cplayer] Configuration: -Dwayland=enabled -Dxv=enabled -Dpipewire=enabled -Dlua=enabled
[   0.001][v][cplayer] List of enabled features: build-date cplugins debug dvbin ffmpeg gl glibc-thread-name glob glob-posix gpl iconv libarchive libass libdl libplacebo linux-fstatfs lua51 memfd-create pipewire posix posix-shm ppoll pthread-condattr-setclock vector vt.h wayland x11 xv zlib
[   0.001][d][global] home path: '' -> '-'
[   0.001][d][global] user path: '~~home/' -> ''
[   0.001][d][global] user path: '~~old_home/' -> ''
[   0.001][v][cplayer] Setting option 'config' = 'no' (flags = 8)
[   0.001][v][cplayer] Setting option 'profile' = 'sw-fast' (flags = 8)
[   0.001][v][cplayer] Applying profile 'sw-fast'...
[   0.001][v][cplayer] Setting option 'sws-scaler' = 'bilinear' (flags = 12)
[   0.001][v][cplayer] Setting option 'sws-fast' = 'yes' (flags = 12)
[   0.001][v][cplayer] Setting option 'vo' = 'wlshm' (flags = 8)
[   0.001][v][cplayer] Setting option 'ao' = 'null' (flags = 8)
[   0.001][v][cplayer] Setting option 'v' = '' (flags = 8)
[   0.001][v][cplayer] Setting option 'log-file' = 'mpv.log' (flags = 8)
[   0.002][d][global] user path: 'mpv.log' -> 'mpv.log'
[   0.002][d][osc] Loading lua script @osc.lua...
[   0.002][d][ytdl_hook] Loading lua script @ytdl_hook.lua...
[   0.002][d][stats] Loading lua script @stats.lua...
[   0.002][d][console] Loading lua script @console.lua...
[   0.002][d][auto_profiles] Loading lua script @auto_profiles.lua...
[   0.002][v][cplayer] Waiting for scripts...
[   0.002][d][stats] loading mp.defaults
[   0.002][d][ytdl_hook] loading mp.defaults
[   0.002][d][console] loading mp.defaults
[   0.002][d][auto_profiles] loading mp.defaults
[   0.002][d][osc] loading mp.defaults
[   0.003][d][console] loading @console.lua
[   0.003][d][auto_profiles] loading @auto_profiles.lua
[   0.003][d][stats] loading @stats.lua
[   0.003][d][ytdl_hook] loading @ytdl_hook.lua
[   0.003][d][osc] loading @osc.lua
[   0.004][d][ytdl_hook] reading options for ytdl_hook
[   0.004][d][ytdl_hook] script-opts/ytdl_hook.conf not found.
[   0.004][d][ytdl_hook] lua-settings/ytdl_hook.conf not found.
[   0.004][d][console] reading options for console
[   0.004][d][console] script-opts/console.conf not found.
[   0.004][d][console] lua-settings/console.conf not found.
[   0.004][d][stats] reading options for stats
[   0.004][d][stats] script-opts/stats.conf not found.
[   0.004][d][stats] lua-settings/stats.conf not found.
[   0.004][d][cplayer] Run command: define-section, flags=64, args=[name="input_console", contents="", flags="default"]
[   0.004][d][cplayer] Run command: enable-section, flags=64, args=[name="input_console", flags="allow-hide-cursor+allow-vo-dragging"]
[   0.004][d][cplayer] Run command: define-section, flags=64, args=[name="input_forced_console", contents="", flags="force"]
[   0.004][d][cplayer] Run command: enable-section, flags=64, args=[name="input_forced_console", flags="allow-hide-cursor+allow-vo-dragging"]
[   0.004][d][cplayer] Run command: define-section, flags=64, args=[name="input_stats", contents="", flags="default"]
[   0.004][d][cplayer] Run command: enable-section, flags=64, args=[name="input_stats", flags="allow-hide-cursor+allow-vo-dragging"]
[   0.004][d][cplayer] Run command: define-section, flags=64, args=[name="input_forced_stats", contents="", flags="force"]
[   0.004][d][cplayer] Run command: enable-section, flags=64, args=[name="input_forced_stats", flags="allow-hide-cursor+allow-vo-dragging"]
[   0.005][d][osc] reading options for osc
[   0.005][d][osc] script-opts/osc.conf not found.
[   0.005][d][osc] lua-settings/osc.conf not found.
[   0.005][d][cplayer] Run command: define-section, flags=64, args=[name="showhide", contents="mouse_move script-binding osc/__keybinding1\nmouse_leave script-binding osc/__keybinding2\n", flags="force"]
[   0.005][d][cplayer] Run command: define-section, flags=64, args=[name="showhide_wc", contents="mouse_move script-binding osc/__keybinding3\nmouse_leave script-binding osc/__keybinding4\n", flags="force"]
[   0.005][d][cplayer] Run command: enable-section, flags=64, args=[name="showhide", flags="allow-hide-cursor+allow-vo-dragging"]
[   0.005][d][cplayer] Run command: enable-section, flags=64, args=[name="showhide_wc", flags="allow-hide-cursor+allow-vo-dragging"]
[   0.005][d][cplayer] Run command: define-section, flags=64, args=[name="input", contents="mbtn_left script-binding osc/__keybinding5\nshift+mbtn_left script-binding osc/__keybinding6\nmbtn_right script-binding osc/__keybinding7\nmbtn_mid script-binding osc/__keybinding8\nwheel_up script-binding osc/__keybinding9\nwheel_down script-binding osc/__keybinding10\nmbtn_left_dbl ignore\nshift+mbtn_left_dbl ignore\nmbtn_right_dbl ignore\n", flags="force"]
[   0.005][d][cplayer] Run command: enable-section, flags=64, args=[name="input", flags=""]
[   0.005][d][cplayer] Run command: define-section, flags=64, args=[name="window-controls", contents="mbtn_left script-binding osc/__keybinding11\n", flags="force"]
[   0.005][d][cplayer] Run command: enable-section, flags=64, args=[name="window-controls", flags=""]
[   0.005][v][cplayer] Set property: user-data/osc/visibility="auto" -> 1
[   0.005][d][cplayer] Run command: disable-section, flags=64, args=[name="input"]
[   0.005][d][cplayer] Run command: disable-section, flags=64, args=[name="window-controls"]
[   0.005][v][cplayer] Set property: user-data/osc/margins={"b":0,"l":0,"t":0,"r":0} -> 1
[   0.005][v][cplayer] Done loading scripts.
[   0.005][d][global] state path: 'watch_later' -> '-'
[   0.005][v][cplayer] Running hook: auto_profiles/on_before_start_file
[   0.005][d][global] state path: 'watch_later' -> '-'
[   0.005][v][cplayer] Running hook: ytdl_hook/on_load
[   0.005][v][ytdl_hook] ytdl:// hook
[   0.006][v][cplayer] Set property: user-data/osc/margins={"b":0,"l":0,"t":0,"r":0} -> 1
[   0.006][v][ytdl_hook] not a ytdl:// url
[   0.006][d][osc] osc_init
[   0.006][v][cplayer] Running hook: ytdl_hook/on_load
[   0.006][v][ytdl_hook] playlist hook
[   0.006][v][cplayer] Running hook: auto_profiles/on_load
[   0.006][v][file] Opening test.mkv
[   0.006][d][file] resize stream to 131072 bytes, drop 0 bytes
[   0.006][d][file] Stream opened successfully.
[   0.006][v][demux] Trying demuxers for level=normal.
[   0.006][d][demux] Trying demuxer: disc (force-level: normal)
[   0.006][d][demux] Trying demuxer: edl (force-level: normal)
[   0.006][d][demux] Trying demuxer: cue (force-level: normal)
[   0.006][d][demux] Trying demuxer: rawaudio (force-level: normal)
[   0.006][d][demux] Trying demuxer: rawvideo (force-level: normal)
[   0.006][d][demux] Trying demuxer: mkv (force-level: normal)
[   0.006][d][mkv] Found the head...
[   0.006][d][mkv] + a segment...
[   0.006][d][mkv] Parsing seek head...
[   0.006][d][mkv] |+ segment information...
[   0.006][d][mkv] float 1449989.000000
[   0.006][d][mkv] | + muxing app: Lavf58.76.100
[   0.006][d][mkv] | + writing app: Lavf58.76.100
[   0.006][d][mkv] | + timecode scale: 1000000
[   0.006][d][mkv] | + duration: 1449.989s
[   0.006][d][mkv] | + segment uid 96 2d 22 a4 6a 62 2c 61 28 df e4 67 a6 5e ba e8
[   0.006][d][mkv] |+ segment tracks...
[   0.006][v][cplayer] Set property: user-data/osc/margins={"b":0,"l":0,"t":0,"r":0} -> 1
[   0.006][d][mkv] | + a track...
[   0.006][d][mkv] |  + Track number: 1
[   0.006][d][mkv] |  + Track type: Video
[   0.006][d][mkv] |  + Video track
[   0.006][d][mkv] |   + Pixel width: 1920
[   0.006][d][mkv] |   + Pixel height: 1080
[   0.006][d][mkv] |    + Matrix: bt.709
[   0.006][d][mkv] |    + Primaries: bt.709
[   0.006][d][mkv] |    + Gamma: bt.1886
[   0.006][d][mkv] |    + Levels: limited
[   0.006][d][mkv] |  + Codec ID: V_MPEGH/ISO/HEVC
[   0.006][d][mkv] |  + CodecPrivate, length 2778
[   0.006][d][mkv] |  + Language: und
[   0.006][d][mkv] |  + Default duration: 41.708ms ( = 23.976 fps)
[   0.006][d][mkv] |+ found cluster
[   0.006][v][mkv] Deferring reading cues.
[   0.006][v][mkv] All headers are parsed!
[   0.006][d][osd/libass] ASS library version: 0x1502000 (runtime 0x1502000)
[   0.006][v][osd/libass] libass API version: 0x1502000
[   0.006][v][osd/libass] libass source: tarball: 0.15.2
[   0.006][v][osd/libass] Shaper: FriBidi 1.0.8 (SIMPLE) HarfBuzz-ng 2.7.4 (COMPLEX)
[   0.006][v][osd/libass] Setting up fonts...
[   0.006][v][demux] Detected file format: Matroska
[   0.006][v][cplayer] Opening done: test.mkv
[   0.009][v][osd/libass] Using font provider fontconfig
[   0.009][v][osd/libass] Done.
[   0.009][d][osc] osc_init
[   0.009][v][find_files] Loading external files in .
[   0.009][v][cplayer] Running hook: ytdl_hook/on_preloaded
[   0.009][v][cplayer] Running hook: auto_profiles/on_preloaded
[   0.010][v][mkv] select track 0
[   0.010][i][cplayer]  (+) Video --vid=1 (*) (hevc 1920x1080 23.976fps)
[   0.010][v][vo/wlshm/wayland] Registered for protocol wl_compositor
[   0.010][v][vo/wlshm/wayland] Registered for protocol wl_shm
[   0.010][v][vo/wlshm/wayland] Registered for protocol wl_output
[   0.010][v][vo/wlshm/wayland] Registered for protocol wl_data_device_manager
[   0.010][v][vo/wlshm/wayland] Registered for protocol wl_subcompositor
[   0.010][v][vo/wlshm/wayland] Registered for protocol xdg_wm_base
[   0.010][v][vo/wlshm/wayland] Registered for protocol wp_viewporter
[   0.010][v][vo/wlshm/wayland] Registered for protocol wl_seat
[   0.010][v][vo/wlshm/wayland] Registered for protocol zwp_linux_dmabuf_v1
[   0.010][v][vo/wlshm/wayland] Registered for protocol wp_presentation
[   0.010][v][vo/wlshm/wayland] Registered for protocol zwp_idle_inhibit_manager_v1
[   0.010][v][vo/wlshm/wayland] Compositor doesn't support the zxdg_decoration_manager_v1 protocol!

FWIW, vo=x11 and vo=xv work fine.

ruihe774 avatar Apr 25 '24 01:04 ruihe774

GNOME 46.1 should have a new enough xdg-shell so that's really odd, but it probably doesn't hurt to guard this

Does this fix it?

diff --git a/video/out/wayland_common.c b/video/out/wayland_common.c
index 4a86c21c7e35..731ea31179aa 100644
--- a/video/out/wayland_common.c
+++ b/video/out/wayland_common.c
@@ -1192,6 +1192,7 @@ static void handle_toplevel_close(void *data, struct xdg_toplevel *xdg_toplevel)
     mp_input_put_key(wl->vo->input_ctx, MP_KEY_CLOSE_WIN);
 }
 
+#ifdef XDG_TOPLEVEL_CONFIGURE_BOUNDS_SINCE_VERSION
 static void handle_configure_bounds(void *data, struct xdg_toplevel *xdg_toplevel,
                                     int32_t width, int32_t height)
 {
@@ -1199,6 +1200,7 @@ static void handle_configure_bounds(void *data, struct xdg_toplevel *xdg_topleve
     wl->bounded_width = width * wl->scaling;
     wl->bounded_height = height * wl->scaling;
 }
+#endif
 
 #ifdef XDG_TOPLEVEL_WM_CAPABILITIES_SINCE_VERSION
 static void handle_wm_capabilities(void *data, struct xdg_toplevel *xdg_toplevel,
@@ -1210,7 +1212,9 @@ static void handle_wm_capabilities(void *data, struct xdg_toplevel *xdg_toplevel
 static const struct xdg_toplevel_listener xdg_toplevel_listener = {
     handle_toplevel_config,
     handle_toplevel_close,
+#ifdef XDG_TOPLEVEL_CONFIGURE_BOUNDS_SINCE_VERSION
     handle_configure_bounds,
+#endif
 #ifdef XDG_TOPLEVEL_WM_CAPABILITIES_SINCE_VERSION
     handle_wm_capabilities,
 #endif

llyyr avatar Apr 25 '24 04:04 llyyr

GNOME 46.1 should have a new enough xdg-shell so that's really odd, but it probably doesn't hurt to guard this

Does this fix it?

diff --git a/video/out/wayland_common.c b/video/out/wayland_common.c
index 4a86c21c7e35..731ea31179aa 100644
--- a/video/out/wayland_common.c
+++ b/video/out/wayland_common.c
@@ -1192,6 +1192,7 @@ static void handle_toplevel_close(void *data, struct xdg_toplevel *xdg_toplevel)
     mp_input_put_key(wl->vo->input_ctx, MP_KEY_CLOSE_WIN);
 }
 
+#ifdef XDG_TOPLEVEL_CONFIGURE_BOUNDS_SINCE_VERSION
 static void handle_configure_bounds(void *data, struct xdg_toplevel *xdg_toplevel,
                                     int32_t width, int32_t height)
 {
@@ -1199,6 +1200,7 @@ static void handle_configure_bounds(void *data, struct xdg_toplevel *xdg_topleve
     wl->bounded_width = width * wl->scaling;
     wl->bounded_height = height * wl->scaling;
 }
+#endif
 
 #ifdef XDG_TOPLEVEL_WM_CAPABILITIES_SINCE_VERSION
 static void handle_wm_capabilities(void *data, struct xdg_toplevel *xdg_toplevel,
@@ -1210,7 +1212,9 @@ static void handle_wm_capabilities(void *data, struct xdg_toplevel *xdg_toplevel
 static const struct xdg_toplevel_listener xdg_toplevel_listener = {
     handle_toplevel_config,
     handle_toplevel_close,
+#ifdef XDG_TOPLEVEL_CONFIGURE_BOUNDS_SINCE_VERSION
     handle_configure_bounds,
+#endif
 #ifdef XDG_TOPLEVEL_WM_CAPABILITIES_SINCE_VERSION
     handle_wm_capabilities,
 #endif

No. The problem remains the same.

Can it be caused by that the compositor has a higher version of xdg_toplevel while the client library has an older one? In the container environment where mpv is built (Ubuntu 22.04), XDG_TOPLEVEL_WM_CAPABILITIES_SINCE_VERSION is not defined.

ruihe774 avatar Apr 25 '24 05:04 ruihe774

Can it be caused by that the compositor has a higher version of xdg_toplevel while the client library has an older one? In the container environment where mpv is built (Ubuntu 22.04), XDG_TOPLEVEL_WM_CAPABILITIES_SINCE_VERSION is not defined.

That seems to be the case.

llyyr avatar Apr 25 '24 05:04 llyyr

Does https://github.com/mpv-player/mpv/issues/13986 work?

Dudemanguy avatar Apr 25 '24 17:04 Dudemanguy

Does #13986 work?

Yes, #13993 works.

ruihe774 avatar Apr 26 '24 06:04 ruihe774