core: don't fully trust msc from present complete notify

Sometimes X sends bogus complete notifies with invalid msc number.
Instead use a saved msc number to get the next complete notify.

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
This commit is contained in:
Yuxuan Shui 2022-12-17 19:27:40 +00:00
parent 189de51018
commit 9ee297d766
No known key found for this signature in database
GPG Key ID: D3A4405BE6CC17F4
1 changed files with 13 additions and 7 deletions

View File

@ -1540,17 +1540,23 @@ handle_present_complete_notify(session_t *ps, xcb_present_complete_notify_event_
return;
}
bool event_is_invalid = false;
if (ps->frame_pacing) {
auto next_msc = cne->msc + 1;
if (cne->msc <= ps->last_msc || cne->ust == 0) {
// X sometimes sends duplicate/bogus MSC events, don't
// use the msc value. Also ignore these events.
//
// See:
// https://gitlab.freedesktop.org/xorg/xserver/-/issues/1418
next_msc = ps->last_msc + 1;
event_is_invalid = true;
}
auto cookie = xcb_present_notify_msc(ps->c, session_get_target_window(ps),
0, cne->msc + 1, 0, 0);
0, next_msc, 0, 0);
set_cant_fail_cookie(ps, cookie);
}
if (cne->msc <= ps->last_msc || cne->ust == 0) {
// X sometimes sends duplicate/bogus MSC events, ignore them
//
// See:
// https://gitlab.freedesktop.org/xorg/xserver/-/issues/1418
if (event_is_invalid) {
return;
}