Files
electron/patches/chromium/worker_context_will_destroy.patch
electron-roller[bot] a90ccc753b chore: bump chromium to 145.0.7577.0 (main) (#49175)
* chore: bump chromium in DEPS to 145.0.7572.0

* chore: update patches (trivial only)

* chore(patch-conflict): feat_filter_out_non-shareable_windows_in_the_current_application_in.patch

Polished the edits and formatted the result. No real changes.

Ref: https://chromium-review.googlesource.com/c/chromium/src/+/7232079 "7232079: Use WindowsToExclude to exclude PiP window in macOS screencapture device"

* chore(patch-conflict): feat_add_support_for_missing_dialog_features_to_shell_dialogs.patch

Ref: https://chromium-review.googlesource.com/c/chromium/src/+/7214586 "7214586: Refactor SelectFileDialogLinuxPortal to request XDG portal on demand"
Ref: https://chromium-review.googlesource.com/c/chromium/src/+/7237910 "7237910: Remove g_gtk_ui global"

* 7228586: Migrate SystemMemoryInfo from ByteCount to ByteSize

Ref: https://chromium-review.googlesource.com/c/chromium/src/+/7228586

* 7207583: GlobalRenderFrameHostId to ChildProcessId

Ref: https://chromium-review.googlesource.com/c/chromium/src/+/7207583

* 7205548: Remove uses of BodyAsStringCallbackDeprecated (extensions/)

Ref: https://chromium-review.googlesource.com/c/chromium/src/+/7205548

* chore: bump chromium in DEPS to 145.0.7574.0

* chore: update libc++ filenames

* chore: update patches (trivial only)

* chore(patch-conflict): feat_filter_out_non-shareable_windows_in_the_current_application_in.patch

Ref: https://chromium-review.googlesource.com/c/chromium/src/+/7246150 "7246150: Fix crash in ScreenCaptureKitDeviceMac due to null PIPScreenCaptureCoordinator"

* fixup! chore(patch-conflict): feat_add_support_for_missing_dialog_features_to_shell_dialogs.patch

* fixup! chore(patch-conflict): feat_filter_out_non-shareable_windows_in_the_current_application_in.patch

* 7239572: [OOPIF PDF] Enable OOPIF PDF by default on Windows/macOS/Linux

Ref: https://chromium-review.googlesource.com/c/chromium/src/+/7239572

* chore: bump chromium in DEPS to 145.0.7576.0

* fixup! chore(patch-conflict): feat_add_support_for_missing_dialog_features_to_shell_dialogs.patch

* chore: update patches (trivial only)

* chore: add note to keep patch that was upstreamed but reverted

fix_restore_original_resize_performance_on_macos.patch was organically upstreamed but that change got reverted just after the current roll's cutoff.

I've added a note in the patch contents so the patch sticks around and so we can keep it after the revert is included.

Ref: https://chromium-review.googlesource.com/c/chromium/src/+/7255334 "7255334: Revert 'Fix jank when resizing browser window'"

* chore: bump chromium in DEPS to 145.0.7577.0

* chore: update patches (trivial only)

* chore(patch-conflict): keep patch after revert

Ref: https://chromium-review.googlesource.com/c/chromium/src/+/7255334 "7255334: Revert 'Fix jank when resizing browser window'"

* 7237910: Remove g_gtk_ui global

I tried to find a way to avoid the patch, but other approaches seemed complex and involved.

Ref: https://chromium-review.googlesource.com/c/chromium/src/+/7237910

* 7251900: Reland "Remove callback_helpers.h include from is_callback.h (try 5)"

Ref: https://chromium-review.googlesource.com/c/chromium/src/+/7251900

* 7170174: [LNA] Retry requests for cached local resources

Ref: https://chromium-review.googlesource.com/c/chromium/src/+/7170174

* fix: PDFs use OOPIF (behavior change)

* fixup! 7237910: Remove g_gtk_ui global

* fixup! 7251900: Reland "Remove callback_helpers.h include from is_callback.h (try 5)"

---------

Co-authored-by: electron-roller[bot] <84116207+electron-roller[bot]@users.noreply.github.com>
Co-authored-by: clavin <clavin@electronjs.org>
2025-12-16 12:32:38 -05:00

86 lines
4.4 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Cheng Zhao <zcbenz@gmail.com>
Date: Thu, 20 Sep 2018 17:47:12 -0700
Subject: worker_context_will_destroy.patch
This adds a hook for worker context destruction, which we use in Electron to
shutdown node integration in the worker if relevant.
An attempt to upstream this was made, but rejected:
https://chromium-review.googlesource.com/c/chromium/src/+/1954347
diff --git a/content/public/renderer/content_renderer_client.h b/content/public/renderer/content_renderer_client.h
index 36b734254b0c5836e9765f52587b7a1967c5c486..b7c3a63d126c1f8d83673c456d71c946d50ca067 100644
--- a/content/public/renderer/content_renderer_client.h
+++ b/content/public/renderer/content_renderer_client.h
@@ -418,6 +418,11 @@ class CONTENT_EXPORT ContentRendererClient {
virtual void DidInitializeWorkerContextOnWorkerThread(
v8::Local<v8::Context> context) {}
+ // Notifies that a worker context will be destroyed. This function is called
+ // from the worker thread.
+ virtual void WillDestroyWorkerContextOnWorkerThread(
+ v8::Local<v8::Context> context) {}
+
// Overwrites the given URL to use an HTML5 embed if possible.
// An empty URL is returned if the URL is not overriden.
virtual GURL OverrideFlashEmbedWithHTML(const GURL& url);
diff --git a/content/renderer/renderer_blink_platform_impl.cc b/content/renderer/renderer_blink_platform_impl.cc
index 65e33db544f8c469ec7de31ddd02686f67f74e01..4f7a8cbceed9ebcf12e5f794b11fb8731f2ee32d 100644
--- a/content/renderer/renderer_blink_platform_impl.cc
+++ b/content/renderer/renderer_blink_platform_impl.cc
@@ -902,6 +902,12 @@ void RendererBlinkPlatformImpl::WillStopWorkerThread() {
WorkerThreadRegistry::Instance()->WillStopCurrentWorkerThread();
}
+void RendererBlinkPlatformImpl::WorkerContextWillDestroy(
+ const v8::Local<v8::Context>& worker) {
+ GetContentClient()->renderer()->WillDestroyWorkerContextOnWorkerThread(
+ worker);
+}
+
void RendererBlinkPlatformImpl::WorkerContextCreated(
const v8::Local<v8::Context>& worker) {
GetContentClient()->renderer()->DidInitializeWorkerContextOnWorkerThread(
diff --git a/content/renderer/renderer_blink_platform_impl.h b/content/renderer/renderer_blink_platform_impl.h
index 59f5f44ff05efdca28ff6c8a98c08b9548dbdb29..ed6d7f641fbc06f4600106affcc3230b14f19f4a 100644
--- a/content/renderer/renderer_blink_platform_impl.h
+++ b/content/renderer/renderer_blink_platform_impl.h
@@ -205,6 +205,7 @@ class CONTENT_EXPORT RendererBlinkPlatformImpl : public BlinkPlatformImpl {
void DidStartWorkerThread() override;
void WillStopWorkerThread() override;
void WorkerContextCreated(const v8::Local<v8::Context>& worker) override;
+ void WorkerContextWillDestroy(const v8::Local<v8::Context>& worker) override;
bool AllowScriptExtensionForServiceWorker(
const blink::WebSecurityOrigin& script_origin) override;
blink::ProtocolHandlerSecurityLevel GetProtocolHandlerSecurityLevel(
diff --git a/third_party/blink/public/platform/platform.h b/third_party/blink/public/platform/platform.h
index 25ec1590ee683f5b913a8eca6413848587ed47e0..c778f0c3064a1cadb5972130278c4cb51d72da68 100644
--- a/third_party/blink/public/platform/platform.h
+++ b/third_party/blink/public/platform/platform.h
@@ -673,6 +673,7 @@ class BLINK_PLATFORM_EXPORT Platform {
virtual void DidStartWorkerThread() {}
virtual void WillStopWorkerThread() {}
virtual void WorkerContextCreated(const v8::Local<v8::Context>& worker) {}
+ virtual void WorkerContextWillDestroy(const v8::Local<v8::Context>& worker) {}
virtual bool AllowScriptExtensionForServiceWorker(
const WebSecurityOrigin& script_origin) {
return false;
diff --git a/third_party/blink/renderer/core/workers/worker_thread.cc b/third_party/blink/renderer/core/workers/worker_thread.cc
index 0660054931e295abafb420ce567f6b45d9af39d6..bea00fa0a9faaa0c0e7fa5b444c1e485d1e883d1 100644
--- a/third_party/blink/renderer/core/workers/worker_thread.cc
+++ b/third_party/blink/renderer/core/workers/worker_thread.cc
@@ -824,6 +824,12 @@ void WorkerThread::PrepareForShutdownOnWorkerThread() {
}
pause_handle_.reset();
+ {
+ v8::HandleScope handle_scope(GetIsolate());
+ Platform::Current()->WorkerContextWillDestroy(
+ GlobalScope()->ScriptController()->GetContext());
+ }
+
if (WorkerThreadDebugger* debugger = WorkerThreadDebugger::From(GetIsolate()))
debugger->WorkerThreadDestroyed(this);