Bug 1426801 - Clear gFirstIdleTask if we fail to dispatch the runnable. r=mrbkap
MozReview-Commit-ID: 23f9VDTyyqg
--- a/dom/ipc/ContentChild.cpp
+++ b/dom/ipc/ContentChild.cpp
@@ -1806,17 +1806,20 @@ ContentChild::RecvPBrowserConstructor(PB
static bool hasRunOnce = false;
if (!hasRunOnce) {
hasRunOnce = true;
MOZ_ASSERT(!gFirstIdleTask);
RefPtr<CancelableRunnable> firstIdleTask = NewCancelableRunnableFunction("FirstIdleRunnable",
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,
@@ -2312,16 +2315,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();