From c9a79464da3245af944e692bb65db5b1f71d9ef7 Mon Sep 17 00:00:00 2001 From: Ivan Molodetskikh Date: Fri, 24 Nov 2023 09:34:53 +0400 Subject: niri: Add a check for target screencast time below last I've had this crash my session twice. Not sure what exactly happened. --- src/niri.rs | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/niri.rs b/src/niri.rs index 4f588abf..b7b687ef 100644 --- a/src/niri.rs +++ b/src/niri.rs @@ -1947,13 +1947,25 @@ impl Niri { let last = cast.last_frame_time; let min = cast.min_time_between_frames.get(); - if !last.is_zero() && target_presentation_time - last < min { - trace!( - "skipping frame because it is too soon \ - last={last:?} now={target_presentation_time:?} diff={:?} < min={min:?}", - target_presentation_time - last, + if last.is_zero() { + trace!(?target_presentation_time, ?last, "last is zero, recording"); + } else if target_presentation_time < last { + // Record frame with a warning; in case it was an overflow this will fix it. + warn!( + ?target_presentation_time, + ?last, + "target presentation time is below last, did it overflow or did we mispredict?" ); - continue; + } else { + let diff = target_presentation_time - last; + if diff < min { + trace!( + ?target_presentation_time, + ?last, + "skipping frame because it is too soon: diff={diff:?} < min={min:?}", + ); + continue; + } } { -- cgit