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
This commit is contained in:
parent
1ee64ccb8a
commit
515eb0e801
|
@ -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 @@ import javax.annotation.Nullable;
|
|||
@Override
|
||||
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.
|
||||
return;
|
||||
}
|
||||
mValue = interpolate(mParent.getValue(), mInputRange, mOutputRange, mExtrapolateLeft, mExtrapolateRight);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue