From 52f64e7e39f8ba7734ffae0f3a73dfb896cc6737 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20Qu=C3=A8ze?= Date: Fri, 11 Sep 2026 11:26:54 +0000 Subject: [PATCH] Bug 2070925 - Make setDebuggerReady(false) suspend the debuggee again, r=edenchuang,dom-worker-reviewers. The hold suspended nothing: !mDebuggerReady && !mRemoteDebuggerReady can never both be true, since the two flags are cleared on mutually exclusive UseRemoteDebugger() branches. So no debuggee runnable has been queued since Bug 1899503. Restoring the hold means the three flush sites drop the mDebuggerRegistered term, which a remote worker never sets, and which RegisterDebuggerMainThread has normally already set for a local one. Differential Revision: https://phabricator.services.mozilla.com/D325036 --- dom/workers/WorkerPrivate.cpp | 19 +++++++------------ dom/workers/WorkerPrivate.h | 5 +++-- 2 files changed, 10 insertions(+), 14 deletions(-) diff --git a/dom/workers/WorkerPrivate.cpp b/dom/workers/WorkerPrivate.cpp index 938bed300d89..e0b4cf2a624f 100644 --- a/dom/workers/WorkerPrivate.cpp +++ b/dom/workers/WorkerPrivate.cpp @@ -1641,11 +1641,10 @@ nsresult WorkerPrivate::DispatchLockHeld( return NS_ERROR_UNEXPECTED; } - // Postpone the debuggee runnable dispatching while remote debugger - // registration - if (runnable->IsDebuggeeRunnable() && !mDebuggerReady && - !mRemoteDebuggerReady && - (!mRemoteDebuggerRegistered && XRE_IsParentProcess())) { + // Suspend the debuggee while the debugger has asked us to, through either the + // local or the remote mechanism. + if (runnable->IsDebuggeeRunnable() && + !(mDebuggerReady && mRemoteDebuggerReady)) { MOZ_RELEASE_ASSERT(!aSyncLoopTarget); mDelayedDebuggeeRunnables.AppendElement(runnable); return NS_OK; @@ -1796,8 +1795,7 @@ void WorkerPrivate::SetIsRemoteDebuggerRegistered(const bool& aRegistered) { MOZ_ASSERT(mRemoteDebuggerRegistered != aRegistered); mRemoteDebuggerRegistered = aRegistered; - bool debuggerRegistered = mDebuggerRegistered && mRemoteDebuggerRegistered; - if (mRemoteDebuggerReady && mDebuggerReady && debuggerRegistered) { + if (mRemoteDebuggerReady && mDebuggerReady) { LOGV( ("WorkerPrivate::SetIsRemoteDebuggerRegistered [%p] dispatching " "the delayed debuggee runnables", @@ -1856,7 +1854,7 @@ void WorkerPrivate::SetIsRemoteDebuggerReady(const bool& aReady) { mRemoteDebuggerReady = aReady; - if (mRemoteDebuggerReady && mDebuggerReady && debuggerRegistered) { + if (mRemoteDebuggerReady && mDebuggerReady) { LOGV( ("WorkerPrivate::SetIsRemoteDebuggerReady [%p] dispatching " "the delayed debuggee runnables", @@ -3384,10 +3382,7 @@ nsresult WorkerPrivate::SetIsDebuggerReady(bool aReady) { mDebuggerReady = aReady; - bool debuggerRegistered = mDebuggerRegistered && (mRemoteDebuggerRegistered || - XRE_IsParentProcess()); - - if (aReady && debuggerRegistered) { + if (mDebuggerReady && mRemoteDebuggerReady) { // Dispatch all the delayed runnables without releasing the lock, to ensure // that the order in which debuggee runnables execute is the same as the // order in which they were originally dispatched. diff --git a/dom/workers/WorkerPrivate.h b/dom/workers/WorkerPrivate.h index 337e9dd2f9df..ec35bf6331cd 100644 --- a/dom/workers/WorkerPrivate.h +++ b/dom/workers/WorkerPrivate.h @@ -1121,8 +1121,9 @@ class WorkerPrivate final // Whether this worker exposes its debugger through the parent-process // RemoteWorkerDebugger mechanism (true) or registers its nsIWorkerDebugger on // the local main thread (false). Latched at construction from - // dom.worker.remoteDebugger.enabled; always false in the parent process. The - // two mechanisms are mutually exclusive for a given worker. + // dom.worker.remoteDebugger.enabled, and for a parent-process worker also + // from RemoteWorkerService::IsInitialized(); see the mUseRemoteDebugger + // initializer. The two mechanisms are mutually exclusive for a given worker. bool UseRemoteDebugger() const { return mUseRemoteDebugger; } void SetIsQueued(const bool& aQueued);