Skip to content

Commit

Permalink
Bug 1076868 - Fix RemoveTextureFromCompositableAsync() call handling …
Browse files Browse the repository at this point in the history
…r=nical
  • Loading branch information
Sotaro Ikeda committed Oct 7, 2014
1 parent 0d9b8ad commit bda824b
Show file tree
Hide file tree
Showing 9 changed files with 71 additions and 16 deletions.
2 changes: 1 addition & 1 deletion gfx/layers/client/ClientLayerManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions gfx/layers/client/CompositableClient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 2 additions & 0 deletions gfx/layers/ipc/CompositableForwarder.h
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,8 @@ class CompositableForwarder : public ISurfaceAllocator
PTextureChild* aTexture,
const FenceHandle& aFence) = 0;

virtual void SendPendingAsyncMessges() = 0;

void IdentifyTextureHost(const TextureFactoryIdentifier& aIdentifier);

virtual int32_t GetMaxTextureSize() const MOZ_OVERRIDE
Expand Down
4 changes: 2 additions & 2 deletions gfx/layers/ipc/ImageBridgeChild.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -555,7 +555,7 @@ ImageBridgeChild::EndTransaction()
NS_RUNTIMEABORT("not reached");
}
}
SendPendingAsyncMessge();
SendPendingAsyncMessges();
}


Expand Down Expand Up @@ -964,7 +964,7 @@ bool ImageBridgeChild::IsSameProcess() const
return OtherProcess() == ipc::kInvalidProcessHandle;
}

void ImageBridgeChild::SendPendingAsyncMessge()
void ImageBridgeChild::SendPendingAsyncMessges()
{
if (!IsCreated() ||
mTransactionsToRespond.empty()) {
Expand Down
2 changes: 1 addition & 1 deletion gfx/layers/ipc/ImageBridgeChild.h
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,7 @@ class ImageBridgeChild MOZ_FINAL : public PImageBridgeChild

virtual bool IsSameProcess() const MOZ_OVERRIDE;

void SendPendingAsyncMessge();
virtual void SendPendingAsyncMessges();

void MarkShutDown();
protected:
Expand Down
26 changes: 26 additions & 0 deletions gfx/layers/ipc/LayerTransactionParent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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];

Expand Down Expand Up @@ -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;
Expand Down
1 change: 1 addition & 0 deletions gfx/layers/ipc/LayersMessages.ipdlh
Original file line number Diff line number Diff line change
Expand Up @@ -492,6 +492,7 @@ union AsyncParentMessageData {
union AsyncChildMessageData {
OpDeliverFenceFromChild;
OpReplyDeliverFence;
OpRemoveTextureAsync;
};

} // namespace
Expand Down
43 changes: 32 additions & 11 deletions gfx/layers/ipc/ShadowLayers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,8 @@ class Transaction
}
bool Finished() const { return !mOpen && Empty(); }

bool Opened() const { return mOpen; }

EditVector mCset;
EditVector mPaints;
ShadowableLayerSet mMutants;
Expand Down Expand Up @@ -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);
}
Expand Down Expand Up @@ -821,7 +831,7 @@ void ShadowLayerForwarder::StopReceiveAsyncParentMessge()
!mShadowManager->IPCOpen()) {
return;
}
SendPendingAsyncMessge();
SendPendingAsyncMessges();
mShadowManager->SetForwarder(nullptr);
}

Expand All @@ -831,7 +841,7 @@ void ShadowLayerForwarder::ClearCachedResources()
!mShadowManager->IPCOpen()) {
return;
}
SendPendingAsyncMessge();
SendPendingAsyncMessges();
mShadowManager->SendClearCachedResources();
}

Expand All @@ -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);
}

Expand Down
3 changes: 2 additions & 1 deletion gfx/layers/ipc/ShadowLayers.h
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,7 @@ class ShadowLayerForwarder : public CompositableForwarder

void Composite();

void SendPendingAsyncMessge();
virtual void SendPendingAsyncMessges();

/**
* True if this is forwarding to a LayerManagerComposite.
Expand Down Expand Up @@ -403,6 +403,7 @@ class ShadowLayerForwarder : public CompositableForwarder
private:

Transaction* mTxn;
std::vector<AsyncChildMessageData> mPendingAsyncMessages;
DiagnosticTypes mDiagnosticTypes;
bool mIsFirstPaint;
bool mWindowOverlayChanged;
Expand Down

0 comments on commit bda824b

Please sign in to comment.