From efc44d05ff199e39de92e646c1a8edbd9e20c602 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kacper=20Michaj=C5=82ow?= Date: Mon, 15 Dec 2025 02:10:23 +0100 Subject: [PATCH] vo: trigger manual redraws at most at slightly over display fps This is workaround for some windowing platforms that break when they get too many present requests. Fixes: #17082 --- video/out/vo.c | 13 +++++++++++-- video/out/vo.h | 1 + 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/video/out/vo.c b/video/out/vo.c index 884a7a3cab..c9cde30478 100644 --- a/video/out/vo.c +++ b/video/out/vo.c @@ -1182,8 +1182,17 @@ static MP_THREAD_VOID vo_thread(void *ptr) if (send_pause) vo->driver->control(vo, vo_paused ? VOCTRL_PAUSE : VOCTRL_RESUME, NULL); if (wait_until > now && redraw) { - vo->driver->control(vo, VOCTRL_REDRAW, NULL); - do_redraw(vo); // now is a good time + // Allow manual redraws at most at slightly over display fps. + int64_t max_interval = (MP_TIME_S_TO_NS(1) / MPMAX(in->display_fps, 10)) / 1.1; + // Some windowing platforms break if we submit frames too fast. + if (vo->previous_redraw_time + max_interval <= now) { + vo->driver->control(vo, VOCTRL_REDRAW, NULL); + do_redraw(vo); // now is a good time + vo->previous_redraw_time = now; + } else { + in->request_redraw = true; + wait_vo(vo, now + max_interval); + } continue; } if (vo->want_redraw) // might have been set by VOCTRLs diff --git a/video/out/vo.h b/video/out/vo.h index 07d756fa19..160d86042b 100644 --- a/video/out/vo.h +++ b/video/out/vo.h @@ -508,6 +508,7 @@ struct vo { struct mp_vo_opts *opts; bool want_redraw; // redraw as soon as possible + int64_t previous_redraw_time; // current window state int dwidth;