Skip to content

Commit 515eb0e

Browse files
mhorowitzfacebook-github-bot
authored andcommitted
Fix a race condition in the animation module
Summary: update() is called from the choreographer, so it can be invoked asynchronously relative to RN. If it's called while the node tree is incomplete, this can be called with no parent. Don't treat an unparented node as an invariant failure, just skip over it. Reviewed By: AaaChiuuu Differential Revision: D6249038 fbshipit-source-id: d22807dff1659bf29a81893ab97d0fe7c19de512
1 parent 1ee64cc commit 515eb0e

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

ReactAndroid/src/main/java/com/facebook/react/animated/InterpolationAnimatedNode.java

+10-3
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,15 @@
1+
/**
2+
* Copyright (c) 2015-present, Facebook, Inc. All rights reserved.
3+
*
4+
* <p>This source code is licensed under the BSD-style license found in the LICENSE file in the root
5+
* directory of this source tree. An additional grant of patent rights can be found in the PATENTS
6+
* file in the same directory.
7+
*/
18
package com.facebook.react.animated;
29

310
import com.facebook.react.bridge.JSApplicationIllegalArgumentException;
411
import com.facebook.react.bridge.ReadableArray;
512
import com.facebook.react.bridge.ReadableMap;
6-
713
import javax.annotation.Nullable;
814

915
/**
@@ -133,8 +139,9 @@ public void onDetachedFromNode(AnimatedNode parent) {
133139
@Override
134140
public void update() {
135141
if (mParent == null) {
136-
throw new IllegalStateException("Trying to update interpolation node that has not been " +
137-
"attached to the parent");
142+
// The graph is in the middle of being created, just skip this
143+
// unattached node.
144+
return;
138145
}
139146
mValue = interpolate(mParent.getValue(), mInputRange, mOutputRange, mExtrapolateLeft, mExtrapolateRight);
140147
}

0 commit comments

Comments
 (0)