Bug 1262390 - In some cases, we fail with the small allocation because of the device reset situation. r=bas, a=gchang
authorMilan Sreckovic <milan@mozilla.com>
Mon, 20 Feb 2017 17:14:49 -0500
changeset 378664 7cd0cae1045d7be5b79a714e8ce41d6d2dfd6b4d
parent 378663 08c8172374801689c5793ff23a3b5a5ce2a81c2e
child 378665 53bf634de5cb7e3583956752548b63ace3058abc
push id1419
push userjlund@mozilla.com
push dateMon, 10 Apr 2017 20:44:07 +0000
treeherdermozilla-release@5e6801b73ef6 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbas, gchang
bugs1262390
milestone53.0a2
Bug 1262390 - In some cases, we fail with the small allocation because of the device reset situation. r=bas, a=gchang MozReview-Commit-ID: BKMOZbgJ7px
gfx/2d/DrawTargetD2D1.cpp
--- a/gfx/2d/DrawTargetD2D1.cpp
+++ b/gfx/2d/DrawTargetD2D1.cpp
@@ -1353,16 +1353,19 @@ DrawTargetD2D1::FinalizeDrawing(Composit
     if (FAILED(hr) || !blendEffect) {
       gfxWarning() << "Failed to create blend effect!";
       return;
     }
 
     // We don't need to preserve the current content of this layer as the output
     // of the blend effect should completely replace it.
     RefPtr<ID2D1Image> tmpImage = GetImageForLayerContent(false);
+    if (!tmpImage) {
+      return;
+    }
 
     blendEffect->SetInput(0, tmpImage);
     blendEffect->SetInput(1, source);
     blendEffect->SetValue(D2D1_BLEND_PROP_MODE, D2DBlendMode(aOp));
 
     mDC->DrawImage(blendEffect, D2D1_INTERPOLATION_MODE_NEAREST_NEIGHBOR, D2D1_COMPOSITE_MODE_BOUNDED_SOURCE_COPY);
 
     // This may seem a little counter intuitive. If this is false, we go through the regular
@@ -1456,19 +1459,23 @@ DrawTargetD2D1::GetImageForLayerContent(
 {
   PopAllClips();
 
   if (!CurrentLayer().mCurrentList) {
     RefPtr<ID2D1Bitmap> tmpBitmap;
     HRESULT hr = mDC->CreateBitmap(D2DIntSize(mSize), D2D1::BitmapProperties(D2DPixelFormat(mFormat)), getter_AddRefs(tmpBitmap));
     if (FAILED(hr)) {
       gfxCriticalError(CriticalLog::DefaultOptions(Factory::ReasonableSurfaceSize(mSize))) << "[D2D1.1] 6CreateBitmap failure " << mSize << " Code: " << hexa(hr) << " format " << (int)mFormat;
-      // For now, crash in this scenario; this should happen because tmpBitmap is
+      // If it's a recreate target error, return and handle it elsewhere.
+      if (hr == D2DERR_RECREATE_TARGET) {
+        mDC->Flush();
+        return nullptr;
+      }
+      // For now, crash in other scenarios; this should happen because tmpBitmap is
       // null and CopyFromBitmap call below dereferences it.
-      // return;
     }
     mDC->Flush();
 
     tmpBitmap->CopyFromBitmap(nullptr, mBitmap, nullptr);
     return tmpBitmap.forget();
   } else {
     RefPtr<ID2D1CommandList> list = CurrentLayer().mCurrentList;
     mDC->CreateCommandList(getter_AddRefs(CurrentLayer().mCurrentList));