Bug 1539118 - "Crash in mozilla::gfx::DrawTargetD2D1::CreateBrushForPattern when using Canvas" a=pascalc FENNEC_66_0_2_BUILD1 FENNEC_66_0_2_RELEASE FIREFOX_66_0_2_BUILD1 FIREFOX_66_0_2_RELEASE
authorBas Schouten <bas>
Tue, 26 Mar 2019 05:06:00 +0200
changeset 516411 ed39a05717aaba84fa217aada9bc2ce77cf98e11
parent 516410 c00fbbe4f98880afd487fc8a1b67aed0bd46763b
child 516412 0cee3e44e7aa921ebfcbfff5c0f62ef5e98e11b8
push id1990
push userrgurzau@mozilla.com
push dateTue, 26 Mar 2019 17:52:29 +0000
treeherdermozilla-release@ed39a05717aa [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerspascalc
bugs1539118
milestone66.0.2
Bug 1539118 - "Crash in mozilla::gfx::DrawTargetD2D1::CreateBrushForPattern when using Canvas" a=pascalc
dom/canvas/CanvasRenderingContext2D.cpp
--- a/dom/canvas/CanvasRenderingContext2D.cpp
+++ b/dom/canvas/CanvasRenderingContext2D.cpp
@@ -1784,16 +1784,24 @@ bool CanvasRenderingContext2D::TryBasicT
     RefPtr<gfx::DrawTarget>& aOutDT,
     RefPtr<layers::PersistentBufferProvider>& aOutProvider) {
   aOutDT = gfxPlatform::GetPlatform()->CreateOffscreenCanvasDrawTarget(
       GetSize(), GetSurfaceFormat());
   if (!aOutDT) {
     return false;
   }
 
+  // See Bug 1524554 - this forces DT initialization.
+  aOutDT->ClearRect(gfx::Rect());
+
+  if (!aOutDT->IsValid()) {
+    aOutDT = nullptr;
+    return false;
+  }
+
   aOutProvider = new PersistentBufferProviderBasic(aOutDT);
   return true;
 }
 
 NS_IMETHODIMP
 CanvasRenderingContext2D::SetDimensions(int32_t aWidth, int32_t aHeight) {
   // Zero sized surfaces can cause problems.
   mZero = false;