Bug 1373836 - Generate fixed animation id per layer if animations exist, r=kats a=jcristau
authorpeter chang <pchang@mozilla.com>
Wed, 28 Jun 2017 09:31:10 -0700
changeset 414214 47395fea9c849e3c1f8aa1056a3d59a72c1b299b
parent 414213 ebda0666d66ff826c321a3e7ab4d4c4230c06149
child 414215 b424dea9b108e06cbad74bf7eee92de4a5483a54
push id1490
push usermtabara@mozilla.com
push dateMon, 31 Jul 2017 14:08:16 +0000
treeherdermozilla-release@70e32e6bf15e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerskats, jcristau
bugs1373836
milestone55.0
Bug 1373836 - Generate fixed animation id per layer if animations exist, r=kats a=jcristau In gecko, it's possible to generate lots of animation ids per layer if animations are changed. It also introduces lots of memory allocation/deallocation in CompositorAnimationStorage(HashTable). Generate fixed animations id per layer should help the memory usage and reduce CPU time for memory allocation. MozReview-Commit-ID: 1hWUD5gNBJH
gfx/layers/Layers.cpp
gfx/layers/ipc/LayerTransactionParent.cpp
--- a/gfx/layers/Layers.cpp
+++ b/gfx/layers/Layers.cpp
@@ -237,17 +237,16 @@ Layer::ClearAnimations()
   mPendingAnimations = nullptr;
 
   if (mAnimations.IsEmpty() && mAnimationData.IsEmpty()) {
     return;
   }
 
   MOZ_LAYERS_LOG_IF_SHADOWABLE(this, ("Layer::Mutated(%p) ClearAnimations", this));
   mAnimations.Clear();
-  mCompositorAnimationsId = 0;
   mAnimationData.Clear();
   Mutated();
 }
 
 Animation*
 Layer::AddAnimationForNextTransaction()
 {
   MOZ_ASSERT(mPendingAnimations,
--- a/gfx/layers/ipc/LayerTransactionParent.cpp
+++ b/gfx/layers/ipc/LayerTransactionParent.cpp
@@ -532,16 +532,27 @@ LayerTransactionParent::SetLayerAttribut
     layer->SetClipRect(clipRect);
   }
   if (LayerHandle maskLayer = common.maskLayer()) {
     layer->SetMaskLayer(AsLayer(maskLayer));
   } else {
     layer->SetMaskLayer(nullptr);
   }
   layer->SetCompositorAnimations(common.compositorAnimations());
+  // Clean up the Animations by id in the CompositorAnimationStorage
+  // if there are no active animations on the layer
+  if (layer->GetCompositorAnimationsId() &&
+      layer->GetAnimations().IsEmpty()) {
+    CompositorAnimationStorage* storage =
+      mCompositorBridge->GetAnimationStorage(GetId());
+
+    if (storage) {
+      storage->ClearById(layer->GetCompositorAnimationsId());
+    }
+  }
   if (common.scrollMetadata() != layer->GetAllScrollMetadata()) {
     UpdateHitTestingTree(layer, "scroll metadata changed");
     layer->SetScrollMetadata(common.scrollMetadata());
   }
   layer->SetDisplayListLog(common.displayListLog().get());
 
   // The updated invalid region is added to the existing one, since we can
   // update multiple times before the next composite.