Bug 1037226 - Don't crash when surface allocation fails in BasicCompositor. r=Bas, a=sledru
authorMatt Woodrow <mwoodrow@mozilla.com>
Thu, 24 Jul 2014 15:48:28 +1200
changeset 217897 9dd2e18346511333cfb451e47b2a04476468f54b
parent 217896 023a362fab212b1eaec62401a59947f81946663e
child 217898 8d7b3bfaf3ab9bb3c32afb51d9714246d7c854f4
push id515
push userraliiev@mozilla.com
push dateMon, 06 Oct 2014 12:51:51 +0000
treeherdermozilla-release@267c7a481bef [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersBas, sledru
bugs1037226
milestone33.0
Bug 1037226 - Don't crash when surface allocation fails in BasicCompositor. r=Bas, a=sledru
gfx/layers/basic/BasicCompositor.cpp
--- a/gfx/layers/basic/BasicCompositor.cpp
+++ b/gfx/layers/basic/BasicCompositor.cpp
@@ -82,16 +82,20 @@ void BasicCompositor::Destroy()
   mWidget = nullptr;
 }
 
 TemporaryRef<CompositingRenderTarget>
 BasicCompositor::CreateRenderTarget(const IntRect& aRect, SurfaceInitMode aInit)
 {
   RefPtr<DrawTarget> target = mDrawTarget->CreateSimilarDrawTarget(aRect.Size(), SurfaceFormat::B8G8R8A8);
 
+  if (!target) {
+    return nullptr;
+  }
+
   RefPtr<BasicCompositingRenderTarget> rt = new BasicCompositingRenderTarget(target, aRect);
 
   return rt.forget();
 }
 
 TemporaryRef<CompositingRenderTarget>
 BasicCompositor::CreateRenderTargetFromSource(const IntRect &aRect,
                                               const CompositingRenderTarget *aSource,
@@ -423,16 +427,22 @@ BasicCompositor::BeginFrame(const nsIntR
   }
   if (!mDrawTarget) {
     return;
   }
 
   // Setup an intermediate render target to buffer all compositing. We will
   // copy this into mDrawTarget (the widget), and/or mTarget in EndFrame()
   RefPtr<CompositingRenderTarget> target = CreateRenderTarget(mInvalidRect, INIT_MODE_CLEAR);
+  if (!target) {
+    if (!mTarget) {
+      mWidget->EndRemoteDrawing();
+    }
+    return;
+  }
   SetRenderTarget(target);
 
   // We only allocate a surface sized to the invalidated region, so we need to
   // translate future coordinates.
   Matrix transform;
   transform.Translate(-invalidRect.x, -invalidRect.y);
   mRenderTarget->mDrawTarget->SetTransform(transform);