Bug 1264736: Crash sooner if we can't get a valid command list, at least in nightly/aurora. r?bas
MozReview-Commit-ID: JyUOZrEZ9hT
--- 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