mpv on Wayland: vsync spikes and mistimed frames causing stutter
When I play a video on Gnome Wayland via mpv --video-sync=display-resample video.mpv
(it automatically picks Wayland backend), mistimed and delayed frames accumulate (occur together with vsync jitter spikes). It can happen with any video, but it seems to happen in a most "reliable" way when playing 59.94fps videos. This happens with my single display configured to both 59.95Hz and 75Hz. It might only happen once per minute, but it can also do so every few seconds. There comes visible stutter with this, e.g. easy to spot when watching judder test videos.
Sometimes also black flicker occurs together with the reported statistics anomalies. It's hard to spot, but I think this applies to the whole Mutter frame, not just the mpv window content.
The issue does not occur with Gnome Xorg, Plasma Wayland & Sway Wayland. Forcing maximum GPU and CPU clocks doesn't help either. Afair Gnome Wayland doesn't have presentation feedback yet, thus vsync jitter in general is higher than on Xorg. But it shouldn't stutter regardless.
This should be tested with an AMD GPU, as Intel seems to have their own additional issue with vsync jitter spikes on Wayland, independent of Gnome.
Tested with gnome-shell 1:3.34.1+56+gbb24df2f9-1 (Arch rolls it out in stable repo), linux 5.4.1, mesa 20-git, recent mpv-git. mpv shouldn't be older than 0.30 when trying to reproduce.