Skip to content

Commit db59949

Browse files
Peter Laraiafacebook-github-bot
Peter Laraia
authored andcommitted
Android Q related NaN error fix - don't try to do math with NaN values
Summary: We noticed a repro-able crash in Ride in T52804960 on Android Q due to NaN being passed into setCameraDistance on View see Oleg's related post: https://fb.workplace.com/groups/rn.support/permalink/2682537011794897/ It looks like a generic fix or wrapper around View setCameraDistance might be planned in T48580247 But in the meantime, it kind of maybe seems reasonable-ish to say, ~~if the value of an input node is NaN, don't use it in the math for this node?~~ if a one of the inputs for this node evaluates to NaN, update that input node first? But I'm not super familiar with the Animations library so maybe that's not a good idea, idk. From what I can tell in our specific error, it's coming from an InterpolatedNode A based off an AdditionNode B which tried to add a ValueNode C + a InterpolatedNode D, but D had only just been created and not had it's first update, so it's value was NaN, and so when B runs it's update value of C + NaN means B's new values is also NaN, and A's subsequent update based on that now comes out to NaN. Atleast that's what it seems like based on Log statements. Reviewed By: olegbl Differential Revision: D16960177 fbshipit-source-id: 99c8ca35be4b5e99f7c21db6733ebd622ae39d07
1 parent 92a3c9d commit db59949

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

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

+3
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@ public ValueAnimatedNode(ReadableMap config) {
2929
}
3030

3131
public double getValue() {
32+
if (Double.isNaN(mOffset + mValue)) {
33+
this.update();
34+
}
3235
return mOffset + mValue;
3336
}
3437

0 commit comments

Comments
 (0)