mirror of
https://github.com/yshui/picom.git
synced 2024-11-11 13:51:02 -05:00
core: only check present timer alignment in the first frame
Timer can sometimes drift randomly, like when the system is suspended. we don't want to disable frame pacing for that Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
This commit is contained in:
parent
e0e5c1e9e6
commit
189de51018
1 changed files with 9 additions and 10 deletions
19
src/picom.c
19
src/picom.c
|
@ -1569,22 +1569,21 @@ handle_present_complete_notify(session_t *ps, xcb_present_complete_notify_event_
|
||||||
int frame_time = (int)((cne->ust - ps->last_msc_instant) / frame_count);
|
int frame_time = (int)((cne->ust - ps->last_msc_instant) / frame_count);
|
||||||
rolling_avg_push(ps->frame_time, frame_time);
|
rolling_avg_push(ps->frame_time, frame_time);
|
||||||
log_trace("Frame count %lu, frame time: %d us, rolling average: %lf us, "
|
log_trace("Frame count %lu, frame time: %d us, rolling average: %lf us, "
|
||||||
"msc: %" PRIu64 ", offset: %" PRIu64,
|
"msc: %" PRIu64 ", offset: %d us",
|
||||||
frame_count, frame_time, rolling_avg_get_avg(ps->frame_time),
|
frame_count, frame_time, rolling_avg_get_avg(ps->frame_time),
|
||||||
cne->ust, drift);
|
cne->ust, (int)drift);
|
||||||
}
|
} else if (drift > 1000000 && ps->frame_pacing) {
|
||||||
ps->last_msc_instant = cne->ust;
|
// This is the first MSC event we receive, let's check if the timestamps
|
||||||
ps->last_msc = cne->msc;
|
// align with the monotonic clock. If not, disable frame pacing because we
|
||||||
if (drift > 1000000 && ps->frame_pacing) {
|
// can't schedule frames reliably.
|
||||||
log_error("Temporal anomaly detected, frame pacing disabled. (Are we "
|
log_error("Temporal anomaly detected, frame pacing disabled. (Are we "
|
||||||
"running inside a time namespace?), %" PRIu64 " %" PRIu64,
|
"running inside a time namespace?), %" PRIu64 " %" PRIu64,
|
||||||
now_usec, ps->last_msc_instant);
|
now_usec, ps->last_msc_instant);
|
||||||
ps->frame_pacing = false;
|
ps->frame_pacing = false;
|
||||||
// We could have deferred a frame in queue_redraw() because of frame
|
|
||||||
// pacing. Unconditionally queue a frame for simplicity.
|
|
||||||
queue_redraw(ps);
|
|
||||||
}
|
}
|
||||||
if (ps->frame_pacing && ps->redraw_needed) {
|
ps->last_msc_instant = cne->ust;
|
||||||
|
ps->last_msc = cne->msc;
|
||||||
|
if (ps->redraw_needed) {
|
||||||
schedule_render(ps);
|
schedule_render(ps);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue