forge
Explore
Log in

Don't you dare go Hollow

niri: Add a check for target screencast time below last

Browse files at this commit

c9a79464da3245af944e692bb65db5b1f71d9ef7Ivan MolodetskikhParent: c082e2a
I've had this crash my session twice. Not sure what exactly happened.
src/niri.rsmodified+18 -6
@@ -1947,13 +1947,25 @@ impl Niri {
1947 1947
1948 let last = cast.last_frame_time;1948 let last = cast.last_frame_time;
1949 let min = cast.min_time_between_frames.get();1949 let min = cast.min_time_between_frames.get();
1950- if !last.is_zero() && target_presentation_time - last < min {1950+ if last.is_zero() {
1951- trace!(1951+ trace!(?target_presentation_time, ?last, "last is zero, recording");
1952- "skipping frame because it is too soon \1952+ } else if target_presentation_time < last {
1953- last={last:?} now={target_presentation_time:?} diff={:?} < min={min:?}",1953+ // Record frame with a warning; in case it was an overflow this will fix it.
1954- target_presentation_time - last,1954+ warn!(
1955+ ?target_presentation_time,
1956+ ?last,
1957+ "target presentation time is below last, did it overflow or did we mispredict?"
1955 );1958 );
1956- continue;1959+ } else {
1960+ let diff = target_presentation_time - last;
1961+ if diff < min {
1962+ trace!(
1963+ ?target_presentation_time,
1964+ ?last,
1965+ "skipping frame because it is too soon: diff={diff:?} < min={min:?}",
1966+ );
1967+ continue;
1968+ }
1957 }1969 }
1958 1970
1959 {1971 {