Bug 1459233 - Make SyncObjectD3D11Host::Synchronize() fallible with WebRender r=mattwoodrow
authorsotaro <sotaro.ikeda.g@gmail.com>
Fri, 05 Oct 2018 14:49:04 +0900
changeset 495510 2558c8ea6ad2075c51b18d79330ec2d59eeabc5a
parent 495509 dae89dbd2159c0b2a5865389dadab9a8f938e8ee
child 495511 463cee9e37d965f514aec1bc546db7ce7321ece6
push id9984
push userffxbld-merge
push dateMon, 15 Oct 2018 21:07:35 +0000
treeherdermozilla-beta@183d27ea8570 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmattwoodrow
bugs1459233
milestone64.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 1459233 - Make SyncObjectD3D11Host::Synchronize() fallible with WebRender r=mattwoodrow
gfx/layers/SyncObject.h
gfx/layers/d3d11/TextureD3D11.cpp
gfx/layers/d3d11/TextureD3D11.h
gfx/webrender_bindings/RenderCompositorANGLE.cpp
--- a/gfx/layers/SyncObject.h
+++ b/gfx/layers/SyncObject.h
@@ -32,17 +32,17 @@ public:
 #endif
                                                               );
 
   virtual bool Init() = 0;
 
   virtual SyncHandle GetSyncHandle() = 0;
 
   // Return false for failed synchronization.
-  virtual bool Synchronize() = 0;
+  virtual bool Synchronize(bool aFallible = false) = 0;
 
 protected:
   SyncObjectHost() { }
 };
 
 class SyncObjectClient : public external::AtomicRefCounted<SyncObjectClient>
 {
 public:
--- a/gfx/layers/d3d11/TextureD3D11.cpp
+++ b/gfx/layers/d3d11/TextureD3D11.cpp
@@ -1711,32 +1711,34 @@ SyncObjectD3D11Host::Init()
 
 SyncHandle
 SyncObjectD3D11Host::GetSyncHandle()
 {
   return mSyncHandle;
 }
 
 bool
-SyncObjectD3D11Host::Synchronize()
+SyncObjectD3D11Host::Synchronize(bool aFallible)
 {
   HRESULT hr;
   AutoTextureLock lock(mKeyedMutex, hr, 10000);
 
   if (hr == WAIT_TIMEOUT) {
     hr = mDevice->GetDeviceRemovedReason();
-    if (hr == S_OK) {
+    if (hr != S_OK ) {
+      // Since the timeout is related to the driver-removed. Return false for
+      // error handling.
+      gfxCriticalNote << "GFX: D3D11 timeout with device-removed:" << gfx::hexa(hr);
+    } else if (aFallible) {
+      gfxCriticalNote << "GFX: D3D11 timeout on the D3D11 sync lock.";
+    } else {
       // There is no driver-removed event. Crash with this timeout.
       MOZ_CRASH("GFX: D3D11 normal status timeout");
     }
 
-    // Since the timeout is related to the driver-removed. Return false for
-    // error handling.
-    gfxCriticalNote << "GFX: D3D11 timeout with device-removed:" << gfx::hexa(hr);
-
     return false;
   }
   if (hr == WAIT_ABANDONED) {
     gfxCriticalNote << "GFX: AL_D3D11 abandoned sync";
   }
 
   return true;
 }
--- a/gfx/layers/d3d11/TextureD3D11.h
+++ b/gfx/layers/d3d11/TextureD3D11.h
@@ -493,17 +493,17 @@ class SyncObjectD3D11Host : public SyncO
 {
 public:
   explicit SyncObjectD3D11Host(ID3D11Device* aDevice);
 
   virtual bool Init() override;
 
   virtual SyncHandle GetSyncHandle() override;
 
-  virtual bool Synchronize() override;
+  virtual bool Synchronize(bool aFallible) override;
 
   IDXGIKeyedMutex* GetKeyedMutex() { return mKeyedMutex.get(); };
 
 private:
   virtual ~SyncObjectD3D11Host() { }
 
   SyncHandle mSyncHandle;
   RefPtr<ID3D11Device> mDevice;
--- a/gfx/webrender_bindings/RenderCompositorANGLE.cpp
+++ b/gfx/webrender_bindings/RenderCompositorANGLE.cpp
@@ -306,17 +306,17 @@ RenderCompositorANGLE::BeginFrame()
   }
 
   if (!MakeCurrent()) {
     gfxCriticalNote << "Failed to make render context current, can't draw.";
     return false;
   }
 
   if (mSyncObject) {
-    if (!mSyncObject->Synchronize()) {
+    if (!mSyncObject->Synchronize(/* aFallible */ true)) {
       // It's timeout or other error. Handle the device-reset here.
       RenderThread::Get()->HandleDeviceReset("SyncObject", /* aNotify */ true);
       return false;
     }
   }
   return true;
 }