Skip to content

Commit

Permalink
Android Q related NaN error fix - don't try to do math with NaN values
Browse files Browse the repository at this point in the history
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
  • Loading branch information
Peter Laraia authored and facebook-github-bot committed Aug 27, 2019
1 parent 92a3c9d commit db59949
Showing 1 changed file with 3 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ public ValueAnimatedNode(ReadableMap config) {
}

public double getValue() {
if (Double.isNaN(mOffset + mValue)) {
this.update();
}
return mOffset + mValue;
}

Expand Down

0 comments on commit db59949

Please sign in to comment.