Bug 1004191 - Destroy LayerTransactionChild r=nical,bjacob

This commit is contained in:
Sotaro Ikeda 2014-05-07 06:23:14 -07:00
parent 7faee3d635
commit 5fd73fc63c
5 changed files with 19 additions and 6 deletions

View File

@ -2725,8 +2725,8 @@ nsDOMWindowUtils::AdvanceTimeAndRefresh(int64_t aMilliseconds)
nsRefreshDriver* driver = GetPresContext()->RefreshDriver();
driver->AdvanceTimeAndRefresh(aMilliseconds);
LayerTransactionChild* transaction = GetLayerTransaction();
if (transaction) {
RefPtr<LayerTransactionChild> transaction = GetLayerTransaction();
if (transaction && transaction->IPCOpen()) {
transaction->SendSetTestSampleTime(driver->MostRecentRefresh());
}
@ -2743,8 +2743,8 @@ nsDOMWindowUtils::RestoreNormalRefresh()
// Kick the compositor out of test mode before the refresh driver, so that
// the refresh driver doesn't send an update that gets ignored by the
// compositor.
LayerTransactionChild* transaction = GetLayerTransaction();
if (transaction) {
RefPtr<LayerTransactionChild> transaction = GetLayerTransaction();
if (transaction && transaction->IPCOpen()) {
transaction->SendLeaveTestMode();
}

View File

@ -48,7 +48,7 @@ CompositorChild::Destroy()
mLayerManager->Destroy();
mLayerManager = nullptr;
while (size_t len = ManagedPLayerTransactionChild().Length()) {
LayerTransactionChild* layers =
RefPtr<LayerTransactionChild> layers =
static_cast<LayerTransactionChild*>(ManagedPLayerTransactionChild()[len - 1]);
layers->Destroy();
}

View File

@ -22,10 +22,19 @@ namespace layers {
void
LayerTransactionChild::Destroy()
{
if (!IPCOpen() || mDestroyed) {
return;
}
// mDestroyed is used to prevent calling Send__delete__() twice.
// When this function is called from CompositorChild::Destroy(),
// under Send__delete__() call, this function is called from
// ShadowLayerForwarder's destructor.
// When it happens, IPCOpen() is still true.
// See bug 1004191.
mDestroyed = true;
NS_ABORT_IF_FALSE(0 == ManagedPLayerChild().Length(),
"layers should have been cleaned up by now");
PLayerTransactionChild::Send__delete__(this);
// WARNING: |this| has gone to the great heap in the sky
}

View File

@ -46,6 +46,8 @@ public:
protected:
LayerTransactionChild()
: mIPCOpen(false)
, mDestroyed(false)
, mForwarder(nullptr)
{}
~LayerTransactionChild() { }
@ -78,6 +80,7 @@ protected:
friend class layout::RenderFrameChild;
bool mIPCOpen;
bool mDestroyed;
ShadowLayerForwarder* mForwarder;
};

View File

@ -179,6 +179,7 @@ ShadowLayerForwarder::~ShadowLayerForwarder()
delete mTxn;
if (mShadowManager) {
mShadowManager->SetForwarder(nullptr);
mShadowManager->Destroy();
}
}