Bug 1076868 - Fix RemoveTextureFromCompositableAsync() call handling r=nical

This commit is contained in:
Sotaro Ikeda 2014-10-07 11:37:15 -07:00
parent 9fa93a5f9c
commit 6c8fec1791
9 changed files with 71 additions and 16 deletions

View File

@ -607,7 +607,7 @@ ClientLayerManager::ForwardTransaction(bool aScheduleComposite)
}
mForwarder->RemoveTexturesIfNecessary();
mForwarder->SendPendingAsyncMessge();
mForwarder->SendPendingAsyncMessges();
mPhase = PHASE_NONE;
// this may result in Layers being deleted, which results in

View File

@ -171,6 +171,10 @@ CompositableClient::Destroy()
if (!mCompositableChild) {
return;
}
// Send pending AsyncMessages before deleting CompositableChild.
// They might have dependency to the mCompositableChild.
mForwarder->SendPendingAsyncMessges();
// Delete CompositableChild.
mCompositableChild->mCompositableClient = nullptr;
PCompositableChild::Send__delete__(mCompositableChild);
mCompositableChild = nullptr;

View File

@ -194,6 +194,8 @@ public:
PTextureChild* aTexture,
const FenceHandle& aFence) = 0;
virtual void SendPendingAsyncMessges() = 0;
void IdentifyTextureHost(const TextureFactoryIdentifier& aIdentifier);
virtual int32_t GetMaxTextureSize() const MOZ_OVERRIDE

View File

