1
0
Fork 0
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:
Yuxuan Shui 2022-12-16 08:53:08 +00:00
parent e0e5c1e9e6
commit 189de51018
No known key found for this signature in database
GPG key ID: D3A4405BE6CC17F4

View file

@ -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);
} }
} }