Bug 1500833: Avoid updating if added animation was already removed. r=pbro
authorDaisuke Akatsuka <dakatsuka@mozilla.com>
Wed, 24 Oct 2018 13:32:02 +0000
changeset 491265 980d3b8e603b3cdebf7cc647b39b01576f0178b0
parent 491264 8399e5224d6935e06c37eb600b34967ba06b4487
child 491266 ece9ea20335f74562cc8f9c771d4149c0760703b
push id247
push userfmarier@mozilla.com
push dateSat, 27 Oct 2018 01:06:44 +0000
reviewerspbro
bugs1500833
milestone65.0a1
Bug 1500833: Avoid updating if added animation was already removed. r=pbro 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