Skip to content

clutter/frame-clock: Advance timelines according to presentation time

Daniel van Vugt requested to merge vanvugt/mutter:smoother-timelines-42 into main

This ensures they remain perfectly smooth regardless of how the dispatch time has been adjusted/optimized/delayed/jittered.

Idea by Ivan Molodetskikh yalterz@gmail.com

For example, dragging a window on a 60Hz monitor:

BEFORE

delta(time_us) = 17014μs
delta(time_us) = 15998μs
delta(time_us) = 17006μs
delta(time_us) = 16975μs
delta(time_us) = 16001μs
delta(time_us) = 17002μs
delta(time_us) = 17006μs
delta(time_us) = 16004μs

AFTER

delta(time_us) = 16667μs
delta(time_us) = 16667μs
delta(time_us) = 16670μs
delta(time_us) = 16667μs
delta(time_us) = 16669μs
delta(time_us) = 16668μs
delta(time_us) = 16664μs
delta(time_us) = 16674μs

Caveat 1: Because we don't know a "next presentation time" on the first frame, the interval between the first and second frame will usually be different to the subsequent steady interval. So this change increases the jitter of just frame 2, but eliminates jitter thereafter.

Caveat 2: clutter_frame_clock_schedule_update_now schedules updates earlier than clutter_frame_clock_schedule_update. This means potentially you could get multiple frames targeting the same "next presentation time". That doesn't really change here though - we're dispatching at the same times as we used to and just giving timelines a better vsync-aligned timestamp now.

Closes: #25 (closed)

Edited by Daniel van Vugt

Merge request reports