Make CreateImageClient fallible. (bug 1313770 part 2, r=mattwoodrow)
authorDavid Anderson <danderson@mozilla.com>
Fri, 28 Oct 2016 15:48:35 -0700
changeset 346693 8c31adc3869b113b6917e621a75bf94ae338e3b1
parent 346692 c9a887ab3ba6179894b8e4d2b87c3ebeffa9b14d
child 346694 a8e078e03894e144487e04d0eef507def1a0d50d
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)
reviewersmattwoodrow
bugs1313770
milestone52.0a1
Make CreateImageClient fallible. (bug 1313770 part 2, r=mattwoodrow)
gfx/layers/ImageContainer.cpp
gfx/layers/ipc/ImageBridgeChild.cpp
--- a/gfx/layers/ImageContainer.cpp
+++ b/gfx/layers/ImageContainer.cpp
@@ -106,18 +106,19 @@ ImageContainer::EnsureImageClient(bool a
   if (!aCreate && (!mImageClient || mImageClient->GetForwarder()->GetLayersIPCActor()->IPCOpen())) {
     return;
   }
 
   RefPtr<ImageBridgeChild> imageBridge = ImageBridgeChild::GetSingleton();
   if (imageBridge) {
     mIPDLChild = new ImageContainerChild(this);
     mImageClient = imageBridge->CreateImageClient(CompositableType::IMAGE, this, mIPDLChild);
-    MOZ_ASSERT(mImageClient);
-    mAsyncContainerID = mImageClient->GetAsyncID();
+    if (mImageClient) {
+      mAsyncContainerID = mImageClient->GetAsyncID();
+    }
   }
 }
 
 ImageContainer::ImageContainer(Mode flag)
 : mReentrantMonitor("ImageContainer.mReentrantMonitor"),
   mGenerationCounter(++sGenerationCounter),
   mPaintCount(0),
   mDroppedImageCount(0),
--- a/gfx/layers/ipc/ImageBridgeChild.cpp
+++ b/gfx/layers/ipc/ImageBridgeChild.cpp
@@ -431,17 +431,19 @@ ImageBridgeChild::Connect(CompositableCl
 
   PImageContainerChild* imageContainerChild = nullptr;
   if (aImageContainer)
     imageContainerChild = aImageContainer->GetPImageContainerChild();
 
   PCompositableChild* child =
     SendPCompositableConstructor(aCompositable->GetTextureInfo(),
                                  imageContainerChild, &id);
-  MOZ_ASSERT(child);
+  if (!child) {
+    return;
+  }
   aCompositable->InitIPDLActor(child, id);
 }
 
 PCompositableChild*
 ImageBridgeChild::AllocPCompositableChild(const TextureInfo& aInfo,
                                           PImageContainerChild* aChild, uint64_t* aID)
 {
   MOZ_ASSERT(CanSend());
@@ -924,16 +926,19 @@ ImageBridgeChild::CreateImageClient(Comp
 }
 
 RefPtr<ImageClient>
 ImageBridgeChild::CreateImageClientNow(CompositableType aType,
                                        ImageContainer* aImageContainer,
                                        ImageContainerChild* aContainerChild)
 {
   MOZ_ASSERT(InImageBridgeChildThread());
+  if (!CanSend()) {
+    return nullptr;
+  }
 
   if (aImageContainer) {
     SendPImageContainerConstructor(aContainerChild);
     aContainerChild->RegisterWithIPDL();
   }
 
   RefPtr<ImageClient> client = ImageClient::CreateImageClient(aType, this, TextureFlags::NO_FLAGS);
   MOZ_ASSERT(client, "failed to create ImageClient");