@ -555,7 +555,7 @@ ImageBridgeChild::EndTransaction()
NS_RUNTIMEABORT("not reached");
}
}
SendPendingAsyncMessge();
SendPendingAsyncMessges();
}
@ -964,7 +964,7 @@ bool ImageBridgeChild::IsSameProcess() const
return OtherProcess() == ipc::kInvalidProcessHandle;
}
void ImageBridgeChild::SendPendingAsyncMessge()
void ImageBridgeChild::SendPendingAsyncMessges()
{
if (!IsCreated() ||
mTransactionsToRespond.empty()) {

View File

@ -310,7 +310,7 @@ public:
virtual bool IsSameProcess() const MOZ_OVERRIDE;
void SendPendingAsyncMessge();
virtual void SendPendingAsyncMessges();
void MarkShutDown();
protected:

View File

@ -858,6 +858,8 @@ LayerTransactionParent::DeallocPTextureParent(PTextureParent* actor)
bool
LayerTransactionParent::RecvChildAsyncMessages(const InfallibleTArray<AsyncChildMessageData>& aMessages)
{
AutoLayerTransactionParentAsyncMessageSender autoAsyncMessageSender(this);
for (AsyncChildMessageArray::index_type i = 0; i < aMessages.Length(); ++i) {
const AsyncChildMessageData& message = aMessages[i];
@ -888,6 +890,30 @@ LayerTransactionParent::RecvChildAsyncMessages(const InfallibleTArray<AsyncChild
TransactionCompleteted(op.transactionId());
break;
}
case AsyncChildMessageData::TOpRemoveTextureAsync: {
const OpRemoveTextureAsync& op = message.get_OpRemoveTextureAsync();
CompositableHost* compositable = CompositableHost::FromIPDLActor(op.compositableParent());
RefPtr<TextureHost> tex = TextureHost::AsTextureHost(op.textureParent());
MOZ_ASSERT(tex.get());
compositable->RemoveTextureHost(tex);
// send FenceHandle if present via ImageBridge.
ImageBridgeParent::SendFenceHandleToTrackerIfPresent(
GetChildProcessId(),
op.holderId(),
op.transactionId(),
op.textureParent(),
compositable);
// Send message back via PImageBridge.
ImageBridgeParent::ReplyRemoveTexture(
GetChildProcessId(),
OpReplyRemoveTexture(true, // isMain
op.holderId(),
op.transactionId()));
break;
}
default:
NS_ERROR("unknown AsyncChildMessageData type");
return false;

View File

@ -492,6 +492,7 @@ union AsyncParentMessageData {
union AsyncChildMessageData {
OpDeliverFenceFromChild;
OpReplyDeliverFence;
OpRemoveTextureAsync;
};
} // namespace

View File

@ -135,6 +135,8 @@ public:
}
bool Finished() const { return !mOpen && Empty(); }
bool Opened() const { return mOpen; }
EditVector mCset;
EditVector mPaints;
ShadowableLayerSet mMutants;
@ -472,11 +474,19 @@ ShadowLayerForwarder::RemoveTextureFromCompositableAsync(AsyncTransactionTracker
CompositableClient* aCompositable,
TextureClient* aTexture)
{
mTxn->AddEdit(OpRemoveTextureAsync(CompositableClient::GetTrackersHolderId(aCompositable->GetIPDLActor()),
aAsyncTransactionTracker->GetId(),
nullptr, aCompositable->GetIPDLActor(),
nullptr, aTexture->GetIPDLActor()));
// Hold AsyncTransactionTracker until receving reply
if (mTxn->Opened()) {
mTxn->AddEdit(OpRemoveTextureAsync(CompositableClient::GetTrackersHolderId(aCompositable->GetIPDLActor()),
aAsyncTransactionTracker->GetId(),
nullptr, aCompositable->GetIPDLActor(),
nullptr, aTexture->GetIPDLActor()));
} else {
// If the function is called outside of transaction,
// OpRemoveTextureAsync message is stored as pending message.
mPendingAsyncMessages.push_back(OpRemoveTextureAsync(CompositableClient::GetTrackersHolderId(aCompositable->GetIPDLActor()),
aAsyncTransactionTracker->GetId(),
nullptr, aCompositable->GetIPDLActor(),
nullptr, aTexture->GetIPDLActor()));
}
CompositableClient::HoldUntilComplete(aCompositable->GetIPDLActor(),
aAsyncTransactionTracker);
}
@ -821,7 +831,7 @@ void ShadowLayerForwarder::StopReceiveAsyncParentMessge()
!mShadowManager->IPCOpen()) {
return;
}
SendPendingAsyncMessge();
SendPendingAsyncMessges();
mShadowManager->SetForwarder(nullptr);
}
@ -831,7 +841,7 @@ void ShadowLayerForwarder::ClearCachedResources()
!mShadowManager->IPCOpen()) {
return;
}
SendPendingAsyncMessge();
SendPendingAsyncMessges();
mShadowManager->SendClearCachedResources();
}
@ -844,20 +854,31 @@ void ShadowLayerForwarder::Composite()
mShadowManager->SendForceComposite();
}
void ShadowLayerForwarder::SendPendingAsyncMessge()
void ShadowLayerForwarder::SendPendingAsyncMessges()
{
if (!HasShadowManager() ||
!mShadowManager->IPCOpen() ||
mTransactionsToRespond.empty()) {
!mShadowManager->IPCOpen()) {
mTransactionsToRespond.clear();
mPendingAsyncMessages.clear();
return;
}
// Send OpReplyDeliverFence messages
if (mTransactionsToRespond.empty() && mPendingAsyncMessages.empty()) {
return;
}
InfallibleTArray<AsyncChildMessageData> replies;
replies.SetCapacity(mTransactionsToRespond.size());
// Prepare OpReplyDeliverFence messages.
for (size_t i = 0; i < mTransactionsToRespond.size(); i++) {
replies.AppendElement(OpReplyDeliverFence(mTransactionsToRespond[i]));
}
mTransactionsToRespond.clear();
// Prepare pending messages.
for (size_t i = 0; i < mPendingAsyncMessages.size(); i++) {
replies.AppendElement(mPendingAsyncMessages[i]);
}
mPendingAsyncMessages.clear();
mShadowManager->SendChildAsyncMessages(replies);
}

View File

@ -319,7 +319,7 @@ public:
void Composite();
void SendPendingAsyncMessge();
virtual void SendPendingAsyncMessges();
/**
* True if this is forwarding to a LayerManagerComposite.
@ -403,6 +403,7 @@ protected:
private:
Transaction* mTxn;
std::vector<AsyncChildMessageData> mPendingAsyncMessages;
DiagnosticTypes mDiagnosticTypes;
bool mIsFirstPaint;
bool mWindowOverlayChanged;