From f72a37b9d41b541efa2e2dcaab18e183557d2e68 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Mon, 18 Oct 2021 10:25:13 +0200 Subject: [PATCH] LibWeb: Coalesce nested repaint requests instead of swallowing them Previously we would ignore repaint requests that came in via OOPWV while the WebContent process was busy with a previous paint request. This caused some easy-to-trigger bugs where the painted content would be "one paint behind", especially noticeable when scrolling. --- Userland/Libraries/LibWeb/OutOfProcessWebView.cpp | 9 ++++++++- Userland/Libraries/LibWeb/OutOfProcessWebView.h | 1 + 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/Userland/Libraries/LibWeb/OutOfProcessWebView.cpp b/Userland/Libraries/LibWeb/OutOfProcessWebView.cpp index 49f24646b8..48a5b16243 100644 --- a/Userland/Libraries/LibWeb/OutOfProcessWebView.cpp +++ b/Userland/Libraries/LibWeb/OutOfProcessWebView.cpp @@ -207,6 +207,11 @@ void OutOfProcessWebView::notify_server_did_paint(Badge, i32 b // We don't need the backup bitmap anymore, so drop it. m_backup_bitmap = nullptr; update(); + + if (m_client_state.got_repaint_requests_while_painting) { + m_client_state.got_repaint_requests_while_painting = false; + request_repaint(); + } } } @@ -399,8 +404,10 @@ void OutOfProcessWebView::request_repaint() if (!m_client_state.back_bitmap.bitmap) return; // Don't request a repaint until pending paint requests have finished. - if (m_client_state.back_bitmap.pending_paints) + if (m_client_state.back_bitmap.pending_paints) { + m_client_state.got_repaint_requests_while_painting = true; return; + } m_client_state.back_bitmap.pending_paints++; client().async_paint(m_client_state.back_bitmap.bitmap->rect().translated(horizontal_scrollbar().value(), vertical_scrollbar().value()), m_client_state.back_bitmap.id); } diff --git a/Userland/Libraries/LibWeb/OutOfProcessWebView.h b/Userland/Libraries/LibWeb/OutOfProcessWebView.h index 7d812a2ecf..818edb2bdf 100644 --- a/Userland/Libraries/LibWeb/OutOfProcessWebView.h +++ b/Userland/Libraries/LibWeb/OutOfProcessWebView.h @@ -125,6 +125,7 @@ private: SharedBitmap back_bitmap; i32 next_bitmap_id { 0 }; bool has_usable_bitmap { false }; + bool got_repaint_requests_while_painting { false }; } m_client_state; RefPtr m_backup_bitmap;