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-08 16:11:00 +08:00
parent 5f96bd073d
commit 00073363b9

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
@ -550,18 +568,6 @@ TabChild::PreloadSlowThings()
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);
}