Be sure to call EndLayerTransaction if there are queued paints. (bug 1412951, r=dvander)
authorRyan Hunt <rhunt@eqrion.net>
Mon, 30 Oct 2017 13:44:59 -0400
changeset 440107 d10121de5705b6ad9fb1fd0f8759457d8a3ef70b
parent 440106 905db84ed1726d0491d44fc7d1940d7172906e0c
child 440108 f4ce99faef05c10d52f7547e4dbe4a2e366282a3
push id8114
push userjlorenzo@mozilla.com
push dateThu, 02 Nov 2017 16:33:21 +0000
treeherdermozilla-beta@73e0d89a540f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdvander
bugs1412951
milestone58.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
Be sure to call EndLayerTransaction if there are queued paints. (bug 1412951, r=dvander) I believe this is the only case where we miss calling EndLayerTransaction, but still had queued async paints. This wasn't an issue before, because the following transaction would then do the synchronization. But I'd like to use EndLayerTransaction for a profiler mark, so we should call it unconditionally. MozReview-Commit-ID: 9rUXBzCZaLO
gfx/layers/client/ClientLayerManager.cpp
gfx/layers/client/ClientLayerManager.h
gfx/layers/client/ClientPaintedLayer.cpp
--- a/gfx/layers/client/ClientLayerManager.cpp
+++ b/gfx/layers/client/ClientLayerManager.cpp
@@ -96,17 +96,17 @@ ClientLayerManager::ClientLayerManager(n
   , mLatestTransactionId(0)
   , mLastPaintTime(TimeDuration::Forever())
   , mTargetRotation(ROTATION_0)
   , mRepeatTransaction(false)
   , mIsRepeatTransaction(false)
   , mTransactionIncomplete(false)
   , mCompositorMightResample(false)
   , mNeedsComposite(false)
-  , mTextureSyncOnPaintThread(false)
+  , mQueuedAsyncPaints(false)
   , mPaintSequenceNumber(0)
   , mDeviceResetSequenceNumber(0)
   , mForwarder(new ShadowLayerForwarder(this))
 {
   MOZ_COUNT_CTOR(ClientLayerManager);
   mMemoryPressureObserver = new MemoryPressureObserver(this);
 
   if (XRE_IsContentProcess()) {
@@ -355,17 +355,17 @@ ClientLayerManager::EndTransactionIntern
 #endif
 
   NS_ASSERTION(InConstruction(), "Should be in construction phase");
   mPhase = PHASE_DRAWING;
 
   ClientLayer* root = ClientLayer::ToClientLayer(GetRoot());
 
   mTransactionIncomplete = false;
-  mTextureSyncOnPaintThread = false;
+  mQueuedAsyncPaints = false;
 
   // Apply pending tree updates before recomputing effective
   // properties.
   GetRoot()->ApplyPendingUpdatesToSubtree();
 
   mPaintedLayerCallback = aCallback;
   mPaintedLayerCallbackData = aCallbackData;
 
@@ -462,16 +462,19 @@ ClientLayerManager::EndEmptyTransaction(
   if (!mRoot || !mForwarder->IPCOpen()) {
     return false;
   }
 
   if (!EndTransactionInternal(nullptr, nullptr, aFlags)) {
     // Return without calling ForwardTransaction. This leaves the
     // ShadowLayerForwarder transaction open; the following
     // EndTransaction will complete it.
+    if (PaintThread::Get() && mQueuedAsyncPaints) {
+      PaintThread::Get()->EndLayerTransaction(nullptr);
+    }
     return false;
   }
   if (mWidget) {
     mWidget->PrepareWindowEffects();
   }
   ForwardTransaction(!(aFlags & END_NO_REMOTE_COMPOSITE));
   MakeSnapshotIfRequired();
   return true;
@@ -737,17 +740,17 @@ ClientLayerManager::ForwardTransaction(b
       syncObject = mForwarder->GetSyncObject();
     }
   }
 
   // If there were async paints queued, then we need to notify the paint thread
   // that we finished queuing async paints so it can schedule a runnable after
   // all async painting is finished to do a texture sync and unblock the main
   // thread if it is waiting before doing a new layer transaction.
-  if (mTextureSyncOnPaintThread) {
+  if (mQueuedAsyncPaints) {
     MOZ_ASSERT(PaintThread::Get());
     PaintThread::Get()->EndLayerTransaction(syncObject);
   } else if (syncObject) {
     syncObject->Synchronize();
   }
 
   mPhase = PHASE_FORWARD;
 
--- a/gfx/layers/client/ClientLayerManager.h
+++ b/gfx/layers/client/ClientLayerManager.h
@@ -155,17 +155,17 @@ public:
   void HandleMemoryPressure();
 
   void SetRepeatTransaction() { mRepeatTransaction = true; }
   bool GetRepeatTransaction() { return mRepeatTransaction; }
 
   bool IsRepeatTransaction() { return mIsRepeatTransaction; }
 
   void SetTransactionIncomplete() { mTransactionIncomplete = true; }
-  void SetNeedTextureSyncOnPaintThread() { mTextureSyncOnPaintThread = true; }
+  void SetQueuedAsyncPaints() { mQueuedAsyncPaints = true; }
 
   bool HasShadowTarget() { return !!mShadowTarget; }
 
   void SetShadowTarget(gfxContext* aTarget) { mShadowTarget = aTarget; }
 
   bool CompositorMightResample() { return mCompositorMightResample; } 
   
   DrawPaintedLayerCallback GetPaintedLayerCallback() const
@@ -346,17 +346,17 @@ private:
 
   // Used to repeat the transaction right away (to avoid rebuilding
   // a display list) to support progressive drawing.
   bool mRepeatTransaction;
   bool mIsRepeatTransaction;
   bool mTransactionIncomplete;
   bool mCompositorMightResample;
   bool mNeedsComposite;
-  bool mTextureSyncOnPaintThread;
+  bool mQueuedAsyncPaints;
 
   // An incrementing sequence number for paints.
   // Incremented in BeginTransaction(), but not for repeat transactions.
   uint32_t mPaintSequenceNumber;
 
   // A sequence number for checking whether we have not yet acknowledged
   // a device reset.
   uint64_t mDeviceResetSequenceNumber;
--- a/gfx/layers/client/ClientPaintedLayer.cpp
+++ b/gfx/layers/client/ClientPaintedLayer.cpp
@@ -259,17 +259,17 @@ ClientPaintedLayer::PaintOffMainThread()
     didUpdate = true;
   }
 
   PaintThread::Get()->EndLayer();
   mContentClient->EndPaint(nullptr);
 
   if (didUpdate) {
     UpdateContentClient(state);
-    ClientManager()->SetNeedTextureSyncOnPaintThread();
+    ClientManager()->SetQueuedAsyncPaints();
   }
   return true;
 }
 
 void
 ClientPaintedLayer::RenderLayerWithReadback(ReadbackProcessor *aReadback)
 {
   RenderMaskLayers(this);