From 29b4f21c7b295e304aa5d32db685db3b5c41b780 Mon Sep 17 00:00:00 2001 From: Andrew Kaster Date: Sun, 30 Jun 2024 19:12:22 -0600 Subject: [PATCH] WebContent: Add shutdown_server IPC call to request process exit This ensures that removing the last view from a WebContentClient will close its associated process, assuming the WebContent process is not hung. A more drastic measure will be needed to trigger forcefully killing the process when it doesn't respond to this request. --- Userland/Libraries/LibWebView/WebContentClient.cpp | 1 + Userland/Services/WebContent/ConnectionFromClient.cpp | 5 +++++ Userland/Services/WebContent/ConnectionFromClient.h | 1 + Userland/Services/WebContent/WebContentServer.ipc | 2 ++ 4 files changed, 9 insertions(+) diff --git a/Userland/Libraries/LibWebView/WebContentClient.cpp b/Userland/Libraries/LibWebView/WebContentClient.cpp index 61f36297f78..fc11d0c5f04 100644 --- a/Userland/Libraries/LibWebView/WebContentClient.cpp +++ b/Userland/Libraries/LibWebView/WebContentClient.cpp @@ -50,6 +50,7 @@ void WebContentClient::unregister_view(u64 page_id) m_views.remove(page_id); if (m_views.is_empty()) { on_web_content_process_crash = nullptr; + async_close_server(); } } diff --git a/Userland/Services/WebContent/ConnectionFromClient.cpp b/Userland/Services/WebContent/ConnectionFromClient.cpp index 3818423e6cf..d64aad7bd8d 100644 --- a/Userland/Services/WebContent/ConnectionFromClient.cpp +++ b/Userland/Services/WebContent/ConnectionFromClient.cpp @@ -82,6 +82,11 @@ Optional ConnectionFromClient::page(u64 index, SourceLocation return {}; } +void ConnectionFromClient::close_server() +{ + shutdown(); +} + Messages::WebContentServer::GetWindowHandleResponse ConnectionFromClient::get_window_handle(u64 page_id) { if (auto page = this->page(page_id); page.has_value()) diff --git a/Userland/Services/WebContent/ConnectionFromClient.h b/Userland/Services/WebContent/ConnectionFromClient.h index 404d0c6d32e..fcba81d1f8f 100644 --- a/Userland/Services/WebContent/ConnectionFromClient.h +++ b/Userland/Services/WebContent/ConnectionFromClient.h @@ -53,6 +53,7 @@ private: Optional page(u64 index, SourceLocation = SourceLocation::current()); Optional page(u64 index, SourceLocation = SourceLocation::current()) const; + virtual void close_server() override; virtual Messages::WebContentServer::GetWindowHandleResponse get_window_handle(u64 page_id) override; virtual void set_window_handle(u64 page_id, String const& handle) override; virtual void connect_to_webdriver(u64 page_id, ByteString const& webdriver_ipc_path) override; diff --git a/Userland/Services/WebContent/WebContentServer.ipc b/Userland/Services/WebContent/WebContentServer.ipc index 94666e7c1ef..29a032af77c 100644 --- a/Userland/Services/WebContent/WebContentServer.ipc +++ b/Userland/Services/WebContent/WebContentServer.ipc @@ -13,6 +13,8 @@ endpoint WebContentServer { + close_server() =| + get_window_handle(u64 page_id) => (String handle) set_window_handle(u64 page_id, String handle) =|