Bug 1264736: Crash sooner if we can't get a valid command list, at least in nightly/aurora. r?bas draft
authorMilan Sreckovic <milan@mozilla.com>
Wed, 20 Apr 2016 12:11:00 -0400
changeset 354326 d52db75aa4c5f390abf52d512f7fa871aad75e2e
parent 353712 ae7413abfa4d3954a6a4ce7c1613a7100f367f9a
child 354851 489d9176bb1b7be230a9ff627f11c8efe6d35ef9
push id16044
push usermsreckovic@mozilla.com
push dateWed, 20 Apr 2016 17:11:03 +0000
reviewersbas
bugs1264736
milestone48.0a1
Bug 1264736: Crash sooner if we can't get a valid command list, at least in nightly/aurora. r?bas MozReview-Commit-ID: JyUOZrEZ9hT
gfx/2d/DrawTargetD2D1.cpp
gfx/2d/Logging.h
--- a/gfx/2d/DrawTargetD2D1.cpp
+++ b/gfx/2d/DrawTargetD2D1.cpp
@@ -1196,20 +1196,26 @@ DrawTargetD2D1::PrepareForDrawing(Compos
     FlushTransformToDC();
 
     if (aOp != CompositionOp::OP_OVER)
       mDC->SetPrimitiveBlend(D2DPrimitiveBlendMode(aOp));
 
     return;
   }
 
-  mDC->CreateCommandList(getter_AddRefs(mCommandList));
+  HRESULT result = mDC->CreateCommandList(getter_AddRefs(mCommandList));
   mDC->SetTarget(mCommandList);
   mUsedCommandListsSincePurge++;
 
+  // This is where we should have a valid command list.  If we don't, something is
+  // wrong, and it's likely an OOM.
+  if (!mCommandList) {
+    gfxDevCrash(LogReason::InvalidCommandList) << "Invalid D2D1.1 command list on creation " << mUsedCommandListsSincePurge << ", " << gfx::hexa(result);
+  }
+
   D2D1_RECT_F rect;
   bool isAligned;
   bool clipIsComplex = CurrentLayer().mPushedClips.size() && !GetDeviceSpaceClipRect(rect, isAligned);
 
   if (ShouldClipTemporarySurfaceDrawing(aOp, aPattern, clipIsComplex)) {
     PushClipsToDC(mDC);
   }
 
@@ -1231,16 +1237,20 @@ DrawTargetD2D1::FinalizeDrawing(Composit
   bool isAligned;
   bool clipIsComplex = CurrentLayer().mPushedClips.size() && !GetDeviceSpaceClipRect(rect, isAligned);
 
   if (ShouldClipTemporarySurfaceDrawing(aOp, aPattern, clipIsComplex)) {
     PopClipsFromDC(mDC);
   }
 
   mDC->SetTarget(CurrentTarget());
+  if (!mCommandList) {
+    gfxDevCrash(LogReason::InvalidCommandList) << "Invalid D21.1 command list on finalize";
+    return;
+  }
   mCommandList->Close();
 
   RefPtr<ID2D1CommandList> source = mCommandList;
   mCommandList = nullptr;
 
   mDC->SetTransform(D2D1::IdentityMatrix());
   mTransformDirty = true;
 
--- a/gfx/2d/Logging.h
+++ b/gfx/2d/Logging.h
@@ -132,16 +132,17 @@ enum class LogReason : int {
   CannotDraw3D, // 20
   IncompatibleBasicTexturedEffect,
   InvalidFont,
   PAllocTextureBackendMismatch,
   GetFontFileDataFailed,
   MessageChannelCloseFailure,
   TextureAliveAfterShutdown,
   InvalidContext,
+  InvalidCommandList,
   // End
   MustBeLessThanThis = 101,
 };
 
 struct BasicLogger
 {
   // For efficiency, this method exists and copies the logic of the
   // OutputMessage below.  If making any changes here, also make it