From 83a566214e1dfcc3f01d99c4e15db15bbb33582d Mon Sep 17 00:00:00 2001 From: Ivan Molodetskikh Date: Wed, 12 Aug 2026 10:00:42 +0300 Subject: [PATCH] Update frame throttling time unconditionally Before, normal (unthrottled) frame callbacks didn't update the stored time, meaning that the throttled frame callbacks were firing unconditionally on their timer, even if the surface was otherwise continously receiving frame callbacks. --- src/desktop/wayland/utils.rs | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/src/desktop/wayland/utils.rs b/src/desktop/wayland/utils.rs index e92a81ecac5e..7ee5a12e79a1 100644 --- a/src/desktop/wayland/utils.rs +++ b/src/desktop/wayland/utils.rs @@ -242,7 +242,7 @@ pub fn send_frames_surface_tree( .map(|preferred_output| preferred_output == *output) .unwrap_or(false); - let frame_overdue = surface_frame_throttling_state.update(time, throttle); + let frame_overdue = surface_frame_throttling_state.is_overdue(time, throttle); // We only want to send frame callbacks on the primary scan-out output // or if we have no output and the frame is overdue, this can only @@ -250,6 +250,8 @@ pub fn send_frames_surface_tree( let send_frame_callback = on_primary_scanout_output || frame_overdue; if send_frame_callback { + surface_frame_throttling_state.update_last_sent(time); + // the surface may not have any user_data if it is a subsurface and has not // yet been committed for callback in states @@ -490,18 +492,18 @@ pub fn surface_presentation_feedback_flags_from_states( struct SurfaceFrameThrottlingState(Mutex>); impl SurfaceFrameThrottlingState { - pub fn update(&self, time: Duration, throttle: Option) -> bool { + pub fn is_overdue(&self, time: Duration, throttle: Option) -> bool { if let Some(throttle) = throttle { - let mut guard = self.0.lock().unwrap(); - let send_throttled_frame = guard + let guard = self.0.lock().unwrap(); + guard .map(|last| time.saturating_sub(last) > throttle) - .unwrap_or(true); - if send_throttled_frame { - *guard = Some(time); - } - send_throttled_frame + .unwrap_or(true) } else { false } } + + pub fn update_last_sent(&self, time: Duration) { + *self.0.lock().unwrap() = Some(time); + } }