toValue error dialog because of getValue() in ReadableNativeMap.java
See original GitHub issuePlease ignore duplicate issue #23267 keep this as the issue
Environment
React Native Environment Info: System: OS: Linux 4.15 Ubuntu 16.04.5 LTS (Xenial Xerus) CPU: (4) x64 Intel® Core™ i5-5200U CPU @ 2.20GHz Memory: 125.41 MB / 7.70 GB Shell: 4.3.48 - /bin/bash Binaries: Node: 8.15.0 - /usr/bin/node npm: 6.4.1 - /usr/bin/npm SDKs: Android SDK: API Levels: 23, 25, 26, 27, 28 Build Tools: 27.0.3, 28.0.2, 28.0.3 System Images: android-28 | Google APIs Intel x86 Atom, android-28 | Google Play Intel x86 Atom IDEs: Android Studio: 3.2 AI-181.5540.7.32.5056338 npmPackages: react: 16.6.3 => 16.6.3 react-native: ^0.57.8 => 0.57.8 npmGlobalPackages: react-native-cli: 2.0.1 react-native-git-upgrade: 0.2.7 react-native-rename: 2.4.0
Description
Error dialog saying ‘toValue’ pops up. I am aware about the potential Fix #19808 reported for issue #19793 Safely unwrapping ReadableMap by defaulting to 0 if key not present seems to be not working.
Code Snippets
node_modules/react-native/ReactAndroid/src/main/java/com/facebook/react/bridge/ReadableNativeMap.java
@Override
public boolean hasKey(String name) {
if (mUseNativeAccessor) {
mJniCallCounter++;
return hasKeyNative(name);
}
return getLocalMap().containsKey(name);
}
private Object getValue(String name) {
if (hasKey(name) && !(isNull(name))) {
return Assertions.assertNotNull(getLocalMap().get(name));
}
throw new NoSuchKeyException(name);
}
private <T> T getValue(String name, Class<T> type) {
Object value = getValue(name);
checkInstance(name, value, type);
return (T) value;
}
@Override
public double getDouble(String name) {
if (mUseNativeAccessor) {
mJniCallCounter++;
return getDoubleNative(name);
}
return getValue(name, Double.class).doubleValue();
}
node_modules/react-native/ReactAndroid/src/main/java/com/facebook/react/animated/FrameBasedAnimationDriver.java
@Override
public void resetConfig(ReadableMap config) {
ReadableArray frames = config.getArray("frames");
int numberOfFrames = frames.size();
if (mFrames == null || mFrames.length != numberOfFrames) {
mFrames = new double[numberOfFrames];
}
for (int i = 0; i < numberOfFrames; i++) {
mFrames[i] = frames.getDouble(i);
}
mToValue = config.hasKey("toValue") ? config.getDouble("toValue") : 0; // hasKey() is returning true
mIterations = config.hasKey("iterations") ? config.getInt("iterations") : 1;
mCurrentLoop = 1;
mHasFinished = mIterations == 0;
mStartFrameTimeNanos = -1;
}
Reproducible Demo
Exception is very difficult to recreate
Issue Analytics
- State:
- Created 5 years ago
- Comments:6
Top GitHub Comments
Same problem @0.59 -rn v
I am closing this issue because it does not appear to have been verified on the latest release, and there has been no followup in a while.
If you found this thread after encountering the same issue in the latest release, please feel free to create a new issue with up-to-date information by clicking here.