Bug 1026893 - Bandaid to catch D3D11 related crashes and deal with them. r=jmuizelaar, a=lmandel
authorBas Schouten <bas@basschouten.com>
Mon, 24 Nov 2014 14:06:15 -0500
changeset 227422 5461eeca3dafb1feb3ec0df84df34d7b3e2b5b3b
parent 227421 75519081f3bb839cbaade5aa2933e4cd12297744
child 227423 ad1b0b9af31ea2ba47ae239f29570daa376b176a
push id585
push userryanvm@gmail.com
push dateMon, 24 Nov 2014 21:02:35 +0000
treeherdermozilla-release@01cac0e2c396 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjmuizelaar, lmandel
bugs1026893
milestone34.0
Bug 1026893 - Bandaid to catch D3D11 related crashes and deal with them. r=jmuizelaar, a=lmandel
gfx/thebes/gfxWindowsPlatform.cpp
--- a/gfx/thebes/gfxWindowsPlatform.cpp
+++ b/gfx/thebes/gfxWindowsPlatform.cpp
@@ -393,17 +393,17 @@ gfxWindowsPlatform::UpdateRenderMode()
 
     ID3D11Device *device = GetD3D11Device();
     if (isVistaOrHigher && !safeMode && tryD2D &&
         device &&
         device->GetFeatureLevel() >= D3D_FEATURE_LEVEL_10_0 &&
         DoesD3D11DeviceWork(device)) {
 
         VerifyD2DDevice(d2dForceEnabled);
-        if (mD2DDevice) {
+        if (mD2DDevice && GetD3D11Device()) {
             mRenderMode = RENDER_DIRECT2D;
             mUseDirectWrite = true;
         }
     } else {
         mD2DDevice = nullptr;
     }
 #endif
 
@@ -1401,23 +1401,29 @@ gfxWindowsPlatform::GetD3D11Device()
   featureLevels.AppendElement(D3D_FEATURE_LEVEL_9_3);
 
   RefPtr<IDXGIAdapter1> adapter = GetDXGIAdapter();
 
   if (!adapter) {
     return nullptr;
   }
 
-  HRESULT hr = d3d11CreateDevice(adapter, D3D_DRIVER_TYPE_UNKNOWN, nullptr,
-                                 // Use
-                                 // D3D11_CREATE_DEVICE_PREVENT_INTERNAL_THREADING_OPTIMIZATIONS
-                                 // to prevent bug 1092260. IE 11 also uses this flag.
-                                 D3D11_CREATE_DEVICE_BGRA_SUPPORT | D3D11_CREATE_DEVICE_PREVENT_INTERNAL_THREADING_OPTIMIZATIONS,
-                                 featureLevels.Elements(), featureLevels.Length(),
-                                 D3D11_SDK_VERSION, byRef(mD3D11Device), nullptr, nullptr);
+  HRESULT hr = E_INVALIDARG;
+  __try {
+    hr = d3d11CreateDevice(adapter, D3D_DRIVER_TYPE_UNKNOWN, nullptr,
+                           // Use
+                           // D3D11_CREATE_DEVICE_PREVENT_INTERNAL_THREADING_OPTIMIZATIONS
+                           // to prevent bug 1092260. IE 11 also uses this flag.
+                           D3D11_CREATE_DEVICE_BGRA_SUPPORT | D3D11_CREATE_DEVICE_PREVENT_INTERNAL_THREADING_OPTIMIZATIONS,
+                           featureLevels.Elements(), featureLevels.Length(),
+                           D3D11_SDK_VERSION, byRef(mD3D11Device), nullptr, nullptr);
+  } __except (EXCEPTION_EXECUTE_HANDLER) {
+    mD3D11Device = nullptr;
+    return nullptr;
+  }
 
   // We leak these everywhere and we need them our entire runtime anyway, let's
   // leak it here as well.
   d3d11Module.disown();
 
   if (SUCCEEDED(hr)) {
     mD3D11Device->SetExceptionMode(0);
   }