wayland: playing stops when not receiving frame events
When the compositor stops sending to the mpv surface the frame events (such as when minimizing it in Orbital (https://github.com/giucam/orbital)) the playing stops entirely. It should instead stop rendering but also keep playing the file.
Does this occur with both outputs --vo=wayland and --vo=opengl:backend=wayland or just one of them?
Ah, it happens only with --vo=opengl:backend=wayland. I didn't know i could just do --vo=wayland, it works right in that case.
--vo=wayland uses shared memory and ffmpeg for scaling, which makes it slow and terrible. But now I can imagine why it blocks. If there is no frame event then eglSwapBuffers probably blocks forever while the shm backend just continues normally.
A solution that would not require any changes to the core mpv code would be adding a callback listener for the frame event that calls eglSwapBuffers. But I have to test if that works out.
I found out that I can't run orbital because the qt5 libraries that ship witch archlinux don't have wayland as platform enabled. So this has to wait a little more until I can actually test it myself.
Wayland support is in an external module for now, QtWayland (http://qt-project.org/wiki/QtWayland). You can just build that and use it with the system libs.
I was unable to build it myself, but I made an attempt in fixing it.
Commit 5decce403d8259274db29ba72b1fdf2039402065 in the branch wayland_egl_fiix might solve this problem (or not)
If it works for you I will commit it to master. EDIT : NOPE I just noticed this makes the playback horrible jumpy. EDIT2: Maybe making it threaded might solve it. EDIT3: Or I will wait for a proper protocol
It also still blocks. :) I don't think a new protocol is needed though. I don't know how mpv works but making it threaded should be enough.
EDIT: No, sorry. It does fix the issue.
I don't think a new protocol is needed though.
Letting a thread block for random extended periods of time is completely unreasonable, and won't work well with any design, no matter how much threaded it is. In fact, heavy threading will make the problem worse, because then random threads will start to deadlock (because the renderer thread never responds), and you won't be able to find the actual cause. (Basically, a debugging nightmare.)
So, no, it needs a better design, not demand unrealistic things from clients.
I don't know how mpv works but making it threaded should be enough.
Nope.
I don't mean a new protocol, but some mechanic to tell the window that it is minimized. Then I could just change the eglSwapInterval to 0. But for now the problem lies in eglSwapBuffers, because it blocks. Maybe Orbital could still send frame_events to hidden clients.
EDIT: No, sorry. It does fix the issue.
Nope. Suppose we run the OpenGL renderer in a thread. Then the thread will become unresponsive as soon as you minimize the window, and the application will explode because it can't communicate with the thread.
This design doesn't even allow a program to quit while minimized, because the thread can't terminate. It doesn't work.
Maybe Orbital could still send frame_events to hidden clients.
I tried that, and it indeed works but it's wasted cpu cycles as the rendered images never get to the screen. Sending frame events when minimized will actually be needed, but not as if the surface was visible, but at a much slower frequency, which right now would result also in a slower playing speed.
A protocol for advertizing a surface it has been minimized has been discussed and will be implemented in wayland but i don't think it's the point here. It wouldn't even help with the slow frame events frequency.
@wm4 I mean 5decce4 fixes the issue.
@wm4 I mean 5decce4 fixes the issue.
Not really, because It actually needs 2 frame_events while playing which makes the playback horrible (I don't know how to describe it).
The problem is either the egl implementation or the missing specs for hidden/minimized windows.
Not really, because It actually needs 2 frame_events while playing which makes the playback horrible (I don't know how to describe it).
Yeah, i'm not saying it's good to go, i'm saying it doesn't block anymore :)
Fixed with a0e3e283259a646ddde3958f69aed901ac5dc62f and works acceptable, but I don't really like to attach 2 callbacks.
I rebased the wayland_egl_fix branch on top of master in case you're planning to still use it.
Fixed in 96e75d234a4df1a09f38eaf932d00d79dccdc324
I had to revert the commit becaues of visual glitches.
With the newest mesa and with the branch wayland_xdg this bug is fixed.
I solved it by disabling vsync when the window is not focused. I think that is a good enough trade off, because if the window is not focused you likely won't notice any tearing or you might not care.
I will close this issue once the xdg shell is stable and part of the official wayland protocol.
That's nice! Kind of disappointed that wayland doesn't seem to have something better for this.
I solved it by disabling vsync when the window is not focused.
Doesn't this have a race condition? The window could get defocused between the point you check window focus (but the window isn't focused yet), and the point you swap a frame with vsync enabled.
Wait ignore my comment. This is also fixed in the master branch. I guess it was fixed in mesa along with addition of eglSwapBufferInterval. I am currently looking through the mesa commits to see if I can find the change that fixed it.
Well then I can close this issue.