fix: Wayland outputs were locked to half refresh (EGL swap interval + libmpv blocking) (#677)
* fix: set EGL swap interval to 0 on Wayland outputs
WaylandOutputViewport paces rendering with its own wl_surface_frame
callback (swapOutput requests one before every eglSwapBuffers). With the
default swap interval of 1, eglSwapBuffers additionally blocks on the EGL
surface's internal frame callback, so each frame waits for two vblanks.
On a 60Hz output every surface was locked to exactly 30fps regardless of
--fps or the number of outputs.
Measured with WAYLAND_DEBUG=1 on Hyprland (NVIDIA EGL, 5 outputs @60Hz),
wl_surface.commit intervals per surface:
before: 30.0 fps, stdev 0.1ms (two wl_callback.done per frame:
one from the app's queue, one from the EGLSurface queue)
after: 60.1 fps, stdev ~2ms
Rendering is still driven only by frame callbacks, so nothing runs
unthrottled; the --fps sleep in the driver loop is unchanged.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
* fix: do not block in mpv_render_context_render for the frame target time
GLPlayer::render is called from the output's frame callback, i.e. the
host loop is already display-synced. libmpv's default
MPV_RENDER_PARAM_BLOCK_FOR_TARGET_TIME=1 makes every render call sleep
until the video frame's target time, which is only meant for hosts with
no vsync of their own. With one player per output on a single thread,
that wait serialises every output onto the video's frame grid: with the
swap-interval fix in place, all outputs dropped to exactly the source
rate (24.0 fps for a 24fps file, every interval >25ms) instead of
presenting at the output's refresh.
Passing 0 lets mpv return whichever frame is due now, giving a normal
2:3 cadence for 24fps content on 60Hz outputs.
Same measurement as the previous commit, 5 outputs @60Hz:
swap interval fix only: 24.0 fps, p99 42ms
swap interval + this commit: 60.1 fps, p99 19ms, no gaps >25ms
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>