Bug 1119854: Crash when AcquireSync takes more than 10 seconds. r=jrmuizel
authorBas Schouten <bschouten@mozilla.com>
Sat, 10 Jan 2015 04:50:02 +0100
changeset 248933 18bc11b32f6f637b3358a63d54e91a4aaa5c428a
parent 248932 9d9610c574b4a78adb93c104c2c956d4f0f44241
child 248934 1831405086dc4c3a8b10b632da3f62ba43b85beb
push id4489
push userraliiev@mozilla.com
push dateMon, 23 Feb 2015 15:17:55 +0000
treeherdermozilla-beta@fd7c3dc24146 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjrmuizel
bugs1119854
milestone37.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 1119854: Crash when AcquireSync takes more than 10 seconds. r=jrmuizel
gfx/gl/SharedSurfaceANGLE.cpp
gfx/layers/d3d11/CompositorD3D11.cpp
gfx/layers/d3d11/TextureD3D11.cpp
--- a/gfx/gl/SharedSurfaceANGLE.cpp
+++ b/gfx/gl/SharedSurfaceANGLE.cpp
@@ -153,18 +153,22 @@ bool
 SharedSurface_ANGLEShareHandle::PollSync()
 {
     return true;
 }
 
 void
 SharedSurface_ANGLEShareHandle::ProducerAcquireImpl()
 {
-  if (mKeyedMutex)
-      mKeyedMutex->AcquireSync(0, INFINITE);
+    if (mKeyedMutex) {
+        HRESULT hr = mKeyedMutex->AcquireSync(0, INFINITE);
+        if (hr == WAIT_TIMEOUT) {
+            MOZ_CRASH();
+        }
+    }
 }
 
 void
 SharedSurface_ANGLEShareHandle::ProducerReleaseImpl()
 {
     if (mKeyedMutex) {
         GLLibraryEGL* egl = &sEGLLibrary;
         mGL->fFlush();
@@ -192,18 +196,22 @@ SharedSurface_ANGLEShareHandle::Consumer
             hr = tex->QueryInterface((IDXGIKeyedMutex**)byRef(mutex));
 
             if (SUCCEEDED(hr)) {
                 mConsumerKeyedMutex = mutex;
             }
         }
     }
 
-    if (mConsumerKeyedMutex)
-        mConsumerKeyedMutex->AcquireSync(0, INFINITE);
+    if (mConsumerKeyedMutex) {
+      HRESULT hr = mConsumerKeyedMutex->AcquireSync(0, 10000);
+      if (hr == WAIT_TIMEOUT) {
+        MOZ_CRASH();
+      }
+    }
 }
 
 void
 SharedSurface_ANGLEShareHandle::ConsumerReleaseImpl()
 {
     if (mConsumerKeyedMutex) {
         mConsumerKeyedMutex->ReleaseSync(0);
     }
--- a/gfx/layers/d3d11/CompositorD3D11.cpp
+++ b/gfx/layers/d3d11/CompositorD3D11.cpp
@@ -1093,17 +1093,21 @@ CompositorD3D11::BeginFrame(const nsIntR
 
   // ClearRect will set the correct blend state for us.
   ClearRect(Rect(invalidRect.x, invalidRect.y, invalidRect.width, invalidRect.height));
 
   RefPtr<IDXGIKeyedMutex> mutex;
   mAttachments->mSyncTexture->QueryInterface((IDXGIKeyedMutex**)byRef(mutex));
 
   MOZ_ASSERT(mutex);
-  mutex->AcquireSync(0, INFINITE);
+  HRESULT hr = mutex->AcquireSync(0, 10000);
+  if (hr == WAIT_TIMEOUT) {
+    MOZ_CRASH();
+  }
+
   mutex->ReleaseSync(0);
 }
 
 void
 CompositorD3D11::EndFrame()
 {
   mContext->Flush();
 
--- a/gfx/layers/d3d11/TextureD3D11.cpp
+++ b/gfx/layers/d3d11/TextureD3D11.cpp
@@ -109,17 +109,21 @@ DataTextureSourceD3D11::~DataTextureSour
 template<typename T> // ID3D10Texture2D or ID3D11Texture2D
 static bool LockD3DTexture(T* aTexture)
 {
   MOZ_ASSERT(aTexture);
   RefPtr<IDXGIKeyedMutex> mutex;
   aTexture->QueryInterface((IDXGIKeyedMutex**)byRef(mutex));
   // Textures created by the DXVA decoders don't have a mutex for synchronization
   if (mutex) {
-    HRESULT hr = mutex->AcquireSync(0, INFINITE);
+    HRESULT hr = mutex->AcquireSync(0, 10000);
+    if (hr == WAIT_TIMEOUT) {
+      MOZ_CRASH();
+    }
+
     if (FAILED(hr)) {
       NS_WARNING("Failed to lock the texture");
       return false;
     }
   }
   return true;
 }
 
@@ -753,17 +757,21 @@ SyncObjectD3D11::FinalizeFrame()
       gfxCriticalError() << "Failed to get KeyedMutex: " << hexa(hr);
       MOZ_CRASH();
     }
   }
 
   if (mD3D10SyncedTextures.size()) {
     RefPtr<IDXGIKeyedMutex> mutex;
     hr = mD3D10Texture->QueryInterface((IDXGIKeyedMutex**)byRef(mutex));
-    mutex->AcquireSync(0, INFINITE);
+    hr = mutex->AcquireSync(0, 10000);
+
+    if (hr == WAIT_TIMEOUT) {
+      MOZ_CRASH();
+    }
 
     D3D10_BOX box;
     box.front = box.top = box.left = 0;
     box.back = box.bottom = box.right = 1;
 
     ID3D10Device* device = gfxWindowsPlatform::GetPlatform()->GetD3D10Device();
 
     for (auto iter = mD3D10SyncedTextures.begin(); iter != mD3D10SyncedTextures.end(); iter++) {
@@ -773,17 +781,21 @@ SyncObjectD3D11::FinalizeFrame()
     mutex->ReleaseSync(0);
 
     mD3D10SyncedTextures.clear();
   }
 
   if (mD3D11SyncedTextures.size()) {
     RefPtr<IDXGIKeyedMutex> mutex;
     hr = mD3D11Texture->QueryInterface((IDXGIKeyedMutex**)byRef(mutex));
-    mutex->AcquireSync(0, INFINITE);
+    hr = mutex->AcquireSync(0, 10000);
+
+    if (hr == WAIT_TIMEOUT) {
+      MOZ_CRASH();
+    }
 
     D3D11_BOX box;
     box.front = box.top = box.left = 0;
     box.back = box.bottom = box.right = 1;
 
     ID3D11Device* dev = gfxWindowsPlatform::GetPlatform()->GetD3D11ContentDevice();
     RefPtr<ID3D11DeviceContext> ctx;
     dev->GetImmediateContext(byRef(ctx));