Bug 1500833 - Avoid updating if added animation was already removed. r=pbro, a=RyanVM
authorDaisuke Akatsuka <dakatsuka@mozilla.com>
Wed, 24 Oct 2018 13:32:02 +0000
changeset 500898 2e302b256039185f559d5ac6f621783bc83cbfa5
parent 500897 805ba967bcb5ad545958544a1ad0206d900a3fe8
child 500899 52d060761f0c9edacbcc7476b7d6ec919d9ce986
push id1864
push userffxbld-merge
push dateMon, 03 Dec 2018 15:51:40 +0000
treeherdermozilla-release@f040763d99ad [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerspbro, RyanVM
bugs1500833
milestone64.0
Bug 1500833 - Avoid updating if added animation was already removed. r=pbro, a=RyanVM Differential Revision: https://phabricator.services.mozilla.com/D9616
devtools/client/inspector/animation/animation.js
--- a/devtools/client/inspector/animation/animation.js
+++ b/devtools/client/inspector/animation/animation.js
@@ -307,20 +307,31 @@ class AnimationInspector {
   }
 
   async onAnimationsMutation(changes) {
     let animations = [...this.state.animations];
     const addedAnimations = [];
 
     for (const {type, player: animation} of changes) {
       if (type === "added") {
+        if (!animation.state.type) {
+          // This animation was added but removed immediately.
+          continue;
+        }
+
         addedAnimations.push(animation);
         animation.on("changed", this.onAnimationStateChanged);
       } else if (type === "removed") {
         const index = animations.indexOf(animation);
+
+        if (index < 0) {
+          // This animation was added but removed immediately.
+          continue;
+        }
+
         animations.splice(index, 1);
         animation.off("changed", this.onAnimationStateChanged);
       }
     }
 
     // Update existing other animations as well since the currentTime would be proceeded
     // sice the scrubber position is related the currentTime.
     // Also, don't update the state of removed animations since React components