Browse Source

sync with release again

Frank-Rainer Grahl 7 months ago
parent
commit
e38ed22b5c

+ 84 - 0
frg/work-js/mozilla-release/patches/1867982-124a1.patch

@@ -0,0 +1,84 @@
+# HG changeset patch
+# User Jens Stutte <jstutte@mozilla.com>
+# Date 1706285430 0
+# Node ID 233014f304aef171ed885462d999df30dce7d497
+# Parent  51f3e018ad5ae830eff13b15f49293d9d8f2e909
+Bug 1867982 - Check if WorkerRunnable::Run runs on top of WorkerThreadPrimaryRunnable::Run in a worker thread. r=dom-worker-reviewers,smaug,asuth
+
+Differential Revision: https://phabricator.services.mozilla.com/D199247
+
+diff --git a/dom/workers/WorkerPrivate.cpp b/dom/workers/WorkerPrivate.cpp
+--- a/dom/workers/WorkerPrivate.cpp
++++ b/dom/workers/WorkerPrivate.cpp
+@@ -5568,17 +5568,19 @@ WorkerPrivate::ScheduleDeletion(WorkerRa
+   MOZ_ASSERT(mSyncLoopStack.IsEmpty());
+   MOZ_ASSERT(!mPendingEventQueueClearing);
+ 
+   ClearMainEventQueue(aRanOrNot);
+ #ifdef DEBUG
+   if (WorkerRan == aRanOrNot) {
+     nsIThread* currentThread = NS_GetCurrentThread();
+     MOZ_ASSERT(currentThread);
+-    MOZ_ASSERT(!NS_HasPendingEvents(currentThread));
++    // On the worker thread WorkerRunnable will refuse to run if not nested
++    // on top of a WorkerThreadPrimaryRunnable.
++    Unused << NS_WARN_IF(NS_HasPendingEvents(currentThread));
+   }
+ #endif
+ 
+   if (WorkerPrivate* parent = GetParent()) {
+     RefPtr<WorkerFinishedRunnable> runnable =
+       new WorkerFinishedRunnable(parent, this);
+     if (!runnable->Dispatch()) {
+       NS_WARNING("Failed to dispatch runnable!");
+diff --git a/dom/workers/WorkerRunnable.cpp b/dom/workers/WorkerRunnable.cpp
+--- a/dom/workers/WorkerRunnable.cpp
++++ b/dom/workers/WorkerRunnable.cpp
+@@ -7,16 +7,17 @@
+ #include "WorkerRunnable.h"
+ 
+ #include "nsGlobalWindow.h"
+ #include "nsIEventTarget.h"
+ #include "nsIGlobalObject.h"
+ #include "nsIRunnable.h"
+ #include "nsThreadUtils.h"
+ 
++#include "mozilla/CycleCollectedJSContext.h"
+ #include "mozilla/DebugOnly.h"
+ #include "mozilla/ErrorResult.h"
+ #include "mozilla/dom/ScriptSettings.h"
+ #include "mozilla/Telemetry.h"
+ 
+ #include "js/RootingAPI.h"
+ #include "js/Value.h"
+ 
+@@ -223,16 +224,29 @@ NS_INTERFACE_MAP_BEGIN(WorkerRunnable)
+ NS_INTERFACE_MAP_END
+ 
+ NS_IMETHODIMP
+ WorkerRunnable::Run()
+ {
+   bool targetIsWorkerThread = mBehavior == WorkerThreadModifyBusyCount ||
+                               mBehavior == WorkerThreadUnchangedBusyCount;
+ 
++  if (targetIsWorkerThread) {
++    // On a worker thread, a WorkerRunnable should only run when there is an
++    // underlying WorkerThreadPrimaryRunnable active, which means we should
++    // find a CycleCollectedJSContext.
++    if (!CycleCollectedJSContext::Get()) {
++      MOZ_DIAGNOSTIC_ASSERT(false,
++                            "A WorkerRunnable was executed after "
++                            "WorkerThreadPrimaryRunnable ended.");
++
++      return NS_OK;
++    }
++  }
++
+ #ifdef DEBUG
+   MOZ_ASSERT_IF(mCallingCancelWithinRun, targetIsWorkerThread);
+   if (targetIsWorkerThread) {
+     mWorkerPrivate->AssertIsOnWorkerThread();
+   }
+   else {
+     MOZ_ASSERT(mBehavior == ParentThreadUnchangedBusyCount);
+     mWorkerPrivate->AssertIsOnParentThread();

+ 1 - 0
frg/work-js/mozilla-release/patches/series

@@ -7964,6 +7964,7 @@ TOP-NOBUG-REGEXP-45-final-25318.patch
 TOP-NOBUG-REGEXP-46-fixes-25318.patch
 TOP-NOBUG-REGEXP-47-fixes-25319.patch
 1864385-PARTIAL-11508.patch
+1867982-124a1.patch
 1878211-11508.patch
 1881093-11509.patch
 TOP-1880562-NSS3902-11509.patch

+ 1 - 0
frg/work-js/mozilla-release/patches/series-test

@@ -7908,6 +7908,7 @@ TOP-NOBUG-REGEXP-45-final-25318.patch
 TOP-NOBUG-REGEXP-46-fixes-25318.patch
 TOP-NOBUG-REGEXP-47-fixes-25319.patch
 1864385-PARTIAL-11508.patch
+1867982-124a1.patch
 1878211-11508.patch
 1881093-11509.patch
 TOP-1880562-NSS3902-11509.patch