Bug 1426801 - Clear gFirstIdleTask if we fail to dispatch the runnable. r=mrbkap, a=gchang
authorAndrew McCreight <continuation@gmail.com>
Thu, 04 Jan 2018 14:59:14 -0800
changeset 445628 a1d9a99f12a544df996ebdf833cf3e65357a7361
parent 445627 38fd987182186720bc0b252a1dc94444f6db39f5
child 445629 3e7bec52b1431c8dfd56c86ec5062514434fa788
push id1618
push userCallek@gmail.com
push dateThu, 11 Jan 2018 17:45:48 +0000
treeherdermozilla-release@882ca853e05a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmrbkap, gchang
bugs1426801
milestone58.0
Bug 1426801 - Clear gFirstIdleTask if we fail to dispatch the runnable. r=mrbkap, a=gchang MozReview-Commit-ID: 23f9VDTyyqg
dom/ipc/ContentChild.cpp
--- a/dom/ipc/ContentChild.cpp
+++ b/dom/ipc/ContentChild.cpp
@@ -1870,17 +1870,20 @@ ContentChild::RecvPBrowserConstructor(PB
   MOZ_ASSERT(!IsShuttingDown());
 
   static bool hasRunOnce = false;
   if (!hasRunOnce) {
     hasRunOnce = true;
     MOZ_ASSERT(!gFirstIdleTask);
     RefPtr<CancelableRunnable> firstIdleTask = NewCancelableRunnableFunction(FirstIdle);
     gFirstIdleTask = firstIdleTask;
-    NS_IdleDispatchToCurrentThread(firstIdleTask.forget());
+    if (NS_FAILED(NS_IdleDispatchToCurrentThread(firstIdleTask.forget()))) {
+      gFirstIdleTask = nullptr;
+      hasRunOnce = false;
+    }
   }
 
   return nsIContentChild::RecvPBrowserConstructor(aActor,
                                                   aTabId,
                                                   aSameTabGroupAs,
                                                   aContext,
                                                   aChromeFlags,
                                                   aCpID,
@@ -2392,16 +2395,17 @@ ContentChild::ActorDestroy(ActorDestroyR
 #ifndef NS_FREE_PERMANENT_DATA
   // In release builds, there's no point in the content process
   // going through the full XPCOM shutdown path, because it doesn't
   // keep persistent state.
   ProcessChild::QuickExit();
 #else
   if (gFirstIdleTask) {
     gFirstIdleTask->Cancel();
+    gFirstIdleTask = nullptr;
   }
 
   nsHostObjectProtocolHandler::RemoveDataEntries();
 
   mAlertObservers.Clear();
 
   mIdleObservers.Clear();