Bug 1137944 - Backout compositor bits (cset b4711fa5f734) which caused a telemetry metric regression. r=backout
authorJim Mathies <jmathies@mozilla.com>
Tue, 08 Sep 2015 18:14:51 -0500
changeset 294175 5bb965937e246fe7d6017bba825902931727b095
parent 294174 0591a9b6e4a0ff333be4cf67fff34700f4c5ca5c
child 294176 a3197d3b445b7e6cd005d908e4f581308d84428a
push id5245
push userraliiev@mozilla.com
push dateThu, 29 Oct 2015 11:30:51 +0000
treeherdermozilla-beta@dac831dc1bd0 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbackout
bugs1137944
milestone43.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 1137944 - Backout compositor bits (cset b4711fa5f734) which caused a telemetry metric regression. r=backout
gfx/layers/ipc/CompositorParent.cpp
gfx/layers/ipc/CompositorParent.h
--- a/gfx/layers/ipc/CompositorParent.cpp
+++ b/gfx/layers/ipc/CompositorParent.cpp
@@ -1008,62 +1008,16 @@ CompositorParent::SetShadowProperties(La
   layerComposite->SetShadowOpacity(aLayer->GetOpacity());
 
   for (Layer* child = aLayer->GetFirstChild();
       child; child = child->GetNextSibling()) {
     SetShadowProperties(child);
   }
 }
 
