Skip to content

Truly independent web browser

LibWebView+WebWorker+Meta: Remove the WebWorker process

Andreas Kling4e72ce3a9356
diff --git a/Libraries/LibWebView/Application.cpp b/Libraries/LibWebView/Application.cpp
index 151fbdaf795..dcd7897820f 100644
--- a/Libraries/LibWebView/Application.cpp
+++ b/Libraries/LibWebView/Application.cpp
@@ -82,7 +82,6 @@
#include <LibWebView/WebContentClient.h>
#include <LibWebView/WebDriverBiDi.h>
#include <LibWebView/WebDriverBrowserConnection.h>
-#include <LibWebView/WebWorkerClient.h>
#include <LibWebView/WorkerProcessManager.h>
#if defined(AK_OS_MACOS)
@@ -2402,11 +2401,6 @@ void Application::process_did_exit(Process&& process, Optional<int>)
m_web_content_clients.remove(client.release_nonnull());
}
break;
- case ProcessType::WebWorker:
- // NB: A worker that closes itself says so and exits right away, and this can come ahead of what it said.
- if (auto client = process.client<WebWorkerClient>())
- client->dispatch_pending_messages();
- break;
case ProcessType::Browser:
dbgln("Invalid process type to be dying: Browser");
VERIFY_NOT_REACHED();
diff --git a/Libraries/LibWebView/CrashReportStore.cpp b/Libraries/LibWebView/CrashReportStore.cpp
index 0b9732cc9c4..bf91716b6e8 100644
--- a/Libraries/LibWebView/CrashReportStore.cpp
+++ b/Libraries/LibWebView/CrashReportStore.cpp
@@ -66,7 +66,7 @@ bool CrashReportStore::is_saved_report_name(StringView name)
if (has_timestamp)
suffix = name.substring_view(timestamp_pattern.length());
}
- for (auto type : { ProcessType::Browser, ProcessType::WebContent, ProcessType::WebWorker,
+ for (auto type : { ProcessType::Browser, ProcessType::WebContent,
ProcessType::RequestServer, ProcessType::ImageDecoder, ProcessType::MediaServer, ProcessType::AudioServer, ProcessType::VideoDecoderServer, ProcessType::Compositor }) {
auto prefix = ByteString::formatted("{}-", process_name_from_type(type));
if (!suffix.starts_with(prefix) || suffix.length() != prefix.length() + 10)
diff --git a/Libraries/LibWebView/HelperProcess.cpp b/Libraries/LibWebView/HelperProcess.cpp
index 8dc11f72034..70909ddd1a6 100644
--- a/Libraries/LibWebView/HelperProcess.cpp
+++ b/Libraries/LibWebView/HelperProcess.cpp
@@ -565,53 +565,6 @@ ErrorOr<NonnullRefPtr<WebView::CompositorClient>> launch_compositor_process()
return client;
}
-ErrorOr<NonnullRefPtr<WebWorkerClient>> launch_web_worker_process(Web::HTML::AgentType type, IsPrivate is_private, Web::HTML::WorkerAgentId agent_id)
-{
- auto const& browser_options = WebView::Application::browser_options();
- auto const& web_content_options = WebView::Application::web_content_options();
-
- Vector<ByteString> arguments;
-
- if (browser_options.disable_sandbox == DisableSandbox::Yes)
- arguments.append("--disable-sandbox"sv);
- if (web_content_options.is_test_mode == WebView::IsTestMode::Yes)
- arguments.append("--test-mode"sv);
- if (web_content_options.expose_experimental_interfaces == WebView::ExposeExperimentalInterfaces::Yes)
- arguments.append("--expose-experimental-interfaces"sv);
- if (web_content_options.enable_http_memory_cache == WebView::EnableMemoryHTTPCache::Yes)
- arguments.append("--enable-http-memory-cache"sv);
- if (web_content_options.file_scheme_urls_have_tuple_origins == FileSchemeUrlsHaveTupleOrigins::Yes)
- arguments.append("--tuple-file-origins"sv);
- if (web_content_options.proxy_autoconfig_url.has_value())
- arguments.append(ByteString::formatted("--proxy-autoconfig-url={}", *web_content_options.proxy_autoconfig_url));
-
- arguments.append("--type"sv);
- switch (type) {
- case Web::HTML::AgentType::DedicatedWorker:
- arguments.append("dedicated"sv);
- break;
- case Web::HTML::AgentType::SharedWorker:
- arguments.append("shared"sv);
- break;
- case Web::HTML::AgentType::ServiceWorker:
- arguments.append("service"sv);
- break;
- default:
- VERIFY_NOT_REACHED();
- }
-
- if (auto server = mach_server_name(); server.has_value()) {
- arguments.append("--mach-server-name"sv);
- arguments.append(server.value());
- }
-
- auto client = TRY(launch_server_process<WebWorkerClient>("WebWorker"sv, move(arguments), is_private, agent_id));
- TRY(connect_to_font_service(*client));
- if (auto system_font_family = WebView::Application::the().system_font_family(); system_font_family.has_value())
- client->async_set_system_font_family(system_font_family.release_value());
- return client;
-}
-
void apply_dns_settings(Requests::RequestControlClient& client)
{
Application::settings().dns_settings().visit(
diff --git a/Libraries/LibWebView/HelperProcess.h b/Libraries/LibWebView/HelperProcess.h
index 3d25e8f930e..642c63bdc5e 100644
--- a/Libraries/LibWebView/HelperProcess.h
+++ b/Libraries/LibWebView/HelperProcess.h
@@ -18,7 +18,6 @@
#include <LibWebView/BrowsingSession.h>
#include <LibWebView/Forward.h>
#include <LibWebView/WebContentClient.h>
-#include <LibWebView/WebWorkerClient.h>
#include <RequestServer/SiteBinding.h>
namespace WebView {
@@ -30,7 +29,6 @@ WEBVIEW_API ErrorOr<NonnullRefPtr<AudioServerControlClient>> launch_audio_server
WEBVIEW_API ErrorOr<NonnullRefPtr<VideoDecoderServerControlClient>> launch_video_decoder_server_process(u64 owner_child_id, Optional<Gfx::GpuDeviceIdentity> const&);
WEBVIEW_API void shut_down_video_decoder_servers();
WEBVIEW_API ErrorOr<NonnullRefPtr<WebView::CompositorClient>> launch_compositor_process();
-WEBVIEW_API ErrorOr<NonnullRefPtr<WebView::WebWorkerClient>> launch_web_worker_process(Web::HTML::AgentType, IsPrivate, Web::HTML::WorkerAgentId);
// Serves the given site's partitions, or all partitions if site is empty.
WEBVIEW_API ErrorOr<NonnullRefPtr<Requests::RequestControlClient>> launch_request_server_process(ByteString const& cache_path, Optional<Utf16String> const& site, HTTPDiskCacheMode);
WEBVIEW_API void apply_dns_settings(Requests::RequestControlClient&);
diff --git a/Libraries/LibWebView/ProcessManager.cpp b/Libraries/LibWebView/ProcessManager.cpp
index a8591686137..7d134094eb9 100644
--- a/Libraries/LibWebView/ProcessManager.cpp
+++ b/Libraries/LibWebView/ProcessManager.cpp
@@ -21,8 +21,6 @@ ProcessType process_type_from_name(StringView name)
return ProcessType::Compositor;
if (name == "WebContent"sv)
return ProcessType::WebContent;
- if (name == "WebWorker"sv)
- return ProcessType::WebWorker;
if (name == "RequestServer"sv)
return ProcessType::RequestServer;
if (name == "ImageDecoder"sv)
@@ -49,8 +47,6 @@ StringView process_name_from_type(ProcessType type)
return "Compositor"sv;
case ProcessType::WebContent:
return "WebContent"sv;
- case ProcessType::WebWorker:
- return "WebWorker"sv;
case ProcessType::RequestServer:
return "RequestServer"sv;
case ProcessType::ImageDecoder:
diff --git a/Libraries/LibWebView/ProcessType.h b/Libraries/LibWebView/ProcessType.h
index 792eacdbcd6..376c07eb9bf 100644
--- a/Libraries/LibWebView/ProcessType.h
+++ b/Libraries/LibWebView/ProcessType.h
@@ -14,7 +14,6 @@ enum class ProcessType : u8 {
Browser,
Compositor,
WebContent,
- WebWorker,
RequestServer,
ImageDecoder,
MediaServer,
diff --git a/Libraries/LibWebView/TabPerformanceMonitor.cpp b/Libraries/LibWebView/TabPerformanceMonitor.cpp
index 849b9997460..6857658a33d 100644
--- a/Libraries/LibWebView/TabPerformanceMonitor.cpp
+++ b/Libraries/LibWebView/TabPerformanceMonitor.cpp
@@ -14,7 +14,6 @@
#include <LibWebView/ViewImplementation.h>
#include <LibWebView/WebContentClient.h>
#include <LibWebView/WebContentPage.h>
-#include <LibWebView/WorkerProcessManager.h>
namespace WebView {
@@ -45,14 +44,15 @@ void TabPerformanceMonitor::configure(Requests::RequestControlClient& requests)
WebContentClient::for_each_client([&](WebContentClient& client) {
if (client.pid() != entry.process_id)
return IterationDecision::Continue;
+ // NB: What a worker on a thread of the process uses comes with no page.
if (auto* page = client.page(entry.page_id)) {
auto const& view = page->view();
owner = view.owner_view_id().value_or(view.view_id());
+ } else {
+ owner = client.exclusive_performance_owner();
}
return IterationDecision::Break;
});
- if (!owner.has_value())
- owner = WorkerProcessManager::the().exclusive_performance_owner(entry.process_id);
if (owner.has_value())
s_monitor->m_tabs.ensure(*owner).add_network_bytes(now, interval_microseconds, entry.download_bytes, entry.upload_bytes);
}
@@ -104,8 +104,6 @@ void TabPerformanceMonitor::sample()
if (process.type() == ProcessType::WebContent) {
if (auto client = process.client<WebContentClient>())
owner = client->exclusive_performance_owner();
- } else if (process.type() == ProcessType::WebWorker) {
- owner = WorkerProcessManager::the().exclusive_performance_owner(process.pid());
}
if (!owner.has_value())
return;
diff --git a/Libraries/LibWebView/WebContentPage.cpp b/Libraries/LibWebView/WebContentPage.cpp
index ae668c48e77..4952b9a06cd 100644
--- a/Libraries/LibWebView/WebContentPage.cpp
+++ b/Libraries/LibWebView/WebContentPage.cpp
@@ -3408,7 +3408,7 @@ void WebContentPage::did_simulate_worker_request_server_connection_loss()
{
VERIFY(Application::web_content_options().is_test_mode == IsTestMode::Yes);
if (auto result = WorkerProcessManager::the().simulate_request_server_connection_loss_for_testing(client(), m_id); result.is_error()) {
- warnln("Unable to reconnect WebWorker processes to RequestServer: {}", result.error());
+ warnln("Unable to reconnect workers to RequestServer: {}", result.error());
VERIFY_NOT_REACHED();
}
}
diff --git a/Libraries/LibWebView/WebUI/CrashReportsUI.cpp b/Libraries/LibWebView/WebUI/CrashReportsUI.cpp
index 7e477a5f358..579a3f8d235 100644
--- a/Libraries/LibWebView/WebUI/CrashReportsUI.cpp
+++ b/Libraries/LibWebView/WebUI/CrashReportsUI.cpp
@@ -22,8 +22,6 @@ static StringView plain_process_name(StringView process)
return "Graphics process"sv;
if (process == "WebContent"sv)
return "Page"sv;
- if (process == "WebWorker"sv)
- return "Worker"sv;
if (process == "RequestServer"sv)
return "Network process"sv;
if (process == "ImageDecoder"sv)
diff --git a/Libraries/LibWebView/WebWorkerClient.cpp b/Libraries/LibWebView/WebWorkerClient.cpp
index 3d56162667a..9e09e14c0e1 100644
--- a/Libraries/LibWebView/WebWorkerClient.cpp
+++ b/Libraries/LibWebView/WebWorkerClient.cpp
@@ -4,7 +4,6 @@
* SPDX-License-Identifier: BSD-2-Clause
*/
-#include <LibCore/Process.h>
#include <LibWebView/Application.h>
#include <LibWebView/AudioServerControlClient.h>
#include <LibWebView/BlobURLStore.h>
@@ -42,8 +41,7 @@ WebWorkerClient::~WebWorkerClient()
void WebWorkerClient::set_host(WebContentClient& host)
{
m_host = host;
- m_runs_on_thread = true;
- set_child_identity({ .child_id = host.child_id(), .pid = host.pid() });
+ m_host_child_id = host.child_id();
}
void WebWorkerClient::did_misbehave(StringView message_name, StringView reason)
@@ -54,17 +52,9 @@ void WebWorkerClient::did_misbehave(StringView message_name, StringView reason)
shutdown();
return;
}
- dbgln("WebWorkerClient: terminating helper process {}: {} rejected: {}", pid(), message_name, reason);
- if (!m_runs_on_thread)
- terminate_process();
shutdown();
}
-void WebWorkerClient::terminate_process()
-{
- (void)Application::process_manager().terminate_child(child_id(), Core::Process::TerminationMode::Forceful);
-}
-
void WebWorkerClient::die()
{
remove_blob_url_entries();
@@ -74,11 +64,7 @@ void WebWorkerClient::die()
if (m_holds_image_decoder_client)
ImageDecoderManager::the().process_did_release_decoder(child_id());
- // NB: A worker whose connection is gone does no more work, so a process that outlives its connection is ended. A
- // thread closes the connection as it ends.
- if (!m_runs_on_thread)
- terminate_process();
- WorkerProcessManager::the().worker_process_did_exit(*this);
+ WorkerProcessManager::the().worker_thread_did_exit(*this);
// Otherwise nested workers we own would outlive us, in violation of the HTML spec.
WorkerProcessManager::the().remove_web_worker_owner(*this);
@@ -115,7 +101,7 @@ void WebWorkerClient::remove_blob_url_entries()
session->blob_url_store->remove_entries_added_by(WeakPtr<WebWorkerClient> { *this });
}
-// The environment a worker process names is its worker's.
+// The environment a worker names is its own.
Optional<CanonicalEnvironmentSettingsObject const&> WebWorkerClient::hosted_environment(Web::HTML::EnvironmentId const& environment_id) const
{
auto inside_settings = WorkerProcessManager::the().inside_settings(m_agent_id);
@@ -203,7 +189,7 @@ Messages::WebWorkerClient::RequestMediaServerConnectionResponse WebWorkerClient:
auto connection = connect_new_media_server_client(m_media_server_client, child_id(), [weak_self = make_weak_ptr<WebWorkerClient>()]() -> ErrorOr<IPC::TransportHandle> {
auto self = weak_self.strong_ref();
if (!self)
- return Error::from_string_literal("The worker process is gone");
+ return Error::from_string_literal("The worker is gone");
TRY(ensure_audio_server_is_running(self->m_audio_server_client, self->child_id()));
return connect_new_audio_server_client(*self->m_audio_server_client, self->m_audio_tab_id);
});
@@ -216,9 +202,6 @@ Messages::WebWorkerClient::RequestMediaServerConnectionResponse WebWorkerClient:
Messages::WebWorkerClient::RequestImageDecoderConnectionResponse WebWorkerClient::request_image_decoder_connection()
{
- if (!m_runs_on_thread)
- return ImageDecoderManager::the().connect_requesting_process(child_id(), session(), m_site);
-
// NB: A thread is part of its process, and what the decoder of a process may see goes by all that the process hosts.
auto host = m_host.strong_ref();
if (!host)
diff --git a/Libraries/LibWebView/WebWorkerClient.h b/Libraries/LibWebView/WebWorkerClient.h
index 7f8f04d9fa2..5f636c4d227 100644
--- a/Libraries/LibWebView/WebWorkerClient.h
+++ b/Libraries/LibWebView/WebWorkerClient.h
@@ -19,7 +19,6 @@
#include <LibWebCommon/HTML/WorkerAgentTypes.h>
#include <LibWebView/BlobURLStore.h>
#include <LibWebView/BrowsingSession.h>
-#include <LibWebView/ChildIdentity.h>
#include <LibWebView/Export.h>
#include <LibWebView/RequestServerSiteBindings.h>
#include <WebWorker/WebWorkerClientEndpoint.h>
@@ -39,26 +38,19 @@ public:
RefPtr<BrowsingSession> session() const { return m_session.strong_ref(); }
IsPrivate is_private() const { return m_is_private; }
- // The site of the worker's origin, if it has one.
- void set_site(Optional<Utf16String> site) { m_site = move(site); }
-
- // The sites this process asked for the permissions of: at most its worker's top-level site.
+ // The sites this worker asked for the permissions of: at most its top-level site.
Vector<URL::Origin> const& permission_origins() const { return m_permission_origins; }
RequestServerSiteBindings& request_server_site_bindings() { return m_request_server_site_bindings; }
void remove_blob_url_entries();
- // The process of a worker on a thread is its host's. So, what these say and do is about that process.
- pid_t pid() const { return m_child_identity.pid; }
- u64 child_id() const { return m_child_identity.child_id; }
- void terminate_process();
+ // The process the worker's thread runs in.
+ u64 child_id() const { return m_host_child_id; }
- // The WebContent process that runs this worker on a thread. A worker with a process of its own has none.
+ // The WebContent process that runs this worker on a thread.
WebContentClient* host() const { return m_host.ptr(); }
void set_host(WebContentClient&);
- bool runs_on_thread() const { return m_runs_on_thread; }
Optional<CanonicalEnvironmentSettingsObject const&> hosted_environment(Web::HTML::EnvironmentId const& environment_id) const;
- void set_child_identity(ChildIdentity identity) { m_child_identity = identity; }
virtual void did_close_worker() override;
virtual void did_finish_loading_worker_script(bool worker_is_secure_context) override;
@@ -86,19 +78,17 @@ private:
virtual void die() override;
IsPrivate m_is_private { IsPrivate::No };
- Optional<Utf16String> m_site;
WeakPtr<BrowsingSession> m_session;
RequestServerSiteBindings m_request_server_site_bindings;
- ChildIdentity m_child_identity;
+ u64 m_host_child_id { 0 };
WeakPtr<WebContentClient> m_host;
- bool m_runs_on_thread { false };
bool m_holds_image_decoder_client { false };
Web::HTML::WorkerAgentId m_agent_id { 0 };
Vector<URL::Origin> m_permission_origins;
- // The controller connections to the MediaServer and AudioServer spawned for this process, from its first media use
- // until it exits.
+ // The controller connections to the MediaServer and AudioServer spawned for this worker, from its first media use
+ // until it ends.
RefPtr<MediaClient::Client> m_media_server_client;
RefPtr<AudioServerControlClient> m_audio_server_client;
u64 m_audio_tab_id { 0 };
diff --git a/Libraries/LibWebView/WorkerProcessManager.cpp b/Libraries/LibWebView/WorkerProcessManager.cpp
index 87d3dde2d77..5e613548f33 100644
--- a/Libraries/LibWebView/WorkerProcessManager.cpp
+++ b/Libraries/LibWebView/WorkerProcessManager.cpp
@@ -9,7 +9,6 @@
#include <LibCore/Timer.h>
#include <LibIPC/File.h>
#include <LibURL/Parser.h>
-#include <LibURL/Site.h>
#include <LibWebCommon/WebView/SiteIsolation.h>
#include <LibWebView/Application.h>
#include <LibWebView/CanonicalEnvironmentSettingsObject.h>
@@ -30,8 +29,6 @@ namespace WebView {
// less than a process, but still has a heap, JIT threads and connections to itself, and one page can start them all.
static constexpr size_t maximum_worker_count_per_top_level_site = 64;
-static constexpr auto worker_exit_grace_period = AK::Duration::from_seconds(5);
-
// https://html.spec.whatwg.org/multipage/workers.html#extended-lifetime-shared-worker-timeout
static constexpr auto extended_lifetime_shared_worker_timeout = AK::Duration::from_seconds(30);
@@ -167,7 +164,7 @@ WorkerProcessManager::StartedWorkerAgent WorkerProcessManager::start_worker_agen
}
// NB: A top-level site may run only so many workers at once, wherever its documents and workers start them.
- // An opaque top-level origin is a site of its own. A worker counts until its thread or process is gone, and one
+ // An opaque top-level origin is a site of its own. A worker counts until its thread is gone, and one
// whose creator's browsing context has been discarded, leaving it no top-level origin, does not start.
auto top_level_origin = outside_settings->top_level_origin();
if (!top_level_origin.has_value()) {
@@ -209,23 +206,23 @@ WorkerProcessManager::StartedWorkerAgent WorkerProcessManager::start_worker_agen
} else if (auto const* web_content_owner = owner.client.get_pointer<WebContentOwner>(); web_content_owner && owner_process_may_host_shared_worker(*web_content_owner, *outside_settings)) {
host = web_content_owner->client.strong_ref();
}
- bool const host_has_only_this_worker = !host && request.agent_type == Web::HTML::AgentType::SharedWorker;
+ // NB: Nothing would close a process started for a dedicated worker, as only shared workers keep a process alive.
+ if (request.agent_type == Web::HTML::AgentType::DedicatedWorker && !host) {
+ notify_worker_script_load_failure(owner);
+ return {};
+ }
+ bool const host_has_only_this_worker = !host;
Optional<IPC::TransportHandle> thread_transport;
auto client_or_error = [&]() -> ErrorOr<NonnullRefPtr<WebWorkerClient>> {
- auto client = TRY([&]() -> ErrorOr<NonnullRefPtr<WebWorkerClient>> {
- if (!host && !host_has_only_this_worker)
- return launch_web_worker_process(request.agent_type, is_private, agent_id);
- auto transport = TRY(IPC::Transport::create_paired());
- if (host_has_only_this_worker) {
- host = TRY(Application::the().launch_web_content_process_without_page(is_private));
- host->async_start_worker_thread(move(transport.remote_handle), request.agent_type);
- } else {
- thread_transport = move(transport.remote_handle);
- }
- auto client = TRY(try_make_ref_counted<WebWorkerClient>(move(transport.local), is_private, agent_id));
- client->set_host(*host);
- return client;
- }());
+ auto transport = TRY(IPC::Transport::create_paired());
+ if (host_has_only_this_worker) {
+ host = TRY(Application::the().launch_web_content_process_without_page(is_private));
+ host->async_start_worker_thread(move(transport.remote_handle), request.agent_type);
+ } else {
+ thread_transport = move(transport.remote_handle);
+ }
+ auto client = TRY(try_make_ref_counted<WebWorkerClient>(move(transport.local), is_private, agent_id));
+ client->set_host(*host);
// The worker's RequestServer client uses the cookies of the session the worker itself belongs to.
auto session = client->session();
@@ -256,7 +253,7 @@ WorkerProcessManager::StartedWorkerAgent WorkerProcessManager::start_worker_agen
client->async_connect_to_compositor(compositor_handle.release_value());
return client;
}();
- // A worker the system cannot give a thread or a process fails to load, as one whose script cannot be fetched does.
+ // A worker the system cannot give a thread fails to load, as one whose script cannot be fetched does.
if (client_or_error.is_error()) {
dbgln("Unable to start a worker: {}", client_or_error.error());
if (host_has_only_this_worker && host)
@@ -282,7 +279,6 @@ WorkerProcessManager::StartedWorkerAgent WorkerProcessManager::start_worker_agen
// settings it is created for, too.
auto inside_settings = make<CanonicalWorkerEnvironmentSettingsObject>(move(origin), outside_settings->top_level_origin(), has_cross_site_ancestor, Web::HTML::EnvironmentId::generate());
auto environment_id = inside_settings->id();
- client->set_site(URL::Site::serialize_for_partitioning(inside_settings->origin()));
// NB: The task manager lists a process with the site of its pages. One that has none left only runs on for its shared
// workers, so it goes by the site of their origin.
@@ -291,8 +287,8 @@ WorkerProcessManager::StartedWorkerAgent WorkerProcessManager::start_worker_agen
process->set_site_url(URL::Parser::basic_parse(worker_origin.serialize()));
}
- // NB: A worker's process reads local files as its owner's does. A worker of a file origin that local file content
- // starts is local file content too.
+ // NB: A worker reads local files as its owner does. A worker of a file origin that local file content starts is
+ // local file content too.
auto may_read_local_files = inside_settings->origin().is_file_origin()
&& owner.client.visit(
[](WebContentOwner const& web_content_owner) {
@@ -801,7 +797,7 @@ void WorkerProcessManager::worker_did_request_file(Web::HTML::WorkerAgentId agen
if (maybe_agent == m_agents.end())
return;
- // NB: As a page's, a worker's process reads a local file only through this broker, and only local file content may.
+ // NB: As a page, a worker reads a local file only through this broker, and only local file content may.
auto& client = maybe_agent->value.client;
if (!maybe_agent->value.may_read_local_files) {
client->async_handle_file_return(EACCES, {}, request_id);
@@ -865,21 +861,12 @@ void WorkerProcessManager::remove_agent(Web::HTML::WorkerAgentId agent_id, Agent
return;
agent.client->async_close_worker();
- // NB: A worker busy running script handles no request to close, so its process is terminated if it has not exited
- // in time. A worker on a thread cannot be: its thread leaves as soon as it gets out of the builtin or the request
- // it may be in, and nothing waits for it. Until it is gone, it counts toward the workers of its top-level site.
- RefPtr<Core::Timer> termination_timer;
- if (!agent.client->runs_on_thread()) {
- termination_timer = Core::Timer::create_single_shot(worker_exit_grace_period, [client = agent.client] {
- if (client->is_open())
- client->terminate_process();
- });
- termination_timer->start();
- }
- m_exiting_workers.append({ agent.client, agent.is_private, move(agent.top_level_origin), move(termination_timer) });
+ // NB: A thread leaves as soon as it gets out of the builtin or the request it may be in, and nothing waits for it.
+ // Until it is gone, it counts toward the workers of its top-level site.
+ m_exiting_workers.append({ agent.client, agent.is_private, move(agent.top_level_origin) });
}
-void WorkerProcessManager::worker_process_did_exit(WebWorkerClient& client)
+void WorkerProcessManager::worker_thread_did_exit(WebWorkerClient& client)
{
Vector<ExitingWorker> exited_workers;
for (size_t i = m_exiting_workers.size(); i > 0; --i) {
@@ -935,42 +922,4 @@ void WorkerProcessManager::remove_owner(Web::HTML::WorkerAgentId agent_id, Owner
remove_agent(agent_id, AgentRemovalCause::AgentTerminated);
}
-Optional<u64> WorkerProcessManager::exclusive_performance_owner(pid_t pid) const
-{
- HashTable<Web::HTML::WorkerAgentId> visiting;
- Function<Optional<u64>(WorkerAgent const&)> resolve = [&](WorkerAgent const& agent) -> Optional<u64> {
- if (agent.closing || visiting.contains(agent.id))
- return {};
- visiting.set(agent.id);
- ScopeGuard remove_visit = [&] { visiting.remove(agent.id); };
- Optional<u64> result;
- for (auto const& owner : agent.owners) {
- auto id = owner.client.visit(
- [&](WebContentOwner const& content) -> Optional<u64> {
- if (!content.client)
- return {};
- auto* page = content.client->page(content.page_id);
- if (!page)
- return {};
- return page->view().view_id(); },
- [&](WebWorkerOwner const& worker) -> Optional<u64> {
- for (auto const& candidate : m_agents) {
- if (candidate.value.client.ptr() == worker.client.ptr())
- return resolve(candidate.value);
- }
- return {}; });
- if (!id.has_value() || (result.has_value() && *result != *id))
- return {};
- result = id;
- }
- return result;
- };
- // NB: A worker on a thread has the process of its owner, which is not this worker's to speak for.
- for (auto const& agent : m_agents) {
- if (agent.value.client->pid() == pid && !agent.value.client->runs_on_thread())
- return resolve(agent.value);
- }
- return {};
-}
-
}
diff --git a/Libraries/LibWebView/WorkerProcessManager.h b/Libraries/LibWebView/WorkerProcessManager.h
index 4cd87f180a6..d6c8207644e 100644
--- a/Libraries/LibWebView/WorkerProcessManager.h
+++ b/Libraries/LibWebView/WorkerProcessManager.h
@@ -90,8 +90,6 @@ public:
// A process goes on without pages for as long as it runs a shared worker, as the worker's owners can be anywhere.
bool hosts_shared_worker(WebContentClient const&) const;
- Optional<u64> exclusive_performance_owner(pid_t) const;
-
size_t client_count() const { return m_agents.size(); }
void update_permission_snapshot(PermissionManager const&);
@@ -140,7 +138,7 @@ private:
void worker_did_report_outside_settings_content_security_policy_violation(Web::HTML::WorkerAgentId, u64 policy_index, String effective_directive, URL::URL resource);
void worker_did_close(Web::HTML::WorkerAgentId);
void worker_did_die(Web::HTML::WorkerAgentId);
- void worker_process_did_exit(WebWorkerClient&);
+ void worker_thread_did_exit(WebWorkerClient&);
void worker_did_request_file(Web::HTML::WorkerAgentId, ByteString path, i32 request_id);
void worker_did_write_rtc_transform_encoded_audio_frame(Web::HTML::WorkerAgentId, u64 transform_id, ByteBuffer payload, u32 ssrc, u8 payload_type, u32 rtp_timestamp, u16 sequence_number);
@@ -182,13 +180,12 @@ private:
static bool is_same_owner(Owner const&, Owner const& identity);
static void forget_removed_outside_settings_owner(WorkerAgent&);
- // A worker whose agent is gone counts toward the workers of its top-level site until its connection closes: a thread
- // closes it as it ends, and that also ends a process.
+ // A worker whose agent is gone counts toward the workers of its top-level site until its thread closes its connection
+ // as it ends.
struct ExitingWorker {
NonnullRefPtr<WebWorkerClient> client;
IsPrivate is_private { IsPrivate::No };
Optional<URL::Origin> top_level_origin;
- RefPtr<Core::Timer> termination_timer;
};
Vector<ExitingWorker> m_exiting_workers;
diff --git a/Meta/CMake/ladybird_helper_processes.cmake b/Meta/CMake/ladybird_helper_processes.cmake
index 53a33ac9150..0f1702b1e37 100644
--- a/Meta/CMake/ladybird_helper_processes.cmake
+++ b/Meta/CMake/ladybird_helper_processes.cmake
@@ -7,7 +7,6 @@ set(ladybird_helper_processes
VideoDecoderServer
WebContent
WebRTCClient
- WebWorker
)
# Kills the helpers when the Browser is gone, which the kernel cannot do on macOS.
diff --git a/Meta/Generators/generate-build-information.py b/Meta/Generators/generate-build-information.py
index 389f39f5f8b..b8453cb0099 100755
--- a/Meta/Generators/generate-build-information.py
+++ b/Meta/Generators/generate-build-information.py
@@ -20,7 +20,6 @@ HELPERS = (
"RequestServer",
"VideoDecoderServer",
"WebContent",
- "WebWorker",
"WebRTCClient",
)
diff --git a/Meta/ladybird.py b/Meta/ladybird.py
index bf582b68686..5915aaa1932 100755
--- a/Meta/ladybird.py
+++ b/Meta/ladybird.py
@@ -426,7 +426,6 @@ def run_main(host_system: HostSystem, build_dir: Path, target: str, args: list[s
"RequestServer",
"WebContent",
"WebDriver",
- "WebWorker",
):
run_args.append(str(build_dir.joinpath("bin", "Ladybird.app", "Contents", "MacOS", target)))
else:
diff --git a/Meta/style-update-capture.py b/Meta/style-update-capture.py
index a0900d74af6..2b63f690e20 100755
--- a/Meta/style-update-capture.py
+++ b/Meta/style-update-capture.py
@@ -66,7 +66,7 @@ PHASES = {
}
-WATCHED_PROCESSES = ("js", "test-web", "test262-runner", "WebContent", "WebWorker", "Ladybird", "WebDriver")
+WATCHED_PROCESSES = ("js", "test-web", "test262-runner", "WebContent", "Ladybird", "WebDriver")
PS_FORMAT = "pid=,pgid=,rss=,time=,lstart=,comm="
PS_START_FIELDS = 5
PS_UNAVAILABLE = False
diff --git a/Services/WebWorker/CMakeLists.txt b/Services/WebWorker/CMakeLists.txt
index 8fbf97d4ca9..aa97389e862 100644
--- a/Services/WebWorker/CMakeLists.txt
+++ b/Services/WebWorker/CMakeLists.txt
@@ -18,21 +18,3 @@ target_include_directories(webworkerservice PRIVATE ${LADYBIRD_SOURCE_DIR}/Servi
target_link_libraries(webworkerservice PUBLIC LibCore LibFileSystem LibGfx LibHTTP LibIPC LibJS LibRequests LibCompositing LibWeb LibUnicode LibImageDecoderClient LibMain LibMediaClient LibThreading LibURL LibGC)
target_link_libraries(webworkerservice PRIVATE OpenSSL::Crypto OpenSSL::SSL)
-add_executable(WebWorker main.cpp)
-
-if (LINUX)
- target_sources(WebWorker PRIVATE ../RendererSandboxLinux.cpp)
-elseif (APPLE)
- target_sources(WebWorker PRIVATE ../RendererSandboxMacOS.cpp)
-else()
- target_sources(WebWorker PRIVATE ../RendererSandboxUnimplemented.cpp)
-endif()
-
-target_include_directories(WebWorker PRIVATE ${LADYBIRD_SOURCE_DIR})
-target_link_libraries(WebWorker PRIVATE webworkerservice LibSandbox OpenSSL::Crypto OpenSSL::SSL)
-
-if(WIN32)
- ladybird_windows_bin(WebWorker CONSOLE)
-endif()
-
-ladybird_sign_helper_process(WebWorker ALLOW_JIT)
diff --git a/Services/WebWorker/ConnectionFromClient.cpp b/Services/WebWorker/ConnectionFromClient.cpp
index 95a2db84b5c..65d997cea42 100644
--- a/Services/WebWorker/ConnectionFromClient.cpp
+++ b/Services/WebWorker/ConnectionFromClient.cpp
@@ -115,11 +115,6 @@ Web::Compositor::CompositorConnection* ConnectionFromClient::compositor_process_
return m_compositor_connection.ptr();
}
-void ConnectionFromClient::set_system_font_family(String family)
-{
- Web::Platform::FontPlugin::the().set_system_font_family(FlyString { family });
-}
-
void ConnectionFromClient::set_site_compatibility_data(JsonValue data)
{
auto parsed_data = Web::SiteCompatibilityData::from_json(data);
@@ -175,12 +170,9 @@ void ConnectionFromClient::die()
void ConnectionFromClient::did_lose_peer_during_sync_request()
{
- // NB: Whatever made the request cannot be unwound from here, and it cannot carry on without a response.
- if (m_host == Host::Process)
- Core::Process::terminate_immediately(0);
-
- // NB: A thread cannot take its process with it, so the script stops instead, and the request fails. That is every
- // caller's to handle, as the connection is shut down from the event loop the script returns to.
+ // NB: Whatever made the request cannot be unwound from here, and a thread cannot take its process with it. So, the
+ // script stops, and the request fails. That is every caller's to handle, as the connection is shut down from the
+ // event loop the script returns to.
m_script_abort_handle->abort_script();
deferred_invoke([this] {
shutdown();
@@ -251,11 +243,9 @@ void ConnectionFromClient::blob_url_entry_removed(Utf16String url)
Web::FileAPI::remove_entry_from_blob_url_store(*url_record);
}
-ConnectionFromClient::ConnectionFromClient(NonnullOwnPtr<IPC::Transport> transport, bool enable_test_mode, Host host)
+ConnectionFromClient::ConnectionFromClient(NonnullOwnPtr<IPC::Transport> transport)
: IPC::ConnectionFromClient<WebWorkerClientEndpoint, WebWorkerServerEndpoint>(*this, move(transport), 1)
, m_page_host(PageHost::create(*this))
- , m_enable_test_mode(enable_test_mode)
- , m_host(host)
, m_script_abort_handle(Web::HTML::surrounding_agent().script_abort_handle())
{
// The UI process started this worker agent, and die() ends it. So, once the UI process has closed the connection —
@@ -287,12 +277,6 @@ ConnectionFromClient::ConnectionFromClient(NonnullOwnPtr<IPC::Transport> transpo
ConnectionFromClient::~ConnectionFromClient() = default;
-void ConnectionFromClient::set_font_service(IPC::TransportHandle handle, IPC::File catalog, u64 catalog_size, u64 generation)
-{
- auto* font_provider = MUST(Compositing::install_font_service(move(handle), move(catalog), catalog_size, generation));
- Web::Platform::FontPlugin::install(*new Web::Platform::FontPlugin(m_enable_test_mode, font_provider));
-}
-
Web::Page& ConnectionFromClient::page()
{
return m_page_host->page();
diff --git a/Services/WebWorker/ConnectionFromClient.h b/Services/WebWorker/ConnectionFromClient.h
index 633cbecd6ff..a6304a96476 100644
--- a/Services/WebWorker/ConnectionFromClient.h
+++ b/Services/WebWorker/ConnectionFromClient.h
@@ -31,12 +31,6 @@ class ConnectionFromClient final
C_OBJECT(ConnectionFromClient);
public:
- // What the worker agent has to itself: a process that ends with it, or a thread in a process that goes on without it.
- enum class Host {
- Process,
- Thread,
- };
-
virtual ~ConnectionFromClient() override;
virtual void die() override;
@@ -49,7 +43,6 @@ public:
// are gone.
void shut_down_agent();
- virtual void set_font_service(IPC::TransportHandle, IPC::File catalog, u64 catalog_size, u64 generation) override;
virtual void close_worker() override;
void request_file(Web::FileRequest);
@@ -65,7 +58,7 @@ public:
ErrorOr<NonnullOwnPtr<IPC::Transport>> request_image_decoder_transport();
private:
- ConnectionFromClient(NonnullOwnPtr<IPC::Transport>, bool enable_test_mode, Host = Host::Process);
+ explicit ConnectionFromClient(NonnullOwnPtr<IPC::Transport>);
Web::Page& page();
Web::Page const& page() const;
@@ -78,7 +71,6 @@ private:
virtual void set_user_agent(String user_agent) override;
virtual void set_navigator_compatibility_mode(Web::NavigatorCompatibilityMode mode) override;
virtual void set_preferred_languages(Vector<String> preferred_languages) override;
- virtual void set_system_font_family(String family) override;
virtual void start_worker(URL::URL url, Web::HTML::WorkerType type, Web::HTML::RequestCredentials credentials, String name, Web::HTML::TransferDataEncoder, Web::HTML::SerializedEnvironmentSettingsObject, Web::HTML::AgentType, URL::Origin origin, Web::HTML::EnvironmentId environment_id, bool has_process_to_itself) override;
virtual void connect_shared_worker(Web::HTML::TransferDataEncoder, Web::HTML::SerializedEnvironmentSettingsObject) override;
virtual void handle_file_return(i32 error, Optional<IPC::File> file, i32 request_id) override;
@@ -112,9 +104,7 @@ private:
RefPtr<WorkerHost> m_worker_host;
Function<void()> m_request_server_died_callback_for_testing;
- bool m_enable_test_mode { false };
bool m_shutdown_finished { false };
- Host m_host { Host::Process };
NonnullRefPtr<Web::HTML::ScriptAbortHandle> m_script_abort_handle;
};
diff --git a/Services/WebWorker/WebWorkerServer.ipc b/Services/WebWorker/WebWorkerServer.ipc
index c444cf496ba..a1f50c540db 100644
--- a/Services/WebWorker/WebWorkerServer.ipc
+++ b/Services/WebWorker/WebWorkerServer.ipc
@@ -12,8 +12,6 @@
#include <LibWebCommon/Permissions/Permissions.h>
endpoint WebWorkerServer {
- set_font_service(IPC::TransportHandle handle, IPC::File catalog, u64 catalog_size, u64 generation) =|
-
connect_to_request_server(IPC::TransportHandle handle, int client_id, Optional<Utf16String> top_level_site) =|
simulate_request_server_connection_loss_and_reconnect_for_testing(IPC::TransportHandle replacement_handle, int client_id, Optional<Utf16String> top_level_site) => ()
connect_to_compositor(IPC::TransportHandle handle) =|
@@ -23,8 +21,6 @@ endpoint WebWorkerServer {
set_navigator_compatibility_mode(Web::NavigatorCompatibilityMode mode) =|
set_preferred_languages(Vector<String> preferred_languages) =|
- set_system_font_family(String family) =|
-
start_worker(URL::URL url,
Web::HTML::WorkerType type,
Web::HTML::RequestCredentials credentials,
diff --git a/Services/WebWorker/WorkerThread.cpp b/Services/WebWorker/WorkerThread.cpp
index 3ef17f905a7..8375c2ddad2 100644
--- a/Services/WebWorker/WorkerThread.cpp
+++ b/Services/WebWorker/WorkerThread.cpp
@@ -56,7 +56,7 @@ static intptr_t run_worker_thread(IPC::TransportHandle const& worker_handle, Web
worker_threads().event_loops.append(event_loop_reference);
}
- auto client = ConnectionFromClient::construct(transport_or_error.release_value(), false, ConnectionFromClient::Host::Thread);
+ auto client = ConnectionFromClient::construct(transport_or_error.release_value());
client->set_up_agent_services();
auto exit_code = event_loop.exec();
diff --git a/Services/WebWorker/main.cpp b/Services/WebWorker/main.cpp
deleted file mode 100644
index 2eafbf61dd8..00000000000
--- a/Services/WebWorker/main.cpp
+++ /dev/null
@@ -1,149 +0,0 @@
-/*
- * Copyright (c) 2023, Andrew Kaster <[email protected]>
- *
- * SPDX-License-Identifier: BSD-2-Clause
- */
-
-#include <LibCore/ArgsParser.h>
-#include <LibCore/CrashHandler.h>
-#include <LibCore/EventLoop.h>
-#include <LibCore/Platform/TaskRole.h>
-#include <LibCore/Platform/ThreadQoS.h>
-#include <LibCore/Process.h>
-#include <LibCore/StatsLog.h>
-#include <LibCore/System.h>
-#include <LibCrypto/OpenSSL.h>
-#include <LibCrypto/OpenSSLForward.h>
-#include <LibFileSystem/FileSystem.h>
-#include <LibIPC/SingleServer.h>
-#include <LibIPC/Transport.h>
-#include <LibMain/Main.h>
-#include <LibURL/Parser.h>
-#include <LibWeb/Bindings/MainThreadVM.h>
-#include <LibWeb/Fetch/Fetching/Fetching.h>
-#include <LibWeb/HTML/WindowOrWorkerGlobalScope.h>
-#include <LibWeb/Loader/GeneratedPagesLoader.h>
-#include <LibWeb/Loader/ResourceLoader.h>
-#include <LibWeb/Platform/EventLoopPlugin.h>
-#include <LibWebCommon/WebView/Utilities.h>
-#include <Services/RendererSandbox.h>
-#include <WebWorker/ConnectionFromClient.h>
-
-#include <openssl/thread.h>
-
-static ErrorOr<Web::HTML::AgentType> agent_type_from_string(StringView type)
-{
- if (type == "dedicated"sv)
- return Web::HTML::AgentType::DedicatedWorker;
- if (type == "shared"sv)
- return Web::HTML::AgentType::SharedWorker;
- if (type == "service"sv)
- return Web::HTML::AgentType::ServiceWorker;
-
- return Error::from_string_literal("Invalid worker type, must be one of: 'dedicated', 'shared', or 'service'");
-}
-
-ErrorOr<int> ladybird_main(Main::Arguments arguments)
-{
- AK::set_rich_debug_enabled(true);
-
- StringView serenity_resource_root;
- StringView worker_type_string;
- StringView mach_server_name;
- Vector<ByteString> certificates;
- bool expose_experimental_interfaces = false;
- bool enable_http_memory_cache = false;
- bool wait_for_debugger = false;
- bool file_origins_are_tuple_origins = false;
- bool disable_sandbox = false;
- bool enable_test_mode = false;
-
- int crash_report_fd = -1;
- StringView stats_log_directory;
- Core::ArgsParser args_parser;
- args_parser.add_option(stats_log_directory, "Directory for process statistics (JSON lines)", "stats-log-dir", 0, "path");
- args_parser.add_option(crash_report_fd, "Descriptor for anonymous crash diagnostics", "crash-report-fd", 0, "fd");
- args_parser.add_option(serenity_resource_root, "Absolute path to directory for serenity resources", "serenity-resource-root", 'r', "serenity-resource-root");
- args_parser.add_option(certificates, "Path to a certificate file", "certificate", 'C', "certificate");
- args_parser.add_option(expose_experimental_interfaces, "Expose experimental IDL interfaces", "expose-experimental-interfaces");
- args_parser.add_option(enable_http_memory_cache, "Enable HTTP cache", "enable-http-memory-cache");
- args_parser.add_option(wait_for_debugger, "Wait for debugger", "wait-for-debugger");
- args_parser.add_option(worker_type_string, "Type of WebWorker to start (dedicated, shared, or service)", "type", 't', "type");
- args_parser.add_option(mach_server_name, "Mach server name", "mach-server-name", 0, "mach_server_name");
- args_parser.add_option(file_origins_are_tuple_origins, "Treat file:// URLs as having tuple origins", "tuple-file-origins");
- args_parser.add_option(disable_sandbox, "Disable process sandboxing", "disable-sandbox");
- args_parser.add_option(enable_test_mode, "Enable test mode", "test-mode");
- args_parser.add_option(Core::ArgsParser::Option {
- .argument_mode = Core::ArgsParser::OptionArgumentMode::Required,
- .help_string = "URL of a PAC file (not supported yet, requests fail)",
- .long_name = "proxy-autoconfig-url",
- .value_name = "url",
- .accept_value = [&](StringView value) {
- auto url = URL::Parser::basic_parse(value);
- if (!url.has_value())
- return false;
- Web::ResourceLoader::set_proxy_autoconfig_url(url.release_value());
- return true;
- },
- });
-
- args_parser.parse(arguments);
-
- auto stats_log = TRY(Core::StatsLog::create(stats_log_directory, "WebWorker"sv));
-
- if (crash_report_fd >= 0) {
- if (auto result = Core::CrashHandler::initialize(crash_report_fd); result.is_error())
- warnln("Could not install crash report handler: {}", result.error());
- }
-
- if (wait_for_debugger)
- Core::Process::wait_for_debugger_and_break();
-
- if (auto result = Core::Platform::adopt_foreground_application_task_role(); result.is_error())
- warnln("Could not adopt the foreground application task role: {}", result.error());
-
- if (file_origins_are_tuple_origins)
- URL::set_file_scheme_urls_have_tuple_origins();
-
- auto worker_type = TRY(agent_type_from_string(worker_type_string));
-
- auto& event_loop = Core::EventLoop::initialize_for_current_thread();
-
- WebView::platform_init();
-
- if (enable_http_memory_cache)
- Web::Fetch::Fetching::set_http_memory_cache_enabled(true);
-
- OPENSSL_TRY(OSSL_set_max_threads(nullptr, Core::System::hardware_concurrency()));
-
- Web::HTML::WindowOrWorkerGlobalScopeMixin::set_experimental_interfaces_exposed(expose_experimental_interfaces);
-
- Web::Platform::EventLoopPlugin::install(*new Web::Platform::EventLoopPlugin);
-
- Web::Bindings::initialize_agent(worker_type);
- if (stats_log)
- JS::VM::the().heap().enable_stats();
-
- if (!disable_sandbox)
- TRY(RendererSandbox::apply_sandbox(mach_server_name));
-
- auto client = TRY(IPC::take_over_accepted_client_from_system_server<WebWorker::ConnectionFromClient>(mach_server_name, enable_test_mode));
-
- client->set_up_agent_services();
-
- auto& heap = JS::VM::the().heap();
- if (stats_log)
- stats_log->start_sampling([&heap](JsonObject& values) { heap.add_stats(values); });
-
- auto exit_code = event_loop.exec();
-
- // The worker has closed. This goes through its agent in order, as a thread that hosts a worker will have to, rather
- // than leave it all to the end of the process.
- stats_log = nullptr;
- client->shut_down_agent();
-
- // The client terminates a process that closes the connection, so the connection stays open until this process ends.
- (void)move(client).leak_ref();
-
- return exit_code;
-}
diff --git a/Tests/LibSandbox/TestHelperSandboxes.cpp b/Tests/LibSandbox/TestHelperSandboxes.cpp
index 7317737fd1a..98c67a267b8 100644
--- a/Tests/LibSandbox/TestHelperSandboxes.cpp
+++ b/Tests/LibSandbox/TestHelperSandboxes.cpp
@@ -193,13 +193,13 @@ TEST_CASE(helpers_run_with_the_hardened_runtime)
{
// With the hardened runtime, the kernel refuses to run code from memory that was writable, unless the process may
// map JIT memory. Only the renderers run code that they compile at runtime.
- for (auto name : { "AudioServer"sv, "Compositor"sv, "ImageDecoder"sv, "MediaServer"sv, "ProcessReaper"sv, "RequestServer"sv, "WebContent"sv, "WebWorker"sv }) {
+ for (auto name : { "AudioServer"sv, "Compositor"sv, "ImageDecoder"sv, "MediaServer"sv, "ProcessReaper"sv, "RequestServer"sv, "WebContent"sv }) {
auto signature = signature_of_helper(name);
if (!signature.has_value()) {
warnln("Skipping {}, which was not built", name);
continue;
}
EXPECT(signature->uses_hardened_runtime);
- EXPECT_EQ(signature->may_map_jit_memory, name == "WebContent"sv || name == "WebWorker"sv);
+ EXPECT_EQ(signature->may_map_jit_memory, name == "WebContent"sv);
}
}
diff --git a/Tests/LibWeb/AccessibilityBridgeMac/diagnose.py b/Tests/LibWeb/AccessibilityBridgeMac/diagnose.py
index 5583c55a19c..9a2af0c1bba 100644
--- a/Tests/LibWeb/AccessibilityBridgeMac/diagnose.py
+++ b/Tests/LibWeb/AccessibilityBridgeMac/diagnose.py
@@ -88,7 +88,7 @@ REPO_ROOT = pathlib.Path(__file__).resolve().parents[3]
DEFAULT_BINARY = REPO_ROOT / "Build" / "release" / "bin" / "Ladybird.app" / "Contents" / "MacOS" / "Ladybird"
FIXTURE = pathlib.Path(__file__).resolve().parents[1] / "AccessibilityBridge" / "input" / "roles.html"
-HELPER_NAMES = ("WebContent", "RequestServer", "ImageDecoder", "Compositor", "WebWorker", "WebDriver")
+HELPER_NAMES = ("WebContent", "RequestServer", "ImageDecoder", "Compositor", "WebDriver")
AX_ERROR_NAMES = {
0: "success",
@@ -993,7 +993,7 @@ class Probe:
except Exception:
continue
for entry in entries:
- if not re.match(r"(Ladybird|WebContent|RequestServer|ImageDecoder|Compositor|WebWorker)", entry.name):
+ if not re.match(r"(Ladybird|WebContent|RequestServer|ImageDecoder|Compositor)", entry.name):
continue
try:
if entry.stat().st_mtime < cutoff:
diff --git a/Tests/LibWeb/test-web/TestRunCapture.cpp b/Tests/LibWeb/test-web/TestRunCapture.cpp
index cc92de652e2..4f2338e7861 100644
--- a/Tests/LibWeb/test-web/TestRunCapture.cpp
+++ b/Tests/LibWeb/test-web/TestRunCapture.cpp
@@ -23,7 +23,6 @@ namespace TestWeb {
static ByteString format_elapsed_time(UnixDateTime run_start_time);
static ByteString format_exit_status(Optional<int> exit_status);
-static bool exit_status_is_crash(Optional<int> exit_status);
static bool is_crash_of_worker(WebView::ProcessType, Optional<int> exit_status);
static void setup_capture_notifier(RefPtr<Core::Notifier>& notifier, Core::File& file, bool drain_available, Function<void(StringView)> on_output);
static bool drain_capture_output(Core::File& file, bool drain_available, Function<void(StringView)> const& on_output);
@@ -146,31 +145,13 @@ static ByteString format_exit_status(Optional<int> exit_status)
#endif
}
-bool exit_status_is_crash(Optional<int> exit_status)
-{
-#if defined(AK_OS_WINDOWS)
- (void)exit_status;
- return false;
-#else
- if (!exit_status.has_value())
- return false;
-
- // NB: A crash handler ends the process with a status of 128 plus the signal.
- if (WIFEXITED(*exit_status))
- return WEXITSTATUS(*exit_status) >= 128;
-
- // NB: The UI process kills a worker that does not exit in time, so being killed is no crash.
- return WIFSIGNALED(*exit_status) && !first_is_one_of(WTERMSIG(*exit_status), SIGKILL, SIGTERM);
-#endif
-}
-
-// NB: A dedicated worker runs on a thread of a WebContent process that can go down between tests, or be the process of
-// a remote frame, where no test would notice.
+// NB: A worker runs on a thread of a WebContent process that can go down between tests, or be the process of a remote
+// frame or of nothing but shared workers, where no test would notice.
bool is_crash_of_worker(WebView::ProcessType type, Optional<int> exit_status)
{
- if (type == WebView::ProcessType::WebWorker)
- return exit_status_is_crash(exit_status);
#if defined(AK_OS_WINDOWS)
+ (void)type;
+ (void)exit_status;
return false;
#else
return type == WebView::ProcessType::WebContent && exit_status.has_value() && WIFEXITED(*exit_status)
diff --git a/Tests/LibWebView/CMakeLists.txt b/Tests/LibWebView/CMakeLists.txt
index d5766abe7ef..0f843cd029e 100644
--- a/Tests/LibWebView/CMakeLists.txt
+++ b/Tests/LibWebView/CMakeLists.txt
@@ -13,7 +13,7 @@ if (BUILD_TESTING AND NOT WIN32)
ladybird_python_test(test-window-size-reaches-every-page.py ARGS $<TARGET_FILE:ladybird>)
ladybird_python_test(test-worker-error-console.py ARGS $<TARGET_FILE:ladybird>)
- foreach(helper IN ITEMS Compositor ImageDecoder RequestServer WebWorker)
+ foreach(helper IN ITEMS Compositor ImageDecoder RequestServer)
ladybird_python_test(test-webdriver-crash-report.py
NAME Test${helper}CrashReport
ARGS $<TARGET_FILE:WebDriver> --process ${helper}
diff --git a/Tests/LibWebView/TestCrashReport.cpp b/Tests/LibWebView/TestCrashReport.cpp
index 9c2679972bf..1588d27a6d8 100644
--- a/Tests/LibWebView/TestCrashReport.cpp
+++ b/Tests/LibWebView/TestCrashReport.cpp
@@ -323,12 +323,12 @@ TEST_CASE(helper_process_names)
{
cleanup();
ScopeGuard guard = cleanup;
- for (auto type : { WebView::ProcessType::WebContent, WebView::ProcessType::WebWorker, WebView::ProcessType::RequestServer, WebView::ProcessType::ImageDecoder, WebView::ProcessType::MediaServer, WebView::ProcessType::Compositor }) {
+ for (auto type : { WebView::ProcessType::WebContent, WebView::ProcessType::RequestServer, WebView::ProcessType::ImageDecoder, WebView::ProcessType::MediaServer, WebView::ProcessType::Compositor }) {
auto report = MUST(WebView::CrashReport::create(type));
MUST(report->save(SIGSEGV, test_directory()));
}
auto paths = report_paths();
- EXPECT_EQ(paths.size(), 6u);
+ EXPECT_EQ(paths.size(), 5u);
for (auto const& path : paths) {
auto file = MUST(Core::File::open(path, Core::File::OpenMode::Read));
auto contents = MUST(file->read_until_eof());
diff --git a/Tests/LibWebView/TestHelperProcessEnvironment.cpp b/Tests/LibWebView/TestHelperProcessEnvironment.cpp
index d0e7b2ae36c..c4fcdd7827d 100644
--- a/Tests/LibWebView/TestHelperProcessEnvironment.cpp
+++ b/Tests/LibWebView/TestHelperProcessEnvironment.cpp
@@ -41,7 +41,7 @@ TEST_CASE(helper_environment_keeps_loader_and_session_variables_out)
MUST(Core::Environment::set("OPENSSL_CONF"sv, "/tmp/openssl.cnf"sv, Core::Environment::Overwrite::Yes));
MUST(Core::Environment::set("XDG_RUNTIME_DIR"sv, "/run/user/1000"sv, Core::Environment::Overwrite::Yes));
- for (auto type : { WebView::ProcessType::Compositor, WebView::ProcessType::WebContent, WebView::ProcessType::WebWorker, WebView::ProcessType::RequestServer, WebView::ProcessType::ImageDecoder, WebView::ProcessType::MediaServer, WebView::ProcessType::AudioServer }) {
+ for (auto type : { WebView::ProcessType::Compositor, WebView::ProcessType::WebContent, WebView::ProcessType::RequestServer, WebView::ProcessType::ImageDecoder, WebView::ProcessType::MediaServer, WebView::ProcessType::AudioServer }) {
auto environment = WebView::Process::helper_process_environment(type);
EXPECT(!environment.contains_slow("LD_PRELOAD=/tmp/evil.so"sv));
EXPECT(!environment.contains_slow("LD_LIBRARY_PATH=/tmp"sv));
@@ -71,8 +71,6 @@ TEST_CASE(helper_environment_gives_each_helper_only_its_own_configuration)
EXPECT(audio_server_environment.contains_slow("PULSE_SERVER=unix:/run/user/1000/pulse/native"sv));
EXPECT(!audio_server_environment.contains_slow("MESA_SHADER_CACHE_DIR=/tmp/mesa"sv));
EXPECT(!audio_server_environment.contains_slow("SSL_CERT_FILE=/etc/ssl/cert.pem"sv));
- auto web_worker_environment = WebView::Process::helper_process_environment(WebView::ProcessType::WebWorker);
- EXPECT(!web_worker_environment.contains_slow("PULSE_SERVER=unix:/run/user/1000/pulse/native"sv));
// Only the Compositor talks to the GPU driver.
auto compositor_environment = WebView::Process::helper_process_environment(WebView::ProcessType::Compositor);
diff --git a/Tests/LibWebView/test-webdriver-crash-report.py b/Tests/LibWebView/test-webdriver-crash-report.py
index e9f6a61c70d..cafa6343b35 100755
--- a/Tests/LibWebView/test-webdriver-crash-report.py
+++ b/Tests/LibWebView/test-webdriver-crash-report.py
@@ -91,25 +91,7 @@ def run_test(webdriver_binary, process_name):
)
assert status == 200, body
else:
- if process_name == "WebWorker":
- status, payload, body = webdriver_helpers.request(
- port,
- "POST",
- f"/session/{session}/execute/async",
- {
- "script": """
- const done = arguments[0];
- window.worker = new SharedWorker(URL.createObjectURL(new Blob([
- "onconnect = ({ ports }) => ports[0].postMessage('ready');"
- ], {type: 'text/javascript'})));
- worker.port.onmessage = () => done();
- worker.onerror = () => done('worker failed');
- """,
- "args": [],
- },
- )
- assert status == 200 and payload == {"value": None}, body
- elif process_name == "ImageDecoder":
+ if process_name == "ImageDecoder":
# A process gets its decoder when it first has an image to decode.
status, payload, body = webdriver_helpers.request(
port,
@@ -183,7 +165,7 @@ if __name__ == "__main__":
parser.add_argument(
"--process",
default="WebContent",
- choices=["WebContent", "WebWorker", "RequestServer", "ImageDecoder", "Compositor"],
+ choices=["WebContent", "RequestServer", "ImageDecoder", "Compositor"],
)
args = parser.parse_args()
run_test(args.webdriver_binary, args.process)
diff --git a/Tests/LibWebView/test-webdriver-worker-terminated-while-starting.py b/Tests/LibWebView/test-webdriver-worker-terminated-while-starting.py
index bd18b4db0af..c0210ae5608 100755
--- a/Tests/LibWebView/test-webdriver-worker-terminated-while-starting.py
+++ b/Tests/LibWebView/test-webdriver-worker-terminated-while-starting.py
@@ -7,7 +7,6 @@
import argparse
import importlib
import os
-import shlex
import subprocess
import tempfile
import time
@@ -16,32 +15,13 @@ from pathlib import Path
webdriver_helpers = importlib.import_module("test-webdriver-delete-session")
-# Terminate a worker at each of these delays after constructing it, to catch its process at every stage of starting up.
+# Terminate a worker at each of these delays after constructing it, to catch its thread at every stage of starting up.
TERMINATE_DELAYS_MS = list(range(0, 600, 25))
-# How long a crashed worker's report gets to show up, once every worker process is gone.
+# How long a crashed worker's report gets to show up.
CRASH_REPORT_GRACE_SECONDS = 2
-def descendants_named(root_pid, process_name):
- rows = subprocess.check_output(["ps", "-axo", "pid=,ppid=,command="], text=True).splitlines()
- children = {}
- for row in rows:
- fields = row.strip().split(None, 2)
- pid, parent = fields[:2]
- command = fields[2] if len(fields) == 3 else ""
- children.setdefault(int(parent), []).append((int(pid), command))
- pending = [root_pid]
- descendants = []
- while pending:
- for pid, command in children.get(pending.pop(), []):
- pending.append(pid)
- arguments = shlex.split(command)
- if arguments and Path(arguments[0]).name == process_name:
- descendants.append(pid)
- return descendants
-
-
def run_test(webdriver_binary):
with tempfile.TemporaryDirectory(prefix="ladybird-worker-terminated-") as temporary:
environment = os.environ.copy()
@@ -91,8 +71,6 @@ def run_test(webdriver_binary):
)
assert status == 200 and payload == {"value": None}, body
- assert not descendants_named(webdriver.pid, "WebWorker"), "A dedicated worker got a process"
-
# A worker that crashes on its way out takes the WebContent process that hosts it along.
time.sleep(CRASH_REPORT_GRACE_SECONDS)
reports = list((profile / "data/CrashReports").glob("*-WebContent-*.txt"))
diff --git a/Tests/UI/Qt/TestProcessManagerWindow.cpp b/Tests/UI/Qt/TestProcessManagerWindow.cpp
index d86b292bdd5..e9527d66c02 100644
--- a/Tests/UI/Qt/TestProcessManagerWindow.cpp
+++ b/Tests/UI/Qt/TestProcessManagerWindow.cpp
@@ -250,21 +250,18 @@ TEST_CASE(helper_processes_are_listed_with_the_site_they_work_for)
return identity.child_id;
};
- // A worker of an opaque origin has no site of its own, and its helpers are listed with the page that started it.
+ // A page's helpers are listed with it, also those that work for another of its helpers.
auto page = add_process(WebView::ProcessType::WebContent, {}, "https://example.com/"sv);
- auto worker = add_process(WebView::ProcessType::WebWorker, page, {});
- add_process(WebView::ProcessType::ImageDecoder, worker, {});
- add_process(WebView::ProcessType::AudioServer, worker, {});
- add_process(WebView::ProcessType::MediaServer, page, {});
- // A shared worker outlives the page that started it, and is then listed with the site of its own origin.
- auto gone_page = add_process(WebView::ProcessType::WebContent, {}, "https://example.org/"sv);
- auto surviving_worker = add_process(WebView::ProcessType::WebWorker, gone_page, "https://example.org"sv);
- add_process(WebView::ProcessType::ImageDecoder, surviving_worker, {});
- (void)manager.remove_process(gone_page);
+ add_process(WebView::ProcessType::ImageDecoder, page, {});
+ auto media_server = add_process(WebView::ProcessType::MediaServer, page, {});
+ add_process(WebView::ProcessType::AudioServer, media_server, {});
+ // A process runs on without pages for a shared worker, and is then listed with the site of the worker's origin.
+ auto worker_host = add_process(WebView::ProcessType::WebContent, {}, "https://example.org"sv);
+ add_process(WebView::ProcessType::ImageDecoder, worker_host, {});
- // With top-level site isolation, a cross-site frame shares its parent's process. Its worker has its own site.
- auto frame_worker = add_process(WebView::ProcessType::WebWorker, page, "https://example.net"sv);
- add_process(WebView::ProcessType::ImageDecoder, frame_worker, {});
+ // With top-level site isolation, a cross-site frame's shared worker can have a process to itself.
+ auto frame_worker_host = add_process(WebView::ProcessType::WebContent, {}, "https://example.net"sv);
+ add_process(WebView::ProcessType::ImageDecoder, frame_worker_host, {});
Ladybird::ProcessManagerWindow window(manager);
window.show();
@@ -279,7 +276,7 @@ TEST_CASE(helper_processes_are_listed_with_the_site_they_work_for)
// The browser, the sites heading, and the three sites.
EXPECT_EQ(processes->topLevelItemCount(), 5);
- EXPECT_EQ(child_count_of_site("example.com"), 5);
+ EXPECT_EQ(child_count_of_site("example.com"), 4);
EXPECT_EQ(child_count_of_site("example.org"), 2);
EXPECT_EQ(child_count_of_site("example.net"), 2);
}
diff --git a/UI/Qt/ProcessManagerWindow.cpp b/UI/Qt/ProcessManagerWindow.cpp
index 3169353f060..2ee229fca4e 100644
--- a/UI/Qt/ProcessManagerWindow.cpp
+++ b/UI/Qt/ProcessManagerWindow.cpp
@@ -621,14 +621,14 @@ void ProcessManagerWindow::refresh()
auto is_spare = [](WebView::ProcessSnapshot const& process) {
return process.type == WebView::ProcessType::WebContent && process.title.has_value() && *process.title == "(spare)"_utf16;
};
- // NB: A page's process, a worker's process, and a request server or image decoder bound to a site, belong to that site.
+ // NB: A page's process, a process that runs on for a shared worker, and a request server or image decoder bound to a
+ // site, belong to that site.
auto site_of = [](WebView::ProcessSnapshot const& process) -> QString {
- if (!first_is_one_of(process.type, WebView::ProcessType::WebContent, WebView::ProcessType::WebWorker, WebView::ProcessType::RequestServer, WebView::ProcessType::ImageDecoder) || !process.site_url.has_value())
+ if (!first_is_one_of(process.type, WebView::ProcessType::WebContent, WebView::ProcessType::RequestServer, WebView::ProcessType::ImageDecoder) || !process.site_url.has_value())
return {};
return task_manager_site_label(*process.site_url);
};
- // NB: A process that works for another may itself work for a third, as a worker's media server works for the
- // worker. A worker with its own site stays with that site; an opaque-origin worker follows its owner.
+ // NB: A process that works for another may itself work for a third.
auto section_process = [&](WebView::ProcessSnapshot const& process) -> WebView::ProcessSnapshot const& {
auto const* section = &process;
for (size_t depth = 0; depth < processes.size() && section->owner_child_id.has_value() && site_of(*section).isEmpty(); ++depth) {