Bug 1001853 - Don't loop waiting on the monitor, and acccount for the fact that timeouts are treated as success. r=jgilbert
authorMatt Woodrow <mwoodrow@mozilla.com>
Wed, 14 May 2014 16:10:00 +1200
changeset 183052 370d74cb269d7dbeed3dfc0832385dffa8ef1602
parent 183051 d6bd79de08f43940eec337b1cc227a531002497f
child 183053 2d37218a619e3119d3aefaa2b5dc21d77527f7a0
push id43455
push usermwoodrow@mozilla.com
push dateWed, 14 May 2014 04:10:47 +0000
treeherdermozilla-inbound@2d37218a619e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjgilbert
bugs1001853
milestone32.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 1001853 - Don't loop waiting on the monitor, and acccount for the fact that timeouts are treated as success. r=jgilbert
gfx/gl/SurfaceStream.cpp
gfx/gl/SurfaceStream.h
--- a/gfx/gl/SurfaceStream.cpp
+++ b/gfx/gl/SurfaceStream.cpp
@@ -429,20 +429,23 @@ SurfaceStream_TripleBuffer::SwapProducer
     PROFILER_LABEL("SurfaceStream_TripleBuffer", "SwapProducer");
 
     MonitorAutoLock lock(mMonitor);
     if (mProducer) {
         RecycleScraps(factory);
 
         // If WaitForCompositor succeeds, mStaging has moved to mConsumer.
         // If it failed, we might have to scrap it.
-        if (mStaging && !WaitForCompositor())
+        if (mStaging) {
+            WaitForCompositor();
+        }
+        if (mStaging) {
             Scrap(mStaging);
+        }
 
-        MOZ_ASSERT(!mStaging);
         Move(mProducer, mStaging);
         mStaging->Fence();
     }
 
     MOZ_ASSERT(!mProducer);
     New(factory, size, mProducer);
 
     return mProducer;
@@ -465,25 +468,21 @@ SurfaceStream_TripleBuffer_Async::Surfac
     : SurfaceStream_TripleBuffer(SurfaceStreamType::TripleBuffer_Async, prevStream)
 {
 }
 
 SurfaceStream_TripleBuffer_Async::~SurfaceStream_TripleBuffer_Async()
 {
 }
 
-bool
+void
 SurfaceStream_TripleBuffer_Async::WaitForCompositor()
 {
     PROFILER_LABEL("SurfaceStream_TripleBuffer_Async", "WaitForCompositor");
 
-    // We are assumed to be locked
-    while (mStaging) {
-        if (!NS_SUCCEEDED(mMonitor.Wait(PR_MillisecondsToInterval(100)))) {
-            return false;
-        }
-    }
-
-    return true;
+    // If we haven't be notified within 100ms, then
+    // something must have happened and it will never arrive.
+    // Bail out to avoid deadlocking.
+    mMonitor.Wait(PR_MillisecondsToInterval(100));
 }
 
 } /* namespace gfx */
 } /* namespace mozilla */
--- a/gfx/gl/SurfaceStream.h
+++ b/gfx/gl/SurfaceStream.h
@@ -187,17 +187,17 @@ public:
 class SurfaceStream_TripleBuffer
     : public SurfaceStream
 {
 protected:
     SharedSurface* mStaging;
     SharedSurface* mConsumer;
 
     // Returns true if we were able to wait, false if not
-    virtual bool WaitForCompositor() { return false; }
+    virtual void WaitForCompositor() {}
 
     // To support subclasses initializing the mType.
     SurfaceStream_TripleBuffer(SurfaceStreamType type, SurfaceStream* prevStream);
 
 public:
     MOZ_DECLARE_REFCOUNTED_VIRTUAL_TYPENAME(SurfaceStream_TripleBuffer)
     SurfaceStream_TripleBuffer(SurfaceStream* prevStream);
     virtual ~SurfaceStream_TripleBuffer();
@@ -216,17 +216,17 @@ public:
 
     virtual void SurrenderSurfaces(SharedSurface*& producer, SharedSurface*& consumer);
 };
 
 class SurfaceStream_TripleBuffer_Async
     : public SurfaceStream_TripleBuffer
 {
 protected:
-    virtual bool WaitForCompositor() MOZ_OVERRIDE;
+    virtual void WaitForCompositor() MOZ_OVERRIDE;
 
 public:
     SurfaceStream_TripleBuffer_Async(SurfaceStream* prevStream);
     virtual ~SurfaceStream_TripleBuffer_Async();
 };
 
 
 } /* namespace gfx */