Skip to content

clutter/frame-clock: Set the last "next presentation time" on feedback

Dor Askayo requested to merge doraskayo/mutter:last-next-presentation into main


This is essentially a "soft" requirement for VRR which makes frequent use of clutter_frame_clock_schedule_update_now()-like scheduling. VRR has its own scheduling algorithm that doesn't suffer from this issue, so it mostly affects frame scheduling when switching between variable and fixed scheduling. I'm proposing it here for general correctness.


From the commit message:

This removes an incorrect implicit assumption in
calculate_next_update_time_us() that a frame may only be scheduled
once in the duration of a refresh cycle. It accomplishes this by
setting last_next_presentation_time_us on presentation feedback
instead of calculating it every time an update is scheduled.

Specifically, it corrects the intended scheduling logic in scenarios
like the following, when all of the below occur in the context of a
single refresh cycle:
  1. Frame update (1) is scheduled normally, and
     "is_next_presentation_time_valid" is set to TRUE
  2. Frame update (1) is dispatched but ends up being "empty" (no
     presentation necessary)
  3. Frame update (2) is scheduled "now" and
     "is_next_presentation_time_valid" is set to FALSE
  4. Frame update (2) is dispatched but ends up being "empty" (no
     presentation necessary)
  5. Frame update (3) is scheduled normally, and since
     "is_next_presentation_time_valid" is set to FALSE, the
     "early presented event" logic is unintentionally skipped in
  6. Frame update (3) is dispatched and ends up being a "non-empty"
     update, but its update time was calculated incorrectly because
     some logic was skipped.

Scenarios such as this would become more common with the introduction
of variable refresh rate since it makes scheduling "now" a commonplace

CC: @daenzer, @jadahl

Edited by Dor Askayo

Merge request reports