Bug 1315583 - Release ActiveResourceTracker on the main thread. r=dvander

This commit is contained in:
Matt Woodrow 2016-11-08 15:24:36 +13:00
Родитель b2c5102506
Коммит 5b78e0fd3c
1 изменённых файлов: 19 добавлений и 0 удалений

Просмотреть файл

@ -192,6 +192,21 @@ ShadowLayerForwarder::ShadowLayerForwarder(ClientLayerManager* aClientLayerManag
mActiveResourceTracker = MakeUnique<ActiveResourceTracker>(1000, "CompositableForwarder");
}
template<typename T>
struct ReleaseOnMainThreadTask : public Runnable
{
UniquePtr<T> mObj;
explicit ReleaseOnMainThreadTask(UniquePtr<T>& aObj)
: mObj(Move(aObj))
{}
NS_IMETHOD Run() override {
mObj = nullptr;
return NS_OK;
}
};
ShadowLayerForwarder::~ShadowLayerForwarder()
{
MOZ_ASSERT(mTxn->Finished(), "unfinished transaction?");
@ -200,6 +215,10 @@ ShadowLayerForwarder::~ShadowLayerForwarder()
mShadowManager->SetForwarder(nullptr);
mShadowManager->Destroy();
}
if (!NS_IsMainThread()) {
NS_DispatchToMainThread(
new ReleaseOnMainThreadTask<ActiveResourceTracker>(mActiveResourceTracker));
}
}
void