From be0aa2976e19f4a6b91bd90ce3942d6b107af7c0 Mon Sep 17 00:00:00 2001 From: Daniel van Vugt Date: Wed, 14 Jun 2023 19:49:29 +0800 Subject: [PATCH] clutter/frame-clock: Avoid rapidly toggling dynamic max render time This could happen when moving the cursor over GUIs that only redraw in response to cursor movement. Mutter would experience alternating cursor-only updates and page flips, and so the `max_render_time_allowed_us` would jump between pessimised and optimised resulting in inconsistent frame pacing. Aside from fixing the smoothness problem this should also provide lower latency cursor movement. Fixes: https://launchpad.net/bugs/2023766 Part-of: --- clutter/clutter/clutter-frame-clock.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/clutter/clutter/clutter-frame-clock.c b/clutter/clutter/clutter-frame-clock.c index 3aeb29042..0ddda800d 100644 --- a/clutter/clutter/clutter-frame-clock.c +++ b/clutter/clutter/clutter-frame-clock.c @@ -105,6 +105,7 @@ struct _ClutterFrameClock /* If we got new measurements last frame. */ gboolean got_measurements_last_frame; + gboolean ever_got_measurements; gboolean pending_reschedule; gboolean pending_reschedule_now; @@ -349,6 +350,7 @@ clutter_frame_clock_notify_presented (ClutterFrameClock *frame_clock, MAX (frame_clock->shortterm.max_swap_to_flip_us, swap_to_flip_us); frame_clock->got_measurements_last_frame = TRUE; + frame_clock->ever_got_measurements = TRUE; } else { @@ -423,7 +425,7 @@ clutter_frame_clock_compute_max_render_time_us (ClutterFrameClock *frame_clock) refresh_interval_us = frame_clock->refresh_interval_us; - if (!frame_clock->got_measurements_last_frame || + if (!frame_clock->ever_got_measurements || G_UNLIKELY (clutter_paint_debug_flags & CLUTTER_DEBUG_DISABLE_DYNAMIC_MAX_RENDER_TIME)) return refresh_interval_us * SYNC_DELAY_FALLBACK_FRACTION;