Skip to content

Truly independent web browser

UI/Qt: Drop the Wayland buffers of retired stores while hidden

Aliaksandr Kalenike3fd951bae29
diff --git a/UI/Qt/RemoteView.h b/UI/Qt/RemoteView.h
index 06707cef17f..20efdde882d 100644
--- a/UI/Qt/RemoteView.h
+++ b/UI/Qt/RemoteView.h
@@ -246,7 +246,11 @@ public:
if (auto result = m_backing_stores.add(move(bitmap_ids), move(backing_stores)); result.is_error())
warnln("Could not add backing stores: {}", result.error());
}
- void did_retire_backing_stores(ReadonlySpan<i32> bitmap_ids) { m_backing_stores.retire(bitmap_ids); }
+ void did_retire_backing_stores(ReadonlySpan<i32> bitmap_ids)
+ {
+ m_backing_stores.retire(bitmap_ids);
+ backing_stores_were_retired();
+ }
void did_present_backing_store(u64 page_id, i32 bitmap_id, Gfx::IntSize, double device_pixel_ratio);
void did_accept_backing_store(i32 bitmap_id, Gfx::IntRect damage_rect);
void did_keep_front_backing_store_as_backup() { m_backing_stores.keep_front_as_backup(); }
@@ -267,6 +271,7 @@ protected:
// The handle's kind is None when the view has no remote layer, and goes on showing backing stores.
virtual void remote_layer_changed(Compositing::RemoteLayerHostHandle) { }
virtual void release_backing_store(u64 page_id, i32 bitmap_id) { release_backing_store_to_page(page_id, bitmap_id); }
+ virtual void backing_stores_were_retired() { }
void set_page_background_color_to_system_canvas(bool dark) { HubConnection::the().async_view_set_page_background_color_to_system_canvas(view_id(), dark); }
void set_device_pixel_ratio_and_viewport(double device_pixel_ratio, Web::DevicePixelSize);
diff --git a/UI/Qt/WebContentView.h b/UI/Qt/WebContentView.h
index 7181fc40b30..fe7d3cef8da 100644
--- a/UI/Qt/WebContentView.h
+++ b/UI/Qt/WebContentView.h
@@ -477,6 +477,8 @@ private:
virtual void release_backing_store(u64 page_id, i32 bitmap_id) override;
# ifdef LADYBIRD_HAS_WAYLAND_GPU_QUERY
+ virtual void backing_stores_were_retired() override;
+
bool create_page_surface();
enum class PageSurfaceContent {
Unchanged,
diff --git a/UI/Qt/WebContentViewLinux.cpp b/UI/Qt/WebContentViewLinux.cpp
index b40de9df7a3..672d9e37327 100644
--- a/UI/Qt/WebContentViewLinux.cpp
+++ b/UI/Qt/WebContentViewLinux.cpp
@@ -1305,6 +1305,14 @@ bool WebContentView::page_surface_can_show_frames() const
return !scales_frames_to_fit() || !has_hover_expanded_chrome;
}
+void WebContentView::backing_stores_were_retired()
+{
+ // NB: A hidden view presents nothing, which is when the page surface would let go of the buffers of retired backing
+ // stores, so their dma-bufs would stay with the compositor of the desktop until the view is shown again.
+ if (m_page_surface)
+ m_page_surface->forget_buffers_except(backing_stores().shared_image_buffers());
+}
+
void WebContentView::hide_page_surface()
{
// NB: Qt paints the page from here on, and shows it once the browser window commits. The page surface stays on