Bug 1333573 P7 Release WorkerLoadInfo data on main thread if we fail nested worker creation. r=baku
authorBen Kelly <ben@wanderview.com>
Tue, 07 Feb 2017 10:28:39 -0500
changeset 387841 7dd9da392d9331452f2c31b50b2cc304754fee63
parent 387840 d60942e5c631de61156ad115b40563846b396fd8
child 387842 22f07bddd55a293afb3a050e4c4343a13558d19a
push id7198
push userjlorenzo@mozilla.com
push dateTue, 18 Apr 2017 12:07:49 +0000
treeherdermozilla-beta@d57aa49c3948 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbaku
bugs1333573
milestone54.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1333573 P7 Release WorkerLoadInfo data on main thread if we fail nested worker creation. r=baku
dom/workers/WorkerPrivate.cpp
--- a/dom/workers/WorkerPrivate.cpp
+++ b/dom/workers/WorkerPrivate.cpp
@@ -4588,27 +4588,40 @@ WorkerPrivate::GetLoadInfo(JSContext* aC
     if (parentStatus > Running) {
       return NS_ERROR_FAILURE;
     }
 
     // Passing a pointer to our stack loadInfo is safe here because this
     // method uses a sync runnable to get the channel from the main thread.
     rv = ChannelFromScriptURLWorkerThread(aCx, aParent, aScriptURL,
                                           loadInfo);
-    NS_ENSURE_SUCCESS(rv, rv);
+    if (NS_FAILED(rv)) {
+      nsTArray<nsCOMPtr<nsISupports>> doomed;
+      loadInfo.ForgetMainThreadObjects(doomed);
+      nsCOMPtr<nsILoadGroup> loadGroupToCancel;
+      RefPtr<MainThreadReleaseRunnable> runnable =
+        new MainThreadReleaseRunnable(doomed, loadGroupToCancel);
+      MOZ_ALWAYS_SUCCEEDS(aParent->DispatchToMainThread(runnable.forget()));
+      return rv;
+    }
 
     // Now that we've spun the loop there's no guarantee that our parent is
     // still alive.  We may have received control messages initiating shutdown.
     {
       MutexAutoLock lock(aParent->mMutex);
       parentStatus = aParent->mStatus;
     }
 
     if (parentStatus > Running) {
-      NS_ReleaseOnMainThread(loadInfo.mChannel.forget());
+      nsTArray<nsCOMPtr<nsISupports>> doomed;
+      loadInfo.ForgetMainThreadObjects(doomed);
+      nsCOMPtr<nsILoadGroup> loadGroupToCancel;
+      RefPtr<MainThreadReleaseRunnable> runnable =
+        new MainThreadReleaseRunnable(doomed, loadGroupToCancel);
+      MOZ_ALWAYS_SUCCEEDS(aParent->DispatchToMainThread(runnable.forget()));
       return NS_ERROR_FAILURE;
     }
 
     loadInfo.mDomain = aParent->Domain();
     loadInfo.mFromWindow = aParent->IsFromWindow();
     loadInfo.mWindowID = aParent->WindowID();
     loadInfo.mStorageAllowed = aParent->IsStorageAllowed();
     loadInfo.mOriginAttributes = aParent->GetOriginAttributes();