Bug 1110928, part 2 - Call PokeGC in nsDocumentViewer::PageHide before the call to OnPageHide. r=smaug
This ensures that the document isn't destroyed when we call PokeGC, which will be useful later.
--- a/layout/base/nsDocumentViewer.cpp
+++ b/layout/base/nsDocumentViewer.cpp
@@ -1332,28 +1332,30 @@ nsDocumentViewer::PageHide(bool aIsUnloa
AutoDontWarnAboutSyncXHR disableSyncXHRWarning;
mHidden = true;
if (!mDocument) {
return NS_ERROR_NULL_POINTER;
}
+ if (aIsUnload) {
+ // Poke the GC. The window might be collectable garbage now.
+ nsJSContext::PokeGC(JS::gcreason::PAGE_HIDE, NS_GC_DELAY * 2);
+ }
+
mDocument->OnPageHide(!aIsUnload, nullptr);
// inform the window so that the focus state is reset.
NS_ENSURE_STATE(mDocument);
nsPIDOMWindowOuter* window = mDocument->GetWindow();
if (window)
window->PageHidden();
if (aIsUnload) {
- // Poke the GC. The window might be collectable garbage now.
- nsJSContext::PokeGC(JS::gcreason::PAGE_HIDE, NS_GC_DELAY * 2);
-
// if Destroy() was called during OnPageHide(), mDocument is nullptr.
NS_ENSURE_STATE(mDocument);
// First, get the window from the document...
nsPIDOMWindowOuter* window = mDocument->GetWindow();
if (!window) {
// Fail if no window is available...