forge
Explore
Log in

Don't you dare go Hollow

frame_clock: Defend against last presentation time being too much in the future

Browse files at this commit

cc259f9a34974dcef4d126dfd3277e0a8c9a180cIvan MolodetskikhParent: 3602876
src/frame_clock.rsmodified+12 -1
@@ -52,8 +52,19 @@ impl FrameClock {
52 52
53 if now <= last_presentation_time {53 if now <= last_presentation_time {
54 // Got an early VBlank.54 // Got an early VBlank.
55+ let orig_now = now;
55 now += Duration::from_nanos(refresh_interval_ns);56 now += Duration::from_nanos(refresh_interval_ns);
56- // Assume two-frame early VBlanks don't happen. Overflow checks will catch them.57+
58+ if now < last_presentation_time {
59+ // Not sure when this can happen.
60+ error!(
61+ now = ?orig_now,
62+ ?last_presentation_time,
63+ "got a 2+ early VBlank, {:?} until presentation",
64+ last_presentation_time - now,
65+ );
66+ now = last_presentation_time + Duration::from_nanos(refresh_interval_ns);
67+ }
57 }68 }
58 69
59 let since_last = now - last_presentation_time;70 let since_last = now - last_presentation_time;