63 lines
2.6 KiB
Diff
63 lines
2.6 KiB
Diff
From: uazo <uazo@users.noreply.github.com>
|
|
Date: Sat, 24 Jan 2026 16:40:11 +0000
|
|
Subject: Immediately destroy shared workers when closing the page
|
|
|
|
Chromium is planning to keep shared workers active even after the page is closed,
|
|
up to a timeout, to compensate for the permanent deactivation of the unload event.
|
|
This feature is used to send pings from the page.
|
|
Cromite already does not allow any information to be sent via the network to the unload event.
|
|
|
|
License: GPL-2.0-or-later - https://spdx.org/licenses/GPL-2.0-or-later.html
|
|
---
|
|
.../browser/worker_host/shared_worker_host.cc | 23 +------------------
|
|
1 file changed, 1 insertion(+), 22 deletions(-)
|
|
|
|
diff --git a/content/browser/worker_host/shared_worker_host.cc b/content/browser/worker_host/shared_worker_host.cc
|
|
--- a/content/browser/worker_host/shared_worker_host.cc
|
|
+++ b/content/browser/worker_host/shared_worker_host.cc
|
|
@@ -71,7 +71,7 @@ namespace {
|
|
// TODO(crbug.com/400473072): revisit the duration.
|
|
// Also, we may want to use the same constant we use for service workers.
|
|
// Current value come from `ServiceWorkerVersion::kRequestTimeout`.
|
|
-constexpr base::TimeDelta kSharedWorkerDestructionDelay = base::Minutes(5);
|
|
+// constexpr base::TimeDelta kSharedWorkerDestructionDelay = base::Minutes(5);
|
|
|
|
// These values are persisted to logs. Entries should not be renumbered and
|
|
// numeric values should never be reused.
|
|
@@ -1107,16 +1107,6 @@ void SharedWorkerHost::OnClientStateChanged() {
|
|
worker_->Resume();
|
|
is_frozen_ = false;
|
|
} else if (!is_frozen_ && !has_active_client) {
|
|
- if (instance_.extended_lifetime()) {
|
|
- // If the worker has extended lifetime, it will be frozen after a delay
|
|
- // if there are no active clients.
|
|
- base::SingleThreadTaskRunner::GetCurrentDefault()->PostDelayedTask(
|
|
- FROM_HERE,
|
|
- base::BindOnce(&SharedWorkerHost::FreezeIfNoActiveClient,
|
|
- weak_factory_.GetWeakPtr()),
|
|
- kSharedWorkerDestructionDelay);
|
|
- return;
|
|
- }
|
|
worker_->Freeze();
|
|
is_frozen_ = true;
|
|
}
|
|
@@ -1171,17 +1161,6 @@ void SharedWorkerHost::OnClientConnectionLost() {
|
|
// the freeze state to freeze the worker if no active clients remain.
|
|
OnClientStateChanged();
|
|
}
|
|
- if (instance_.extended_lifetime()) {
|
|
- if (!clients_.empty()) { // Early return.
|
|
- return;
|
|
- }
|
|
- base::SingleThreadTaskRunner::GetCurrentDefault()->PostDelayedTask(
|
|
- FROM_HERE,
|
|
- base::BindOnce(&SharedWorkerHost::DestructIfNoClients,
|
|
- weak_factory_.GetWeakPtr()),
|
|
- kSharedWorkerDestructionDelay);
|
|
- return;
|
|
- }
|
|
DestructIfNoClients();
|
|
}
|
|
|
|
--
|