Bug 1238015 - Make sure PTexture actors are destroyed after all messages referring to them are sent. r=sotaro

This commit is contained in:
Nicolas Silva 2016-01-12 10:38:14 +01:00
Родитель 4ad8e58cf5
Коммит 3ae9e8ee03
4 изменённых файлов: 27 добавлений и 24 удалений

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

@ -255,11 +255,6 @@ CompositableParentManager::DestroyActor(const OpDestroy& aOp)
void
CompositableParentManager::SendPendingAsyncMessages()
{
for (auto& actor : mDestroyedTextures) {
TextureHost::SendDeleteIPDLActor(actor);
}
mDestroyedTextures.clear();
if (mPendingAsyncMessage.empty()) {
return;
}

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

@ -40,13 +40,14 @@ public:
*/
virtual base::ProcessId GetChildProcessId() = 0;
void DestroyActor(const OpDestroy& aOp);
protected:
/**
* Handle the IPDL messages that affect PCompositable actors.
*/
bool ReceiveCompositableUpdate(const CompositableOperation& aEdit,
EditReplyVector& replyv);
void DestroyActor(const OpDestroy& aOp);
bool IsOnCompositorSide() const override { return true; }
@ -59,7 +60,6 @@ protected:
virtual void ReplyRemoveTexture(const OpReplyRemoveTexture& aReply) {}
std::vector<AsyncParentMessageData> mPendingAsyncMessage;
std::vector<PTextureParent*> mDestroyedTextures;
};
} // namespace layers

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

@ -117,15 +117,23 @@ ImageBridgeParent::RecvImageBridgeThreadId(const PlatformThreadId& aThreadId)
class MOZ_STACK_CLASS AutoImageBridgeParentAsyncMessageSender
{
public:
explicit AutoImageBridgeParentAsyncMessageSender(ImageBridgeParent* aImageBridge)
: mImageBridge(aImageBridge) {}
explicit AutoImageBridgeParentAsyncMessageSender(ImageBridgeParent* aImageBridge,
InfallibleTArray<OpDestroy>* aToDestroy = nullptr)
: mImageBridge(aImageBridge)
, mToDestroy(aToDestroy) {}
~AutoImageBridgeParentAsyncMessageSender()
{
mImageBridge->SendPendingAsyncMessages();
if (mToDestroy) {
for (const auto& op : *mToDestroy) {
mImageBridge->DestroyActor(op);
}
}
}
private:
ImageBridgeParent* mImageBridge;
InfallibleTArray<OpDestroy>* mToDestroy;
};
bool
@ -141,10 +149,6 @@ ImageBridgeParent::RecvUpdate(EditArray&& aEdits, OpDestroyArray&& aToDestroy,
}
}
for (const auto& op : aToDestroy) {
DestroyActor(op);
}
aReply->SetCapacity(replyv.size());
if (replyv.size() > 0) {
aReply->AppendElements(&replyv.front(), replyv.size());

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

@ -207,16 +207,27 @@ LayerTransactionParent::RecvUpdateNoSwap(InfallibleTArray<Edit>&& cset,
class MOZ_STACK_CLASS AutoLayerTransactionParentAsyncMessageSender
{
public:
explicit AutoLayerTransactionParentAsyncMessageSender(LayerTransactionParent* aLayerTransaction)
: mLayerTransaction(aLayerTransaction) {}
explicit AutoLayerTransactionParentAsyncMessageSender(LayerTransactionParent* aLayerTransaction,
InfallibleTArray<OpDestroy>* aDestroyActors = nullptr)
: mLayerTransaction(aLayerTransaction)
, mActorsToDestroy(aDestroyActors)
{}
~AutoLayerTransactionParentAsyncMessageSender()
{
mLayerTransaction->SendPendingAsyncMessages();
ImageBridgeParent::SendPendingAsyncMessages(mLayerTransaction->GetChildProcessId());
if (mActorsToDestroy) {
// Destroy the actors after sending the async messages because the latter may contain
// references to some actors.
for (const auto& op : *mActorsToDestroy) {
mLayerTransaction->DestroyActor(op);
}
}
}
private:
LayerTransactionParent* mLayerTransaction;
InfallibleTArray<OpDestroy>* mActorsToDestroy;
};
bool
@ -243,16 +254,13 @@ LayerTransactionParent::RecvUpdate(InfallibleTArray<Edit>&& cset,
MOZ_LAYERS_LOG(("[ParentSide] received txn with %d edits", cset.Length()));
if (mDestroyed || !layer_manager() || layer_manager()->IsDestroyed()) {
for (const auto& op : aToDestroy) {
DestroyActor(op);
}
AutoLayerTransactionParentAsyncMessageSender autoAsyncMessageSender(this, &aToDestroy);
if (mDestroyed || !layer_manager() || layer_manager()->IsDestroyed()) {
return true;
}
EditReplyVector replyv;
AutoLayerTransactionParentAsyncMessageSender autoAsyncMessageSender(this);
{
AutoResolveRefLayers resolve(mShadowLayersManager->GetCompositionManager(this));
@ -600,10 +608,6 @@ LayerTransactionParent::RecvUpdate(InfallibleTArray<Edit>&& cset,
}
}
for (const auto& op : aToDestroy) {
DestroyActor(op);
}
mShadowLayersManager->ShadowLayersUpdated(this, aTransactionId, targetConfig,
aPlugins, isFirstPaint, scheduleComposite,
paintSequenceNumber, isRepeatTransaction,