Bug 1200504: Initialize the PresShell for about:blank after fork to fix the app launch performance regression. r=khuey

This commit is contained in:
Cervantes Yu 2015-09-09 18:04:59 +08:00
parent dbe7b1f5e5
commit f9a9c60925

View File

@ -460,6 +460,24 @@ PreloadSlowThingsPostFork(void* aUnused)
nsCOMPtr<nsIObserverService> observerService =
mozilla::services::GetObserverService();
observerService->NotifyObservers(nullptr, "preload-postfork", nullptr);
MOZ_ASSERT(sPreallocatedTab);
// Initialize initial reflow of the PresShell has to happen after fork
// because about:blank content viewer is created in the above observer
// notification.
nsCOMPtr<nsIDocShell> docShell =
do_GetInterface(sPreallocatedTab->WebNavigation());
if (nsIPresShell* presShell = docShell->GetPresShell()) {
// Initialize and do an initial reflow of the about:blank
// PresShell to let it preload some things for us.
presShell->Initialize(0, 0);
nsIDocument* doc = presShell->GetDocument();
doc->FlushPendingNotifications(Flush_Layout);
// ... but after it's done, make sure it doesn't do any more
// work.
presShell->MakeZombie();
}
}
#ifdef MOZ_NUWA_PROCESS
@ -540,30 +558,18 @@ TabChild::PreloadSlowThings()
NS_LITERAL_STRING("chrome://global/content/preload.js"),
true);
sPreallocatedTab = tab;
ClearOnShutdown(&sPreallocatedTab);
#ifdef MOZ_NUWA_PROCESS
if (IsNuwaProcess()) {
NuwaAddFinalConstructor(PreloadSlowThingsPostFork, nullptr);
} else {
PreloadSlowThingsPostFork(nullptr);
PreloadSlowThingsPostFork(nullptr);
}
#else
PreloadSlowThingsPostFork(nullptr);
#endif
nsCOMPtr<nsIDocShell> docShell = do_GetInterface(tab->WebNavigation());
if (nsIPresShell* presShell = docShell->GetPresShell()) {
// Initialize and do an initial reflow of the about:blank
// PresShell to let it preload some things for us.
presShell->Initialize(0, 0);
nsIDocument* doc = presShell->GetDocument();
doc->FlushPendingNotifications(Flush_Layout);
// ... but after it's done, make sure it doesn't do any more
// work.
presShell->MakeZombie();
}
sPreallocatedTab = tab;
ClearOnShutdown(&sPreallocatedTab);
}
/*static*/ already_AddRefed<TabChild>