Browse files

Fix a race condition in the animation module

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
  • Loading branch information...
mhorowitz authored and facebook-github-bot committed Nov 6, 2017
1 parent 1ee64cc commit 515eb0e8012a7a8f085a8e410c6c694011fd8c1d
@@ -1,9 +1,15 @@
* Copyright (c) 2015-present, Facebook, Inc. All rights reserved.
* <p>This source code is licensed under the BSD-style license found in the LICENSE file in the root
* directory of this source tree. An additional grant of patent rights can be found in the PATENTS
* file in the same directory.
package com.facebook.react.animated;

import com.facebook.react.bridge.JSApplicationIllegalArgumentException;
import com.facebook.react.bridge.ReadableArray;
import com.facebook.react.bridge.ReadableMap;

import javax.annotation.Nullable;

@@ -133,8 +139,9 @@ public void onDetachedFromNode(AnimatedNode parent) {
public void update() {
if (mParent == null) {
throw new IllegalStateException("Trying to update interpolation node that has not been " +
"attached to the parent");
// The graph is in the middle of being created, just skip this
// unattached node.
mValue = interpolate(mParent.getValue(), mInputRange, mOutputRange, mExtrapolateLeft, mExtrapolateRight);

0 comments on commit 515eb0e

Please sign in to comment.