Truly independent web browser
LibWeb+Compositor: Wait for remote frames in screenshots
sideshowbarker82e8a4453c37
diff --git a/Libraries/LibWeb/Compositor/CompositorConnection.cpp b/Libraries/LibWeb/Compositor/CompositorConnection.cppindex 26bbe47f99b..ed2425def82 100644--- a/Libraries/LibWeb/Compositor/CompositorConnection.cpp+++ b/Libraries/LibWeb/Compositor/CompositorConnection.cpp@@ -20,6 +20,8 @@#include <LibIPC/TransportHandle.h>#include <LibMediaClient/Client.h>#include <LibWeb/Compositor/RenderClock.h>+#include <LibWeb/DOM/Document.h>+#include <LibWeb/HTML/EventLoop/EventLoop.h>#include <LibWeb/HTML/HTMLCanvasElement.h>#include <LibWeb/HTML/LocalNavigable.h>#include <LibWeb/Page/EventHandler.h>@@ -951,6 +953,52 @@ void CompositorConnection::placeholder_canvas_committed(Compositing::CanvasId caWeb::HTML::HTMLCanvasElement::placeholder_frame_committed(canvas_id, size, origin_clean);}+void CompositorConnection::prepare_remote_descendants_for_screenshot(Web::CompositorContextId context_id, Function<void()>&& callback)+{+ if (!can_send_message_to_compositor()) {+ callback();+ return;+ }+ auto request_id = m_next_remote_descendant_preparation_id++;+ m_remote_descendant_preparations.set(request_id, move(callback));+ async_prepare_remote_descendants_for_screenshot(context_id, request_id);+}++void CompositorConnection::remote_descendants_prepared_for_screenshot(u64 request_id)+{+ if (auto callback = m_remote_descendant_preparations.take(request_id); callback.has_value())+ (*callback)();+}++void CompositorConnection::paint_contexts_for_screenshot(u64 preparation_id, Vector<Web::CompositorContextId> context_ids)+{+ // The compositor names a context before those below it, and each is painted after them, as a rendering update would.+ GC::RootVector<GC::Ref<Web::HTML::LocalNavigable>> navigables;+ for (auto context_id : context_ids.in_reverse()) {+ for (auto& navigable : Web::HTML::all_local_navigables()) {+ if (navigable->has_been_destroyed() || !navigable->has_compositor_context() || navigable->compositor_context().id() != context_id)+ continue;+ navigables.append(navigable);+ break;+ }+ }+ GC::RootVector<GC::Ref<Web::Page>> prepared_pages;+ for (auto& navigable : navigables) {+ if (any_of(prepared_pages, [&](auto const& page) { return page.ptr() == &navigable->page(); }))+ continue;+ prepared_pages.append(navigable->page());+ navigable->page().prepare_canvas_contexts_for_compositing();+ }+ // A document that has just loaded may not have painted since, and the screenshot would show the frame it painted+ // before, so paint each one.+ for (auto& navigable : navigables)+ navigable->paint_next_frame_if_needed(Web::DOM::UpdateLayoutReason::ProcessScreenshot);+ // The frames reach the compositor on this connection once the Paint thread has handed them over, ahead of the+ // answer.+ Web::HTML::main_thread_event_loop().take_committed_frames_in();+ async_did_paint_contexts_for_screenshot(preparation_id);+}+void CompositorConnection::did_complete_screenshot(Compositing::ScreenshotRequestId request_id){auto pending_screenshot = take_screenshot(request_id);@@ -984,6 +1032,10 @@ void CompositorConnection::did_lose_compositor()}m_screenshots.clear();+ // Nothing will answer the preparations now, and a screenshot that waits for one goes on without a compositor.+ for (auto& entry : exchange(m_remote_descendant_preparations, {}))+ entry.value();+if (on_compositor_lost)on_compositor_lost();}diff --git a/Libraries/LibWeb/Compositor/CompositorConnection.h b/Libraries/LibWeb/Compositor/CompositorConnection.hindex 9cd7f9c99fa..9743ea10472 100644--- a/Libraries/LibWeb/Compositor/CompositorConnection.h+++ b/Libraries/LibWeb/Compositor/CompositorConnection.h@@ -83,6 +83,9 @@ public:bool request_rendering_opportunity(Web::CompositorContextId, double maximum_frames_per_second);void hurry_rendering_opportunity(Web::CompositorContextId);void request_screenshot(Web::CompositorContextId, NonnullRefPtr<Gfx::Bitmap>, Function<void(ScreenshotResult)>&&);+ // Has the processes that own the context's descendants in other processes paint them, and calls `callback` once the+ // compositor has their frames, or once it is lost.+ void prepare_remote_descendants_for_screenshot(Web::CompositorContextId, Function<void()>&& callback);Optional<Compositing::CanvasId> create_webgl_context(Compositing::WebGL::WebGLVersion, Gfx::IntSize, bool depth, bool stencil, bool antialias, Vector<String>& out_supported_extensions);void set_webgl_command_buffer(Compositing::CanvasId, Core::AnonymousBuffer const&);@@ -125,6 +128,8 @@ private:virtual void animated_content_moved_under_pointer(Web::CompositorContextId, i64 frame_time_nanoseconds) override;virtual void did_complete_screenshot(Compositing::ScreenshotRequestId) override;virtual void did_fail_screenshot(Compositing::ScreenshotRequestId) override;+ virtual void paint_contexts_for_screenshot(u64 preparation_id, Vector<Web::CompositorContextId>) override;+ virtual void remote_descendants_prepared_for_screenshot(u64 request_id) override;virtual void did_lose_compositor() override;virtual void placeholder_canvas_committed(Compositing::CanvasId, Gfx::IntSize, bool origin_clean) override;virtual void overlay_scrollbar_visibilities_changed(Vector<Web::OverlayScrollbarVisibility>) override;@@ -140,6 +145,8 @@ private:HashTable<Compositing::FontResourceId> m_canvas_font_ids_held_by_compositor;HashMap<Compositing::ScreenshotRequestId, PendingScreenshot> m_screenshots;+ HashMap<u64, Function<void()>> m_remote_descendant_preparations;+ u64 m_next_remote_descendant_preparation_id { 1 };// What the compositor process scrolled since the last rendering update adopted it, per context.HashMap<Web::CompositorContextId, Compositing::PendingAsyncScrollUpdates> m_pending_async_scroll_updates;u64 m_next_screenshot_request_id { 1 };diff --git a/Libraries/LibWeb/Compositor/CompositorHost.cpp b/Libraries/LibWeb/Compositor/CompositorHost.cppindex ff2b9cd6637..f6661c480fa 100644--- a/Libraries/LibWeb/Compositor/CompositorHost.cpp+++ b/Libraries/LibWeb/Compositor/CompositorHost.cpp@@ -132,6 +132,11 @@ void CompositorContextHandle::request_screenshot(NonnullRefPtr<Gfx::Bitmap> targm_host.request_screenshot(m_context_id, move(target_bitmap), move(callback));}+void CompositorContextHandle::prepare_remote_descendants_for_screenshot(Function<void()>&& callback)+{+ m_host.prepare_remote_descendants_for_screenshot(m_context_id, move(callback));+}+CompositorHost::CompositorHost(): m_canvas_2d_stream(adopt_ref(*new Compositing::Canvas2DCommandStream())){@@ -606,6 +611,15 @@ void CompositorHost::hurry_rendering_opportunity(Web::CompositorContextId contexconnection->hurry_rendering_opportunity(context_id);}+void CompositorHost::prepare_remote_descendants_for_screenshot(Web::CompositorContextId context_id, Function<void()>&& callback)+{+ if (auto* connection = compositor_connection()) {+ connection->prepare_remote_descendants_for_screenshot(context_id, move(callback));+ return;+ }+ callback();+}+void CompositorHost::request_screenshot(Web::CompositorContextId context_id, NonnullRefPtr<Gfx::Bitmap> target_bitmap, Function<void(ScreenshotResult)>&& callback){if (auto* connection = compositor_connection()) {diff --git a/Libraries/LibWeb/Compositor/CompositorHost.h b/Libraries/LibWeb/Compositor/CompositorHost.hindex de8dea7b887..835dea53ef2 100644--- a/Libraries/LibWeb/Compositor/CompositorHost.h+++ b/Libraries/LibWeb/Compositor/CompositorHost.h@@ -101,6 +101,7 @@ public:bool request_rendering_opportunity(double maximum_frames_per_second);void hurry_rendering_opportunity();void request_screenshot(NonnullRefPtr<Gfx::Bitmap>, Function<void(ScreenshotResult)>&& callback);+ void prepare_remote_descendants_for_screenshot(Function<void()>&& callback);// Sends the canvas commands a frame may sample ahead of it, and answers whether the compositor can be reached.bool ready_for_frame();@@ -173,6 +174,7 @@ public:bool request_rendering_opportunity(Web::CompositorContextId, double maximum_frames_per_second);void hurry_rendering_opportunity(Web::CompositorContextId);void request_screenshot(Web::CompositorContextId, NonnullRefPtr<Gfx::Bitmap>, Function<void(ScreenshotResult)>&& callback);+ void prepare_remote_descendants_for_screenshot(Web::CompositorContextId, Function<void()>&& callback);protected:CompositorHost();diff --git a/Libraries/LibWeb/HTML/LocalNavigable.cpp b/Libraries/LibWeb/HTML/LocalNavigable.cppindex 65cd2d21ed7..73dd4a07cda 100644--- a/Libraries/LibWeb/HTML/LocalNavigable.cpp+++ b/Libraries/LibWeb/HTML/LocalNavigable.cpp@@ -7398,9 +7398,30 @@ void LocalNavigable::render_screenshot(NonnullRefPtr<Gfx::Bitmap> target, PaintCreturn;}+ // The compositor composes the display lists that the processes hosting the subtree's remote descendants last+ // published as well, so it has those processes paint their documents first, as this process does its own below.+ auto has_remote_descendant = any_of(active_document_inclusive_descendant_navigables(), [](auto const& navigable) {+ return is<RemoteNavigable>(*navigable);+ });+ if (!has_remote_descendant) {+ render_screenshot_of_painted_subtree(move(target), paint_config, move(callback));+ return;+ }+ compositor_context().prepare_remote_descendants_for_screenshot([weak_this = GC::Weak { *this }, target = move(target), paint_config, callback = move(callback)]() mutable {+ if (!weak_this || weak_this->has_been_destroyed() || !weak_this->has_compositor_context()) {+ callback(Compositor::ScreenshotResult::Failed);+ return;+ }+ weak_this->render_screenshot_of_painted_subtree(move(target), paint_config, move(callback));+ });+}++void LocalNavigable::render_screenshot_of_painted_subtree(NonnullRefPtr<Gfx::Bitmap> target, PaintConfig paint_config, Function<void(Compositor::ScreenshotResult)>&& callback)+{// The compositor composes the display lists this process last published for the navigables of the subtree. A// descendant that has not painted since it changed, such as one whose document has just loaded, would be missing- // from the screenshot, so paint it first as the rendering update would.+ // from the screenshot, so paint it first as the rendering update would, after preparing the canvases.+ page().prepare_canvas_contexts_for_compositing();auto navigables = hosted_inclusive_descendant_navigables();for (auto& navigable : navigables.in_reverse()) {if (navigable.ptr() != this)diff --git a/Libraries/LibWeb/HTML/LocalNavigable.h b/Libraries/LibWeb/HTML/LocalNavigable.hindex 523819ca921..8e05be812ab 100644--- a/Libraries/LibWeb/HTML/LocalNavigable.h+++ b/Libraries/LibWeb/HTML/LocalNavigable.h@@ -459,6 +459,7 @@ protected:Variant<Empty, Traversal, Utf16String> m_ongoing_navigation;private:+ void render_screenshot_of_painted_subtree(NonnullRefPtr<Gfx::Bitmap> target, PaintConfig, Function<void(Compositor::ScreenshotResult)>&& callback);void record_rendering_invalidation();// A rendering update's recording that flies beside the event loop, with what its frame is finished with.diff --git a/Services/Compositor/CompositorState.cpp b/Services/Compositor/CompositorState.cppindex 7c747c5f853..8b3fc3e419b 100644--- a/Services/Compositor/CompositorState.cpp+++ b/Services/Compositor/CompositorState.cpp@@ -388,7 +388,19 @@ void CompositorState::destroy_contexts_for_web_content_client(CompositorStateWebm_canvas_surface_registry.remove_canvas_surface(canvas_id);return true;});++ // A process that goes away paints nothing more, and is told of nothing.+ m_screenshot_preparations.remove_all_matching([&](auto, auto const& preparation) {+ return preparation.requester == client.web_content_client_id();+ });+ Vector<u64> preparations_awaiting_client;+ for (auto& [preparation_id, preparation] : m_screenshot_preparations) {+ if (preparation.awaited_painters.remove(client.web_content_client_id()))+ preparations_awaiting_client.append(preparation_id);+ }m_web_content_clients.remove(client.web_content_client_id());+ for (auto preparation_id : preparations_awaiting_client)+ finish_screenshot_preparation_if_done(preparation_id);}CompositorState::PlaceholderCanvasAllocation CompositorState::allocate_placeholder_canvas(CompositorStateWebContentClient& client)@@ -1464,6 +1476,92 @@ bool CompositorState::request_screenshot(Web::CompositorContextId context_id, Gfreturn true;}+// How long a screenshot waits for the processes that paint its context's descendants. One whose script never yields+// keeps its connection open without answering, and the screenshot then goes ahead with the frames it last handed over.+static constexpr auto SCREENSHOT_PREPARATION_LIMIT = AK::Duration::from_seconds(10);++void CompositorState::prepare_remote_descendants_for_screenshot(CompositorStateWebContentClient& requester, Web::CompositorContextId context_id, u64 request_id)+{+ HashMap<Web::CompositorContextId, Vector<Web::CompositorContextId>> children;+ for (auto const& [child_id, child] : m_presented_contexts) {+ if (child->parent_context_id.has_value())+ children.ensure(*child->parent_context_id).append(child_id);+ }++ // From the first context of a branch that another process owns on down, each process paints the contexts it owns+ // there, the requester's included. Above that point, the requester paints its own as it takes the screenshot.+ HashMap<WebContentClientId, Vector<Web::CompositorContextId>> contexts_by_painter;+ HashTable<Web::CompositorContextId> visited;+ Vector<Web::CompositorContextId> to_visit { context_id };+ HashTable<Web::CompositorContextId> below_another_process;+ while (!to_visit.is_empty()) {+ auto id = to_visit.take_last();+ if (visited.set(id) != HashSetResult::InsertedNewEntry)+ continue;+ auto context = m_presented_contexts.get(id);+ if (!context.has_value())+ continue;+ auto owner = (*context)->web_content_client.web_content_client_id();+ bool painted_by_owner = below_another_process.contains(id) || owner != requester.web_content_client_id();+ if (painted_by_owner)+ contexts_by_painter.ensure(owner).append(id);+ auto child_ids = children.find(id);+ if (child_ids == children.end())+ continue;+ for (auto child_id : child_ids->value) {+ if (painted_by_owner)+ below_another_process.set(child_id);+ to_visit.append(child_id);+ }+ }++ if (contexts_by_painter.is_empty()) {+ requester.tell_remote_descendants_prepared_for_screenshot(request_id);+ return;+ }++ auto preparation_id = m_next_screenshot_preparation_id++;+ ScreenshotPreparation preparation { requester.web_content_client_id(), request_id, {}, {} };+ for (auto const& [painter, _] : contexts_by_painter)+ preparation.awaited_painters.set(painter);+ preparation.deadline = Core::Timer::create_single_shot(SCREENSHOT_PREPARATION_LIMIT, [this, preparation_id] {+ finish_screenshot_preparation(preparation_id);+ });+ preparation.deadline->start();+ m_screenshot_preparations.set(preparation_id, move(preparation));+ for (auto const& [painter, context_ids] : contexts_by_painter) {+ if (auto* client = web_content_client_if_present(painter))+ client->ask_to_paint_contexts_for_screenshot(preparation_id, context_ids);+ }+}++void CompositorState::did_paint_contexts_for_screenshot(CompositorStateWebContentClient& painter, u64 preparation_id)+{+ auto preparation = m_screenshot_preparations.get(preparation_id);+ if (!preparation.has_value() || !preparation->awaited_painters.remove(painter.web_content_client_id()))+ return;+ finish_screenshot_preparation_if_done(preparation_id);+}++void CompositorState::finish_screenshot_preparation_if_done(u64 preparation_id)+{+ auto preparation = m_screenshot_preparations.get(preparation_id);+ if (!preparation.has_value() || !preparation->awaited_painters.is_empty())+ return;+ finish_screenshot_preparation(preparation_id);+}++void CompositorState::finish_screenshot_preparation(u64 preparation_id)+{+ auto finished = m_screenshot_preparations.take(preparation_id);+ if (!finished.has_value())+ return;+ if (finished->deadline)+ finished->deadline->stop();+ if (auto* requester = web_content_client_if_present(finished->requester))+ requester->tell_remote_descendants_prepared_for_screenshot(finished->request_id);+}+Optional<Gfx::ShareableBitmap> CompositorState::take_frame_snapshot(Web::CompositorContextId context_id, Optional<Gfx::IntSize> maximum_size){auto* context = presented_context_if_present(context_id);diff --git a/Services/Compositor/CompositorState.h b/Services/Compositor/CompositorState.hindex e72c0bf5afb..9b4ac304469 100644--- a/Services/Compositor/CompositorState.h+++ b/Services/Compositor/CompositorState.h@@ -73,6 +73,8 @@ public:virtual void placeholder_canvas_committed(Compositing::CanvasId, Gfx::IntSize, bool origin_clean) = 0;// The owner of this client's canvases, which are the only ones its contexts may draw.virtual Compositing::CanvasSurfaceOwnerId canvas_surface_owner_id() const = 0;+ virtual void ask_to_paint_contexts_for_screenshot(u64 preparation_id, Vector<Web::CompositorContextId> const&) = 0;+ virtual void tell_remote_descendants_prepared_for_screenshot(u64 request_id) = 0;};class CompositorState final@@ -155,6 +157,10 @@ public:// Asks for the next display tick the context's maximum rate lets through, for its render clock.void request_clock_tick(Web::CompositorContextId, double maximum_frames_per_second);bool request_screenshot(Web::CompositorContextId, Gfx::ShareableBitmap&);+ // Has each process that owns a descendant of the context in another process paint it, along with whatever lies below+ // it, and tells the requester once every one of them has handed over its frames, or gone away.+ void prepare_remote_descendants_for_screenshot(CompositorStateWebContentClient& requester, Web::CompositorContextId, u64 request_id);+ void did_paint_contexts_for_screenshot(CompositorStateWebContentClient& painter, u64 preparation_id);Optional<Gfx::ShareableBitmap> take_frame_snapshot(Web::CompositorContextId, Optional<Gfx::IntSize> maximum_size);void presented_bitmap_ready_to_paint(Web::CompositorContextId, i32 bitmap_id);void set_client_gpu_presentation_capability(CompositorStateClient&, bool supported, u64 adapter_luid);@@ -315,6 +321,18 @@ private:void check_gpu_completions();HashMap<Web::CompositorContextId, NonnullOwnPtr<PresentedContext>> m_presented_contexts;++ // A screenshot whose context has descendants in other processes, which waits for those processes to paint them.+ struct ScreenshotPreparation {+ WebContentClientId requester;+ u64 request_id { 0 };+ HashTable<WebContentClientId> awaited_painters;+ RefPtr<Core::Timer> deadline;+ };+ void finish_screenshot_preparation_if_done(u64 preparation_id);+ void finish_screenshot_preparation(u64 preparation_id);+ HashMap<u64, ScreenshotPreparation> m_screenshot_preparations;+ u64 m_next_screenshot_preparation_id { 1 };u64 m_next_web_content_client_id { 1 };HashMap<WebContentClientId, CompositorStateWebContentClient*> m_web_content_clients;HashMap<Web::CompositorContextId, HashMap<ContextTimer, NonnullRefPtr<Core::Timer>>> m_context_timers;diff --git a/Services/Compositor/CompositorWebContentClient.ipc b/Services/Compositor/CompositorWebContentClient.ipcindex f15431f39d6..d6efda1c6bb 100644--- a/Services/Compositor/CompositorWebContentClient.ipc+++ b/Services/Compositor/CompositorWebContentClient.ipc@@ -17,6 +17,8 @@ endpoint CompositorWebContentClient[RustSender] overlay_scrollbar_visibilities_changed(Vector<Web::OverlayScrollbarVisibility> visibilities) =|did_complete_screenshot(Compositing::ScreenshotRequestId request_id) =|did_fail_screenshot(Compositing::ScreenshotRequestId request_id) =|+ paint_contexts_for_screenshot(u64 preparation_id, Vector<Web::CompositorContextId> context_ids) =|+ remote_descendants_prepared_for_screenshot(u64 request_id) =|did_lose_compositor() =|placeholder_canvas_committed(Compositing::CanvasId canvas_id, Gfx::IntSize size, bool origin_clean) =|}diff --git a/Services/Compositor/CompositorWebContentServer.ipc b/Services/Compositor/CompositorWebContentServer.ipcindex dcc2d089335..787557bbfc6 100644--- a/Services/Compositor/CompositorWebContentServer.ipc+++ b/Services/Compositor/CompositorWebContentServer.ipc@@ -98,4 +98,9 @@ endpoint CompositorWebContentServerhurry_rendering_opportunity(Web::CompositorContextId context_id) =|present_frame(Web::CompositorContextId context_id, Gfx::IntRect viewport_rect) =|request_screenshot(Web::CompositorContextId context_id, Compositing::ScreenshotRequestId request_id, Gfx::ShareableBitmap target_bitmap) =|+ // Has the processes that own the context's descendants in other processes paint them, and answers with+ // remote_descendants_prepared_for_screenshot() once the compositor has their frames.+ prepare_remote_descendants_for_screenshot(Web::CompositorContextId context_id, u64 request_id) =|+ // Answers paint_contexts_for_screenshot() once this process has handed the compositor the contexts' frames.+ did_paint_contexts_for_screenshot(u64 preparation_id) =|}diff --git a/Services/Compositor/ConnectionFromWebContent.cpp b/Services/Compositor/ConnectionFromWebContent.cppindex 6dfa45acabf..156ebeabc15 100644--- a/Services/Compositor/ConnectionFromWebContent.cpp+++ b/Services/Compositor/ConnectionFromWebContent.cpp@@ -540,6 +540,20 @@ void ConnectionFromWebContent::present_frame(Web::CompositorContextId context_idm_compositor_state->present_frame(context_id, viewport_rect);}+void ConnectionFromWebContent::prepare_remote_descendants_for_screenshot(Web::CompositorContextId context_id, u64 request_id)+{+ if (!context_is_owned_by_this_connection(context_id)) {+ async_remote_descendants_prepared_for_screenshot(request_id);+ return;+ }+ m_compositor_state->prepare_remote_descendants_for_screenshot(*this, context_id, request_id);+}++void ConnectionFromWebContent::did_paint_contexts_for_screenshot(u64 preparation_id)+{+ m_compositor_state->did_paint_contexts_for_screenshot(*this, preparation_id);+}+void ConnectionFromWebContent::request_screenshot(Web::CompositorContextId context_id, Compositing::ScreenshotRequestId request_id, Gfx::ShareableBitmap target_bitmap){if (!context_is_owned_by_this_connection(context_id))diff --git a/Services/Compositor/ConnectionFromWebContent.h b/Services/Compositor/ConnectionFromWebContent.hindex fe89f52facb..ba996f322f1 100644--- a/Services/Compositor/ConnectionFromWebContent.h+++ b/Services/Compositor/ConnectionFromWebContent.h@@ -88,6 +88,8 @@ private:virtual void hurry_rendering_opportunity(Web::CompositorContextId) override;virtual void present_frame(Web::CompositorContextId, Gfx::IntRect viewport_rect) override;virtual void request_screenshot(Web::CompositorContextId, Compositing::ScreenshotRequestId request_id, Gfx::ShareableBitmap target_bitmap) override;+ virtual void prepare_remote_descendants_for_screenshot(Web::CompositorContextId, u64 request_id) override;+ virtual void did_paint_contexts_for_screenshot(u64 preparation_id) override;virtual WebContentClientId web_content_client_id() const override { return m_web_content_client_id; }virtual void post_message_to_web_content(IPC::MessageBuffer&) override;@@ -100,6 +102,8 @@ private:virtual void video_sink_counted_frames(Media::VideoSinkHandle, Media::DisplayingVideoSinkFrameCounts) override;virtual void placeholder_canvas_committed(Compositing::CanvasId, Gfx::IntSize, bool origin_clean) override;virtual Compositing::CanvasSurfaceOwnerId canvas_surface_owner_id() const override { return m_canvas_host.canvas_surface_owner_id(); }+ virtual void ask_to_paint_contexts_for_screenshot(u64 preparation_id, Vector<Web::CompositorContextId> const& context_ids) override { async_paint_contexts_for_screenshot(preparation_id, context_ids); }+ virtual void tell_remote_descendants_prepared_for_screenshot(u64 request_id) override { async_remote_descendants_prepared_for_screenshot(request_id); }bool context_is_owned_by_this_connection(Web::CompositorContextId);NonnullRefPtr<CompositorState> m_compositor_state;diff --git a/Tests/LibWeb/Ref/expected/screenshot-shows-what-a-busy-remote-frame-has-not-painted-yet-ref.html b/Tests/LibWeb/Ref/expected/screenshot-shows-what-a-busy-remote-frame-has-not-painted-yet-ref.htmlnew file mode 100644index 00000000000..b4d2a01fb0e--- /dev/null+++ b/Tests/LibWeb/Ref/expected/screenshot-shows-what-a-busy-remote-frame-has-not-painted-yet-ref.html@@ -0,0 +1,2 @@+<!DOCTYPE html>+<iframe sandbox srcdoc="PASS"></iframe>diff --git a/Tests/LibWeb/Ref/input/screenshot-shows-what-a-busy-remote-frame-has-not-painted-yet.html b/Tests/LibWeb/Ref/input/screenshot-shows-what-a-busy-remote-frame-has-not-painted-yet.htmlnew file mode 100644index 00000000000..26c23fc6e73--- /dev/null+++ b/Tests/LibWeb/Ref/input/screenshot-shows-what-a-busy-remote-frame-has-not-painted-yet.html@@ -0,0 +1,11 @@+<!DOCTYPE html>+<link rel="match" href="../expected/screenshot-shows-what-a-busy-remote-frame-has-not-painted-yet-ref.html">+<!-- A sandboxed frame with an opaque origin is hosted by another process. Just after it loads, it changes its text and+ keeps its process busy, so it has not painted the change by the time the page asks for the screenshot. -->+<iframe sandbox="allow-scripts" srcdoc="<script>+ onload = () => setTimeout(() => {+ document.body.textContent = 'PASS';+ const until = performance.now() + 1000;+ while (performance.now() < until) {}+ });+</script>"></iframe>