Bug 1407900 - Part 1: Avoid updating animations UI during hidden. r?pbro draft
authorDaisuke Akatsuka <dakatsuka@mozilla.com>
Mon, 16 Oct 2017 10:17:53 +0900
changeset 680692 3684e9bdeb3ac8123df3ca2a74cf07ca6b4ba481
parent 678896 3d918ff5d63442d7b88e1b7e9cb03b832bc28fdf
child 680693 2b846073bf80b15967d3560fe9f753d4fcc37605
push id84588
push userbmo:dakatsuka@mozilla.com
push dateMon, 16 Oct 2017 05:16:34 +0000
reviewerspbro
bugs1407900
milestone58.0a1
Bug 1407900 - Part 1: Avoid updating animations UI during hidden. r?pbro MozReview-Commit-ID: Dl0NaIkeyWM
devtools/client/animationinspector/animation-controller.js
--- a/devtools/client/animationinspector/animation-controller.js
+++ b/devtools/client/animationinspector/animation-controller.js
@@ -223,21 +223,24 @@ var AnimationsController = {
 
   onPanelVisibilityChange: Task.async(function* () {
     if (this.isPanelVisible()) {
       this.onNewNodeFront();
     }
   }),
 
   onNewNodeFront: Task.async(function* () {
-    // Ignore if the panel isn't visible or the node selection hasn't changed.
-    if (!this.isPanelVisible() ||
-        this.nodeFront === gInspector.selection.nodeFront) {
+    // Ignore if the panel isn't visible.
+    // Or the node selection hasn't changed and no animation mutations event occurs during
+    // hidden.
+    if (!this.isPanelVisible() || (this.nodeFront === gInspector.selection.nodeFront &&
+                                   !this.mutationsDetectedWhileHidden)) {
       return;
     }
+    this.isMutationsEventOccuredDuringHidden = false;
 
     this.nodeFront = gInspector.selection.nodeFront;
     let done = gInspector.updating("animationscontroller");
 
     if (!gInspector.selection.isConnected() ||
         !gInspector.selection.isElementNode()) {
       this.destroyAnimationPlayers();
       this.emit(this.PLAYERS_UPDATED_EVENT);
@@ -356,18 +359,24 @@ var AnimationsController = {
       }
 
       if (type === "removed") {
         let index = this.animationPlayers.indexOf(player);
         this.animationPlayers.splice(index, 1);
       }
     }
 
-    // Let the UI know the list has been updated.
-    this.emit(this.PLAYERS_UPDATED_EVENT, this.animationPlayers);
+    if (this.isPanelVisible()) {
+      // Let the UI know the list has been updated.
+      this.emit(this.PLAYERS_UPDATED_EVENT, this.animationPlayers);
+    } else {
+      // Avoid updating the UI while the panel is hidden.
+      // This avoids unnecessary work.
+      this.mutationsDetectedWhileHidden = true;
+    }
   },
 
   /**
    * Get the latest known current time of document.timeline.
    * This value is sent along with all AnimationPlayerActors' states, but it
    * isn't updated after that, so this function loops over all know animations
    * to find the highest value.
    * @return {Number|Boolean} False is returned if this server version doesn't