mpv icon indicating copy to clipboard operation
mpv copied to clipboard

mpv fails to play subsequent video after being idle (vo=gpu gpu-context=drm)

Open krupenik opened this issue 3 years ago • 1 comments

Important Information

Provide following Information:

  • mpv version: 0.34.1
  • Linux Distribution and Version: Alpine Linux, 5.18.5-0-edge
  • Source of the mpv binary: apk
  • GPU driver and version: i915 1.6.0 20201103

Reproduction steps

# mpv --no-config --idle --input-ipc-server=/tmp/mpv.sock --log-file=/root/mpv.log --vo=gpu --gpu-context=drm
# echo '{ "command": [ "loadfile", "/root/t.ts" ] }' | nc local:/tmp/mpv.sock
{"data":{"playlist_entry_id":1},"request_id":0,"error":"success"}

# echo '{ "command": [ "stop" ] }' | nc local:/tmp/mpv.sock                  
{"data":null,"request_id":0,"error":"success"}

# echo '{ "command": [ "loadfile", "/root/t.ts" ] }' | nc local:/tmp/mpv.sock
{"data":{"playlist_entry_id":2},"request_id":0,"error":"success"}

Launch idle mpv with IPC socket, play a video, stop, play a video again.

Expected behavior

Playing videos normally.

Actual behavior

 (+) Video --vid=1 (hevc)
     Audio --aid=1 (mp3)
Using hardware decoding (vaapi).
VO: [gpu] 2560x1440 => 2560x1447 vaapi[nv12]
V: 00:00:04 / 00:00:05 (81%)

 (+) Video --vid=1 (hevc)
     Audio --aid=1 (mp3)
[vo/gpu] Failed to commit ModeSetting atomic request (-13)
[vo/gpu/opengl] Failed to set CRTC for connector 111: Permission denied
[vo/gpu] Failed initializing any suitable GPU context!
Error opening/initializing the selected video_out (--vo) device.
Video: no video
No video or audio streams selected.

Log file

mpv.log

krupenik avatar Aug 30 '22 10:08 krupenik

Same problem. It make me headache.

dream7180 avatar Sep 10 '22 15:09 dream7180

How are you running the echo commands? If you have the mpv --no-config --idle command running in a separate tty and then switching back to another tty that's running a graphical environment (xorg or way) to then run the echo commands, this won't work. The reason is simply because xorg or your wayland compositor has control over the drm master and only one thing can have it at a time. mpv in tty needs the drm master to be able to do anything so you get that permission denied error. When you switch to another tty, xorg or your wayland compositor drops the drm master which is why running an mpv command in there works (mpv itself also drops drm master when you switch ttys of course).

If you do not have any graphical environment running at all (i.e. no xorg or wayland) and just use multiple ttys, then the steps you describe work fine. Well mpv will show itself when you load a file but you can just switch away again to another tty and send it a command via the socket to stop it and then start it again. Closing this since I'm fairly sure what you're seeing is just the behavior I described and there's no bug here. This is just how graphics on linux works. Feel free to reopen if I completely misunderstood something.

Dudemanguy avatar Jan 09 '23 16:01 Dudemanguy

How are you running the echo commands?

via ssh (in development) or via a daemon writing to the socket (in production)

There is no xorg, wayland compositor or anything else graphics-related besides mpv running. There's also no tty switching.

mpv works just fine with --vo=gpu --gpu-context=x11egl when Xorg is running, but behaves as described above with --vo=gpu --gpu-context=drm and without Xorg

Not sure how to reopen the issue.

krupenik avatar Jan 09 '23 18:01 krupenik

via ssh (in development) or via a daemon writing to the socket (in production)

Oh duh, I should have seen nc in your OP. My bad. Still, naively just using ssh works fine here and I can't imagine why there would be any difference. I'll try to configure netcat later to technically copy what you did better.

Dudemanguy avatar Jan 09 '23 18:01 Dudemanguy

@krupenik: I can't reproduce your issue with current git master, but if you get a chance, could you see if https://github.com/mpv-player/mpv/pull/11098 fixes it? From your log, it should still a drm permissions issue so I assume mpv isn't dropping the drm master (although the stop command should completely kill mpv and make this not matter...). Anyways, it fixes a similar issue (#10391), so I think there's a decent chance it might cover what you experience.

Dudemanguy avatar Jan 10 '23 17:01 Dudemanguy

@krupenik: it's finally been merged into master now. I'm optimistic that it solves your problem.

Dudemanguy avatar Jan 21 '23 17:01 Dudemanguy

thanks! Will confirm when I get a chance.

krupenik avatar Jan 21 '23 20:01 krupenik

Should have been fixed by the drm rewrite so closing. If not, feel free to reopen.

Dudemanguy avatar Aug 09 '23 04:08 Dudemanguy