Bug 1462229 - Part 1: Avoid updating the state of removed animation. r=gl
authorDaisuke Akatsuka <dakatsuka@mozilla.com>
Mon, 28 May 2018 08:57:16 +0900
changeset 420090 453e9dd459a2a30a7e2dc6a0c847834f461c4d84
parent 420089 ed795ab22fe5ea48ebc3854bc70e144bdd3f2073
child 420091 452e577be2f4e4ffc7e7415572187e1d4c5f60af
push id64504
push userdakatsuka@mozilla.com
push dateMon, 28 May 2018 04:53:06 +0000
treeherderautoland@443ff1adf8ab [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersgl
bugs1462229
milestone62.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 1462229 - Part 1: Avoid updating the state of removed animation. r=gl MozReview-Commit-ID: IAdHpqXe4Ta
devtools/client/inspector/animation/animation.js
--- a/devtools/client/inspector/animation/animation.js
+++ b/devtools/client/inspector/animation/animation.js
@@ -286,34 +286,40 @@ class AnimationInspector {
     if (shouldStop) {
       this.setAnimationsCurrentTime(currentTime, true);
     } else {
       this.onAnimationsCurrentTimeUpdated(currentTime);
     }
   }
 
   async onAnimationsMutation(changes) {
-    const animations = [...this.state.animations];
-
-    // Update other animations as well since the currentTime would be proceeded.
-    // Because the scrubber position is related the currentTime.
-    await this.updateAnimations(animations);
+    let animations = [...this.state.animations];
+    const addedAnimations = [];
 
     for (const {type, player: animation} of changes) {
       if (type === "added") {
-        animations.push(animation);
+        addedAnimations.push(animation);
         animation.on("changed", this.onAnimationStateChanged);
       } else if (type === "removed") {
         const index = animations.indexOf(animation);
         animations.splice(index, 1);
         animation.off("changed", this.onAnimationStateChanged);
       }
     }
 
-    this.updateState(animations);
+    // 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
+    // may refer to the same instance still.
+    await this.updateAnimations(animations);
+
+    // Get rid of animations that were removed during async updateAnimations().
+    animations = animations.filter(animation => !!animation.state.type);
+
+    this.updateState(animations.concat(addedAnimations));
   }
 
   onElementPickerStarted() {
     this.inspector.store.dispatch(updateElementPickerEnabled(true));
   }
 
   onElementPickerStopped() {
     this.inspector.store.dispatch(updateElementPickerEnabled(false));