Bug 1264736: Crash sooner if we can't get a valid command list, at least in nightly/aurora. r=bas
authorMilan Sreckovic <milan@mozilla.com>
Wed, 20 Apr 2016 12:11:00 -0400
changeset 294369 b341e24b1241986591eb00866e2a8df584f7b4dc
parent 294368 ac3b40d2cedc0952e7301096ab795e751ab91398
child 294370 91b6739888bf9fbb9dd2a92c0a7aa422b239ad15
push id30203
push usercbook@mozilla.com
push dateFri, 22 Apr 2016 13:56:37 +0000
treeherdermozilla-central@fc15477ce628 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbas
bugs1264736
milestone48.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
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