Bug 806029: Have remote content drop their buffers when they're hidden. r=mattwoodrow sr=roc

This commit is contained in:
Chris Jones
2012-11-07 19:51:55 -08:00
parent d11ffe7871
commit a868506921
17 changed files with 208 additions and 6 deletions

View File

@@ -9070,6 +9070,38 @@ PresShell::SetIsActive(bool aIsActive)
}
}
#endif
// We have this odd special case here because remote content behaves
// differently from same-process content when "hidden". In
// desktop-type "browser UIs", hidden "tabs" have documents that are
// part of the chrome tree. When the tabs are hidden, their content
// is no longer part of the visible document tree, and the layers
// for the content are naturally released.
//
// Remote content is its own top-level tree in its subprocess. When
// it's "hidden", there's no transaction in which the document
// thinks it's not visible, so layers can be retained forever. This
// is problematic when those layers uselessly hold on to precious
// resources like directly texturable memory.
//
// PresShell::SetIsActive() is the first C++ entry point at which we
// (i) know that our parent process wants our content to be hidden;
// and (ii) has easy access to the TabChild. So we use this
// notification to signal the TabChild to drop its layer tree and
// stop trying to repaint.
if (TabChild* tab = GetTabChildFrom(this)) {
if (aIsActive) {
tab->MakeVisible();
if (nsIFrame* root = mFrameConstructor->GetRootFrame()) {
FrameLayerBuilder::InvalidateAllLayersForFrame(
nsLayoutUtils::GetDisplayRootFrame(root));
root->SchedulePaint();
}
} else {
tab->MakeHidden();
}
}
return rv;
}