Bug 1169200 - Send OpRemoveTextureAsync before actor destroyed. r=nical, a=jocheng
authorSotaro Ikeda <sikeda@mozilla.com>
Tue, 02 Jun 2015 07:31:05 -0700
changeset 238636 b69b68b8a0a719261469c61e1f9c2f4c2c9e0cfe
parent 238635 b1d19ecf10b46d8b24951cd5aab65870ee76ebed
child 238637 bf3531db0d545c1950c7889539bd7ea31d7eb189
push id697
push userryanvm@gmail.com
push dateMon, 15 Jun 2015 15:18:08 +0000
treeherdermozilla-b2g37_v2_2@bf3531db0d54 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersnical, jocheng
bugs1169200
milestone37.0
Bug 1169200 - Send OpRemoveTextureAsync before actor destroyed. r=nical, a=jocheng
gfx/layers/client/CompositableClient.cpp
gfx/layers/client/CompositableClient.h
gfx/layers/client/TiledContentClient.h
gfx/layers/ipc/ShadowLayers.cpp
--- a/gfx/layers/client/CompositableClient.cpp
+++ b/gfx/layers/client/CompositableClient.cpp
@@ -123,16 +123,17 @@ CompositableClient::FromIPDLActor(PCompo
   return static_cast<CompositableChild*>(aActor)->mCompositableClient;
 }
 
 CompositableClient::CompositableClient(CompositableForwarder* aForwarder,
                                        TextureFlags aTextureFlags)
 : mCompositableChild(nullptr)
 , mForwarder(aForwarder)
 , mTextureFlags(aTextureFlags)
+, mDestroyed(false)
 {
   MOZ_COUNT_CTOR(CompositableClient);
 }
 
 CompositableClient::~CompositableClient()
 {
   MOZ_COUNT_DTOR(CompositableClient);
   Destroy();
@@ -164,16 +165,18 @@ CompositableClient::Connect()
   }
   GetForwarder()->Connect(this);
   return true;
 }
 
 void
 CompositableClient::Destroy()
 {
+  mDestroyed = true;
+
   if (!mCompositableChild) {
     return;
   }
   // Send pending AsyncMessages before deleting CompositableChild.
   // They might have dependency to the mCompositableChild.
   mForwarder->SendPendingAsyncMessges();
   // Delete CompositableChild.
   mCompositableChild->mCompositableClient = nullptr;
--- a/gfx/layers/client/CompositableClient.h
+++ b/gfx/layers/client/CompositableClient.h
@@ -151,16 +151,18 @@ public:
 
   /**
    * Establishes the connection with compositor side through IPDL
    */
   virtual bool Connect();
 
   void Destroy();
 
+  bool IsDestroyed() { return mDestroyed; }
+
   PCompositableChild* GetIPDLActor() const;
 
   // should only be called by a CompositableForwarder
   virtual void SetIPDLActor(CompositableChild* aChild);
 
   CompositableForwarder* GetForwarder() const
   {
     return mForwarder;
@@ -234,16 +236,17 @@ public:
 
   static void DumpTextureClient(std::stringstream& aStream, TextureClient* aTexture);
 protected:
   CompositableChild* mCompositableChild;
   CompositableForwarder* mForwarder;
   // Some layers may want to enforce some flags to all their textures
   // (like disallowing tiling)
   TextureFlags mTextureFlags;
+  bool mDestroyed;
   RefPtr<TextureClientRecycleAllocator> mTextureClientRecycler;
 
   friend class CompositableChild;
 };
 
 /**
  * Helper to call RemoveTexture at the end of a scope.
  */
--- a/gfx/layers/client/TiledContentClient.h
+++ b/gfx/layers/client/TiledContentClient.h
@@ -521,16 +521,17 @@ public:
   TiledContentClient(ClientTiledPaintedLayer* aPaintedLayer,
                      ClientLayerManager* aManager);
 
 protected:
   ~TiledContentClient()
   {
     MOZ_COUNT_DTOR(TiledContentClient);
 
+    mDestroyed = true;
     mTiledBuffer.Release();
     mLowPrecisionTiledBuffer.Release();
   }
 
   virtual void PrintInfo(std::stringstream& aStream, const char* aPrefix);
 
   virtual void Dump(std::stringstream& aStream,
                     const char* aPrefix="",
--- a/gfx/layers/ipc/ShadowLayers.cpp
+++ b/gfx/layers/ipc/ShadowLayers.cpp
@@ -478,17 +478,17 @@ ShadowLayerForwarder::RemoveTextureFromC
   HoldUntilTransaction(aTexture);
 }
 
 void
 ShadowLayerForwarder::RemoveTextureFromCompositableAsync(AsyncTransactionTracker* aAsyncTransactionTracker,
                                                      CompositableClient* aCompositable,
                                                      TextureClient* aTexture)
 {
-  if (mTxn->Opened()) {
+  if (mTxn->Opened() && !aCompositable->IsDestroyed()) {
     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()),