1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 14:17:36 +00:00

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.
This commit is contained in:
Andreas Kling 2021-10-18 10:25:13 +02:00
parent f9e814826f
commit f72a37b9d4
2 changed files with 9 additions and 1 deletions

View file

@ -207,6 +207,11 @@ void OutOfProcessWebView::notify_server_did_paint(Badge<WebContentClient>, i32 b
// We don't need the backup bitmap anymore, so drop it. // We don't need the backup bitmap anymore, so drop it.
m_backup_bitmap = nullptr; m_backup_bitmap = nullptr;
update(); 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) if (!m_client_state.back_bitmap.bitmap)
return; return;
// Don't request a repaint until pending paint requests have finished. // 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; return;
}
m_client_state.back_bitmap.pending_paints++; 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); client().async_paint(m_client_state.back_bitmap.bitmap->rect().translated(horizontal_scrollbar().value(), vertical_scrollbar().value()), m_client_state.back_bitmap.id);
} }

View file

@ -125,6 +125,7 @@ private:
SharedBitmap back_bitmap; SharedBitmap back_bitmap;
i32 next_bitmap_id { 0 }; i32 next_bitmap_id { 0 };
bool has_usable_bitmap { false }; bool has_usable_bitmap { false };
bool got_repaint_requests_while_painting { false };
} m_client_state; } m_client_state;
RefPtr<Gfx::Bitmap> m_backup_bitmap; RefPtr<Gfx::Bitmap> m_backup_bitmap;