Bug 1061696 - Don't crash release builds when failing to allocate a surface in AutoRestoreClippedOut::save. r=Bas, a=sledru
authorNicolas Silva <nsilva@mozilla.com>
Thu, 11 Sep 2014 17:27:48 +0200
changeset 216731 ff9cef7b2f9d
parent 216730 9148cd599e9f
child 216732 430b3512f177
push id3892
push userryanvm@gmail.com
push date2014-09-15 14:56 +0000
treeherdermozilla-beta@cd04e5bf0fec [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersBas, sledru
bugs1061696
milestone33.0
Bug 1061696 - Don't crash release builds when failing to allocate a surface in AutoRestoreClippedOut::save. r=Bas, a=sledru
gfx/2d/DrawTargetD2D.cpp
--- a/gfx/2d/DrawTargetD2D.cpp
+++ b/gfx/2d/DrawTargetD2D.cpp
@@ -71,31 +71,37 @@ public:
     SurfaceFormat format = mDT->mFormat;
 
     CD3D10_TEXTURE2D_DESC desc(DXGIFormat(format), size.width, size.height,
                                1, 1);
     desc.BindFlags = D3D10_BIND_RENDER_TARGET | D3D10_BIND_SHADER_RESOURCE;
 
     HRESULT hr = mDT->mDevice->CreateTexture2D(&desc, nullptr, byRef(tmpTexture));
     if (FAILED(hr)) {
-      gfxWarning() << "Failed to create temporary texture to hold surface data.";
+      gfxWarning() << "Failure to create temporary texture. Size: " << size << " Code: " << hr;
+      // Crash debug builds but try to recover in release builds.
+      MOZ_ASSERT(false);
+      return;
     }
     mDT->mDevice->CopyResource(tmpTexture, mDT->mTexture);
 
     D2D1_BITMAP_PROPERTIES props = D2D1::BitmapProperties(D2DPixelFormat(format));
 
     RefPtr<IDXGISurface> surf;
 
     tmpTexture->QueryInterface((IDXGISurface**)byRef(surf));
 
     hr = mDT->mRT->CreateSharedBitmap(IID_IDXGISurface, surf,
                                       &props, byRef(mOldSurfBitmap));
 
     if (FAILED(hr)) {
-      gfxWarning() << "Failed to create shared bitmap for old surface.";
+      gfxWarning() << "Failed to create shared bitmap for old surface. Code: " << hr;
+      // Crash debug builds but try to recover in release builds.
+      MOZ_ASSERT(false);
+      return;
     }
 
     IntRect clipBounds;
     mClippedArea = mDT->GetClippedGeometry(&clipBounds);
 
     if (!clipBounds.IsEqualEdges(IntRect(IntPoint(0, 0), mDT->mSize))) {
       // We still need to take into account clipBounds if it contains additional
       // clipping information.