-// handles firing of before and after composite events through
-// an raii type helper class.
-class AutoFireCompositorEvents {
-public:
-  explicit AutoFireCompositorEvents(CompositorParent* aTarget, bool aEnabled) :
-    mCompositor(aTarget),
-    mStart(TimeStamp::Now()),
-    mEnabled(aEnabled),
-    mWillSent(false),
-    mDidSent(false)
-  {
-  }
-
-  ~AutoFireCompositorEvents()
-  {
-    WillComposite();
-    DidComposite();
-  }
-
-  void WillComposite() {
-    if (mEnabled && mCompositor && !mWillSent) {
-      TimeStamp now = TimeStamp::Now();
-      mCompositor->CompositeEvent(WILL_COMPOSITE, mStart, now);
-    }
-    mWillSent = true;
-  }
-
-  void DidComposite() {
-    if (mEnabled && mCompositor && !mDidSent) {
-      TimeStamp now = TimeStamp::Now();
-      mCompositor->CompositeEvent(DID_COMPOSITE, mStart, now);
-    }
-    mDidSent = true;
-  }
-
-  void Cancel() {
-    mEnabled = false;
-  }
-
-  CompositorParent* mCompositor;
-  TimeStamp mStart;
-  bool mEnabled;
-  bool mWillSent;
-  bool mDidSent;
-};
-
 void
 CompositorParent::CompositeToTarget(DrawTarget* aTarget, const gfx::IntRect* aRect)
 {
   profiler_tracing("Paint", "Composite", TRACING_INTERVAL_START);
   PROFILER_LABEL("CompositorParent", "Composite",
     js::ProfileEntry::Category::GRAPHICS);
 
   MOZ_ASSERT(IsInCompositorThread(),
@@ -1074,20 +1028,19 @@ CompositorParent::CompositeToTarget(Draw
   TimeDuration scheduleDelta = TimeStamp::Now() - mCompositorScheduler->GetExpectedComposeStartTime();
   if (scheduleDelta > TimeDuration::FromMilliseconds(2) ||
       scheduleDelta < TimeDuration::FromMilliseconds(-2)) {
     printf_stderr("Compositor: Compose starting off schedule by %4.1f ms\n",
                   scheduleDelta.ToMilliseconds());
   }
 #endif
 
-  // Takes care of fireing 'will' and 'did' composite events.
-  AutoFireCompositorEvents afce(this, !aTarget);
-
   if (!CanComposite()) {
+    TimeStamp end = TimeStamp::Now();
+    DidComposite(start, end);
     return;
   }
 
   AutoResolveRefLayers resolve(mCompositionManager);
 
   if (aTarget) {
     mLayerManager->BeginTransactionWithDrawTarget(aTarget, *aRect);
   } else {
@@ -1096,23 +1049,20 @@ CompositorParent::CompositeToTarget(Draw
 
   SetShadowProperties(mLayerManager->GetRoot());
 
   if (mForceCompositionTask && !mOverrideComposeReadiness) {
     if (mCompositionManager->ReadyForCompose()) {
       mForceCompositionTask->Cancel();
       mForceCompositionTask = nullptr;
     } else {
-      afce.Cancel();
       return;
     }
   }
 
-  afce.WillComposite();
-
   mCompositionManager->ComputeRotation();
 
   TimeStamp time = mIsTesting ? mTestTime : mCompositorScheduler->GetLastComposeTime();
   bool requestNextFrame = mCompositionManager->TransformShadowTree(time);
   if (requestNextFrame) {
     ScheduleComposition();
   }
 
@@ -1122,16 +1072,21 @@ CompositorParent::CompositeToTarget(Draw
   if (gfxPrefs::DumpHostLayers()) {
     printf_stderr("Painting --- compositing layer tree:\n");
     mLayerManager->Dump();
   }
 #endif
   mLayerManager->SetDebugOverlayWantsNextFrame(false);
   mLayerManager->EndTransaction(time);
 
+  if (!aTarget) {
+    TimeStamp end = TimeStamp::Now();
+    DidComposite(start, end);
+  }
+
   // We're not really taking advantage of the stored composite-again-time here.
   // We might be able to skip the next few composites altogether. However,
   // that's a bit complex to implement and we'll get most of the advantage
   // by skipping compositing when we detect there's nothing invalid. This is why
   // we do "composite until" rather than "composite again at".
   if (!mCompositor->GetCompositeUntilTime().IsNull() ||
       mLayerManager->DebugOverlayWantsNextFrame()) {
     ScheduleComposition();
@@ -1762,20 +1717,19 @@ public:
   virtual void GetAPZTestData(const LayerTransactionParent* aLayerTree,
                               APZTestData* aOutData) override;
   virtual void SetConfirmedTargetAPZC(const LayerTransactionParent* aLayerTree,
                                       const uint64_t& aInputBlockId,
                                       const nsTArray<ScrollableLayerGuid>& aTargets) override;
 
   virtual AsyncCompositionManager* GetCompositionManager(LayerTransactionParent* aParent) override;
 
-  void CompositeEvent(CallbackType aType,
-                      uint64_t aId,
-                      TimeStamp& aCompositeStart,
-                      TimeStamp& aCompositeEnd);
+  void DidComposite(uint64_t aId,
+                    TimeStamp& aCompositeStart,
+                    TimeStamp& aCompositeEnd);
 
 private:
   // Private destructor, to discourage deletion outside of Release():
   virtual ~CrossProcessCompositorParent();
 
   void DeferredDestroy();
 
   // There can be many CPCPs, and IPDL-generated code doesn't hold a
@@ -1786,41 +1740,38 @@ private:
 
   nsRefPtr<CompositorThreadHolder> mCompositorThreadHolder;
   // If true, we should send a RemotePaintIsReady message when the layer transaction
   // is received
   bool mNotifyAfterRemotePaint;
 };
 
 void
-CompositorParent::CompositeEvent(CallbackType aType,
-                                 TimeStamp& aCompositeStart,
-                                 TimeStamp& aCompositeEnd)
+CompositorParent::DidComposite(TimeStamp& aCompositeStart,
+                               TimeStamp& aCompositeEnd)
 {
-  if (aType == DID_COMPOSITE) {
-    if (mPendingTransaction) {
-      unused << SendDidComposite(0, mPendingTransaction, aCompositeStart, aCompositeEnd);
-      mPendingTransaction = 0;
-    }
-    if (mLayerManager) {
-      nsTArray<ImageCompositeNotification> notifications;
-      mLayerManager->ExtractImageCompositeNotifications(&notifications);
-      if (!notifications.IsEmpty()) {
-        unused << ImageBridgeParent::NotifyImageComposites(notifications);
-      }
+  if (mPendingTransaction) {
+    unused << SendDidComposite(0, mPendingTransaction, aCompositeStart, aCompositeEnd);
+    mPendingTransaction = 0;
+  }
+  if (mLayerManager) {
+    nsTArray<ImageCompositeNotification> notifications;
+    mLayerManager->ExtractImageCompositeNotifications(&notifications);
+    if (!notifications.IsEmpty()) {
+      unused << ImageBridgeParent::NotifyImageComposites(notifications);
     }
   }
 
   MonitorAutoLock lock(*sIndirectLayerTreesLock);
   for (LayerTreeMap::iterator it = sIndirectLayerTrees.begin();
        it != sIndirectLayerTrees.end(); it++) {
     LayerTreeState* lts = &it->second;
     if (lts->mParent == this && lts->mCrossProcessParent) {
-      static_cast<CrossProcessCompositorParent*>(lts->mCrossProcessParent)->CompositeEvent(
-        aType, it->first, aCompositeStart, aCompositeEnd);
+      static_cast<CrossProcessCompositorParent*>(lts->mCrossProcessParent)->DidComposite(
+        it->first, aCompositeStart, aCompositeEnd);
     }
   }
 }
 
 static void
 OpenCompositor(CrossProcessCompositorParent* aCompositor,
                Transport* aTransport, ProcessId aOtherPid,
                MessageLoop* aIOLoop)
@@ -2091,42 +2042,29 @@ UpdatePluginWindowState(uint64_t aId)
     // Clear because there's no recovering from this until we receive
     // new shadow layer plugin data in ShadowLayersUpdated.
     lts.mPluginData.Clear();
   }
 }
 #endif // #if defined(XP_WIN) || defined(MOZ_WIDGET_GTK)
 
 void
-CrossProcessCompositorParent::CompositeEvent(CallbackType aType,
-                                             uint64_t aId,
-                                             TimeStamp& aCompositeStart,
-                                             TimeStamp& aCompositeEnd)
+CrossProcessCompositorParent::DidComposite(uint64_t aId,
+                                           TimeStamp& aCompositeStart,
+                                           TimeStamp& aCompositeEnd)
 {
-  switch (aType) {
-    case WILL_COMPOSITE: {
+  sIndirectLayerTreesLock->AssertCurrentThreadOwns();
+  LayerTransactionParent *layerTree = sIndirectLayerTrees[aId].mLayerTree;
+  if (layerTree && layerTree->GetPendingTransactionId()) {
+    unused << SendDidComposite(aId, layerTree->GetPendingTransactionId(), aCompositeStart, aCompositeEnd);
+    layerTree->SetPendingTransactionId(0);
+  }
 #if defined(XP_WIN) || defined(MOZ_WIDGET_GTK)
       UpdatePluginWindowState(aId);
 #endif
-      break;
-    }
-
-    case DID_COMPOSITE: {
-      sIndirectLayerTreesLock->AssertCurrentThreadOwns();
-      LayerTransactionParent *layerTree = sIndirectLayerTrees[aId].mLayerTree;
-      if (layerTree && layerTree->GetPendingTransactionId()) {
-        unused << SendDidComposite(aId, layerTree->GetPendingTransactionId(), aCompositeStart, aCompositeEnd);
-        layerTree->SetPendingTransactionId(0);
-      }
-      break;
-    }
-
-    default:
-      NS_RUNTIMEABORT("not reached");
-  }
 }
 
 void
 CrossProcessCompositorParent::ForceComposite(LayerTransactionParent* aLayerTree)
 {
   uint64_t id = aLayerTree->GetId();
   MOZ_ASSERT(id != 0);
   CompositorParent* parent;
--- a/gfx/layers/ipc/CompositorParent.h
+++ b/gfx/layers/ipc/CompositorParent.h
@@ -50,22 +50,16 @@ namespace layers {
 
 class APZCTreeManager;
 class AsyncCompositionManager;
 class Compositor;
 class CompositorParent;
 class LayerManagerComposite;
 class LayerTransactionParent;
 
-// CompositeEvent related events
-enum CallbackType {
-  WILL_COMPOSITE,
-  DID_COMPOSITE
-};
-
 struct ScopedLayerTreeRegistration
 {
   ScopedLayerTreeRegistration(uint64_t aLayersId,
                               Layer* aRoot,
                               GeckoContentController* aController);
   ~ScopedLayerTreeRegistration();
 
 private:
@@ -440,24 +434,17 @@ protected:
   static CompositorParent* RemoveCompositor(uint64_t id);
 
    /**
    * Return true if current state allows compositing, that is
    * finishing a layers transaction.
    */
   bool CanComposite();
 
-  // Fires before and after composite events
-  void CompositeEvent(CallbackType aType, TimeStamp& aCompositeStart,
-                      TimeStamp& aCompositeEnd);
-  void DidComposite(TimeStamp& aCompositeStart, TimeStamp& aCompositeEnd) {
-    CompositeEvent(DID_COMPOSITE, aCompositeStart, aCompositeEnd);
-  }
-
-  friend class AutoFireCompositorEvents;
+  void DidComposite(TimeStamp& aCompositeStart, TimeStamp& aCompositeEnd);
 
   nsRefPtr<LayerManagerComposite> mLayerManager;
   nsRefPtr<Compositor> mCompositor;
   RefPtr<AsyncCompositionManager> mCompositionManager;
   nsIWidget* mWidget;
   TimeStamp mTestTime;
   bool mIsTesting;