Don't assume that PTextureChild allocation succeeds. (bug 1314425, r=nical)
authorDavid Anderson <danderson@mozilla.com>
Wed, 09 Nov 2016 18:25:27 -0800
changeset 348650 cc2a7f082db244ff23993afd35ec02ac723c5b38
parent 348649 4c1cb8ecde7fa13a4f4c5d28df5b34cbed6e3319
child 348651 383a0c1435ef4a29e7f36a4c47d6b3954e8f01fe
push id10298
push userraliiev@mozilla.com
push dateMon, 14 Nov 2016 12:33:03 +0000
treeherdermozilla-aurora@7e29173b1641 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersnical
bugs1314425
milestone52.0a1
Don't assume that PTextureChild allocation succeeds. (bug 1314425, r=nical)
gfx/layers/client/TextureClient.cpp
--- a/gfx/layers/client/TextureClient.cpp
+++ b/gfx/layers/client/TextureClient.cpp
@@ -89,17 +89,17 @@ void DeallocateTextureClient(TextureDeal
  * deallocte or recycle the it.
  */
 class TextureChild final : PTextureChild
 {
   ~TextureChild()
   {
     // We should have deallocated mTextureData in ActorDestroy
     MOZ_ASSERT(!mTextureData);
-    MOZ_ASSERT(mOwnerCalledDestroy);
+    MOZ_ASSERT_IF(!mOwnerCalledDestroy, !mTextureClient);
   }
 public:
   NS_INLINE_DECL_THREADSAFE_REFCOUNTING(TextureChild)
 
   TextureChild()
   : mCompositableForwarder(nullptr)
   , mTextureForwarder(nullptr)
   , mTextureClient(nullptr)
@@ -930,21 +930,30 @@ TextureClient::InitIPDLActor(KnowsCompos
   }
   MOZ_ASSERT(!mActor || mActor->mDestroyed, "Cannot use a texture on several IPC channels.");
 
   SurfaceDescriptor desc;
   if (!ToSurfaceDescriptor(desc)) {
     return false;
   }
 
-  mActor = static_cast<TextureChild*>(fwd->CreateTexture(desc,
-                                      aForwarder->GetCompositorBackendType(),
-                                      GetFlags(),
-                                      mSerial));
-  MOZ_ASSERT(mActor);
+  PTextureChild* actor = fwd->CreateTexture(
+    desc,
+    aForwarder->GetCompositorBackendType(),
+    GetFlags(),
+    mSerial);
+  if (!actor) {
+    gfxCriticalNote << static_cast<int32_t>(desc.type()) << ", "
+                    << static_cast<int32_t>(aForwarder->GetCompositorBackendType()) << ", "
+                    << static_cast<uint32_t>(GetFlags())
+                    << ", " << mSerial;
+    return false;
+  }
+
+  mActor = static_cast<TextureChild*>(actor);
   mActor->mTextureForwarder = fwd;
   mActor->mTextureClient = this;
   mActor->mMainThreadOnly = !!(mFlags & TextureFlags::DEALLOCATE_MAIN_THREAD);
 
   // If the TextureClient is already locked, we have to lock TextureChild's mutex
   // since it will be unlocked in TextureClient::Unlock.
   if (mIsLocked) {
     LockActor();