Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

toValue error dialog because of getValue() in ReadableNativeMap.java #23268

Closed
sharwinbobde opened this issue Feb 2, 2019 · 6 comments
Closed
Labels
Bug Platform: Linux Building on Linux. Ran Commands One of our bots successfully processed a command. Resolution: Locked This issue was locked by the bot.

Comments

@sharwinbobde
Copy link

screenshot_2019-02-02-14-41-00-553_com sharwinbobde musicstreaming

Please 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(R) Core(TM) 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

@sharwinbobde
Copy link
Author

Please ignore duplicate issue #23267
keep this as the issue

@react-native-bot react-native-bot added the Platform: Linux Building on Linux. label Feb 2, 2019
@react-native-bot
Copy link
Collaborator

It looks like you are using an older version of React Native. Please update to the latest release, v0.58 and verify if the issue still exists.

The "Resolution: Old Version" label will be removed automatically once you edit your original post with the results of running react-native info on a project using the latest release.

@sharwinbobde
Copy link
Author

The problem was persisted in v0.58.0 and due to some dependency issues I chose to revert to v0.57.8

I have managed to suppress the exception

Situation

I was using TextTicker from 'react-native-text-ticker' to create marquee text.

return(<TextTicker
            style={this.props.style}
            duration={4000}
            loop
            bounce
            repeatSpacer={50}
            marqueeDelay={2000}>{this.props.children}</TextTicker>)

As I was rendering multiple components with MarqueeText, I chose to use a FlatList.

this.viewabilityConfig = {
            minimumViewTime: 100,
            waitForInteraction: false,
            viewAreaCoveragePercentThreshold: 80
        }

...

<FlatList
            data={Queue.getOrderedPlaylist()}
            keyExtractor={(item, index) => index.toString()}
            renderItem={this._renderItem}
            viewabilityConfig={this.viewabilityConfig}
            />
...

possibly the conditional rendering of the FlatList renderItem did not mix well with the Animated component in TextTicker

I have replaced TextTicker with simple Text, thus compromising on the Marquee effect.

This has solved the recurring exception being fired and everything is working normally.

@deanhet
For your consideration.

@react-native-engineer
Copy link

I fixed this issue by adding setTimeout.

@react-native-bot react-native-bot added the Ran Commands One of our bots successfully processed a command. label Feb 28, 2019
@react-native-bot
Copy link
Collaborator

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.

@miticous
Copy link

Same problem @0.59 -rn v

@facebook facebook locked as resolved and limited conversation to collaborators Feb 28, 2020
@react-native-bot react-native-bot added the Resolution: Locked This issue was locked by the bot. label Feb 28, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Bug Platform: Linux Building on Linux. Ran Commands One of our bots successfully processed a command. Resolution: Locked This issue was locked by the bot.
Projects
None yet
Development

No branches or pull requests

5 participants