Bug 1292273 - Skip CompositorD3D11::EndFrame when device-removed happened and add some logs for tracking the behavior. r=dvander, a=gchang
authorGuanWen-Chen <kechen@mozilla.com>
Sat, 22 Oct 2016 20:27:00 -0400
changeset 356314 256a14171223ca343090df223379207e5d4d3400
parent 356313 d562a23fd379d7e2485431e979303396c4941a6c
child 356315 c26d402c9cf21718816aa5d2a6381de0bfaea711
push id6570
push userraliiev@mozilla.com
push dateMon, 14 Nov 2016 12:26:13 +0000
treeherdermozilla-beta@f455459b2ae5 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdvander, gchang
bugs1292273
milestone51.0a2
Bug 1292273 - Skip CompositorD3D11::EndFrame when device-removed happened and add some logs for tracking the behavior. r=dvander, a=gchang
gfx/layers/d3d11/CompositorD3D11.cpp
--- a/gfx/layers/d3d11/CompositorD3D11.cpp
+++ b/gfx/layers/d3d11/CompositorD3D11.cpp
@@ -967,24 +967,31 @@ CompositorD3D11::BeginFrame(const nsIntR
                             const nsIntRegion& aOpaqueRegion,
                             IntRect* aClipRectOut,
                             IntRect* aRenderBoundsOut)
 {
   // Don't composite if we are minimised. Other than for the sake of efficency,
   // this is important because resizing our buffers when mimised will fail and
   // cause a crash when we're restored.
   NS_ASSERTION(mHwnd, "Couldn't find an HWND when initialising?");
-  if (::IsIconic(mHwnd) || mDevice->GetDeviceRemovedReason() != S_OK) {
+  if (::IsIconic(mHwnd)) {
     // We are not going to render, and not going to call EndFrame so we have to
     // read-unlock our textures to prevent them from accumulating.
     ReadUnlockTextures();
     *aRenderBoundsOut = IntRect();
     return;
   }
 
+  if (mDevice->GetDeviceRemovedReason() != S_OK) {
+    gfxCriticalNote << "GFX: D3D11 skip BeginFrame with device-removed.";
+    ReadUnlockTextures();
+    *aRenderBoundsOut = IntRect();
+    return;
+  }
+
   LayoutDeviceIntSize oldSize = mSize;
 
   // Failed to create a render target or the view.
   if (!UpdateRenderTarget() || !mDefaultRT || !mDefaultRT->mRTView ||
       mSize.width <= 0 || mSize.height <= 0) {
     ReadUnlockTextures();
     *aRenderBoundsOut = IntRect();
     return;
@@ -1067,16 +1074,23 @@ CompositorD3D11::BeginFrame(const nsIntR
 void
 CompositorD3D11::EndFrame()
 {
   if (!mDefaultRT) {
     Compositor::EndFrame();
     return;
   }
 
+  if (mDevice->GetDeviceRemovedReason() != S_OK) {
+    gfxCriticalNote << "GFX: D3D11 skip EndFrame with device-removed.";
+    Compositor::EndFrame();
+    mCurrentRT = nullptr;
+    return;
+  }
+
   LayoutDeviceIntSize oldSize = mSize;
   EnsureSize();
   if (mSize.width <= 0 || mSize.height <= 0) {
     Compositor::EndFrame();
     return;
   }
 
   RefPtr<ID3D11Query> query;