From 3fb00f6c70e2f575357c5812222442c79dead755 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Fri, 28 Jun 2019 18:26:11 +0530 Subject: [PATCH] Re-request render frames if we dont hear back in a quarter of a second Fixes #1748 (I hope) --- kitty/child-monitor.c | 7 ++++++- kitty/glfw.c | 2 ++ kitty/state.h | 1 + 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/kitty/child-monitor.c b/kitty/child-monitor.c index ae40c68b9..9ff7e253a 100644 --- a/kitty/child-monitor.c +++ b/kitty/child-monitor.c @@ -675,6 +675,11 @@ draw_resizing_text(OSWindow *w) { } } +static inline bool +no_render_frame_received_recently(OSWindow *w, double now) { + return now - w->last_render_frame_received_at > 0.25; +} + static inline void render(double now) { double time_since_last_render = now - last_render_at; @@ -691,7 +696,7 @@ render(double now) { continue; } if (USE_RENDER_FRAMES && w->render_state != RENDER_FRAME_READY) { - if (w->render_state == RENDER_FRAME_NOT_REQUESTED) request_frame_render(w); + if (w->render_state == RENDER_FRAME_NOT_REQUESTED || no_render_frame_received_recently(w, now)) request_frame_render(w); continue; } make_os_window_context_current(w); diff --git a/kitty/glfw.c b/kitty/glfw.c index 8dbf48529..ed80857cd 100644 --- a/kitty/glfw.c +++ b/kitty/glfw.c @@ -1052,6 +1052,7 @@ cocoa_frame_request_callback(GLFWwindow *window) { for (size_t i = 0; i < global_state.num_os_windows; i++) { if (global_state.os_windows[i].handle == window) { global_state.os_windows[i].render_state = RENDER_FRAME_READY; + global_state.os_windows[i].last_render_frame_received_at = monotonic(); request_tick_callback(); break; } @@ -1071,6 +1072,7 @@ wayland_frame_request_callback(id_type os_window_id) { for (size_t i = 0; i < global_state.num_os_windows; i++) { if (global_state.os_windows[i].id == os_window_id) { global_state.os_windows[i].render_state = RENDER_FRAME_READY; + global_state.os_windows[i].last_render_frame_received_at = monotonic(); request_tick_callback(); break; } diff --git a/kitty/state.h b/kitty/state.h index 30e3a481e..617fc36c6 100644 --- a/kitty/state.h +++ b/kitty/state.h @@ -148,6 +148,7 @@ typedef struct { id_type temp_font_group_id; double pending_scroll_pixels; enum RENDER_STATE render_state; + double last_render_frame_received_at; id_type last_focused_counter; ssize_t gvao_idx; } OSWindow;