Skip to content

[Android] multiGet() hangs, app not responsive #634

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

Closed
3 tasks
ecexplorer opened this issue Jul 15, 2021 · 5 comments
Closed
3 tasks

[Android] multiGet() hangs, app not responsive #634

ecexplorer opened this issue Jul 15, 2021 · 5 comments
Labels
bug Something isn't working platform: Android This is Android specific

Comments

@ecexplorer
Copy link

Current behavior

In our app, I call AsyncStorage.multiGet() on a key array with just two keys. Admittedly one of the keys is tied to a JSON string that when formatted, is 17000+ lines long. This is still under the overall 6MB limit.
When the call is made, it just hangs. No error is thrown, and if I use a callback, it is never called. The same data in iOS has no problem being fetched.
I can also tell that the data is there. That 17,000+ number comes from pulling the data directly on Android Studio using the database inspector. The data is being stored correctly.
If I request the same data using getItem(), then the request works without issue and I get the expected value back.
(See comments for a workaround)

Expected behavior

Calls to multiGet() don't hang, return the data expected.

Repro steps

  • Set two items in AsyncStorage, ensure one of those is LARGE.
  • Attempt to get both at once with a multiGet() request.
  • If the request hangs, this has been repeated.

Similar to source, if I make a Promise.all(keys.map(async (key) => [key, await AsyncStorage.getItem(key)]), I see the same hang. Android doesn't seem to like the multiple accesses to AsyncStorage/DB at once.

Environment

  • Platforms tested:
    • [ X] Android
    • iOS
    • macOS
    • Windows
  • AsyncStorage version: 1.15.5
  • Environment:
    System:
    OS: macOS 11.4
    CPU: (16) x64 Intel(R) Core(TM) i9-9880H CPU @ 2.30GHz
    Memory: 131.27 MB / 32.00 GB
    Shell: 5.8 - /bin/zsh
    Binaries:
    Node: 12.16.2 - ~/.nvm/versions/node/v12.16.2/bin/node
    Yarn: Not Found
    npm: 6.14.4 - ~/.nvm/versions/node/v12.16.2/bin/npm
    Watchman: 2021.06.07.00 - /usr/local/bin/watchman
    Managers:
    CocoaPods: 1.10.1 - /usr/local/bin/pod
    SDKs:
    iOS SDK:
    Platforms: iOS 14.5, DriverKit 20.4, macOS 11.3, tvOS 14.5, watchOS 7.4
    Android SDK: Not Found
    IDEs:
    Android Studio: 4.2 AI-202.7660.26.42.7486908
    Xcode: 12.5.1/12E507 - /usr/bin/xcodebuild
    Languages:
    Java: Not Found
    Python: 2.7.16 - /usr/bin/python
    npmPackages:
    @react-native-community/cli: Not Found
    react: 17.0.2 => 17.0.2
    react-native: 0.63.4 => 0.63.4
    react-native-macos: Not Found
    npmGlobalPackages:
    react-native: Not Found
  • Logs/Errors that may be relevant: I don't get any logs, errors, etc. I just hangs.
@krizzu
Copy link
Member

krizzu commented Jul 19, 2021

Hey @ecexplorer

Thanks for providing all these details. Doing small repro, I confirm that the getItem and multiGet are treated differently when it comes to handling errors. getItem should throw error, while multiGet will swallow it.

I'm marking this as bug and I'm going to work on this one. Thanks!

@krizzu krizzu added bug Something isn't working platform: Android This is Android specific labels Jul 19, 2021
@github-actions
Copy link

This issue has been marked as stale due to inactivity. Please respond or otherwise resolve the issue within 7 days or it will be closed.

@andyecker
Copy link

#694 (comment)

@krizzu
Copy link
Member

krizzu commented Nov 19, 2021

This should be fixed in the latest release (v1.15.11)

@krizzu krizzu closed this as completed Nov 19, 2021
@MichDreby
Copy link

Hello guys, as for v.1.17.6 of the package issue persists.
inlineRequires: true in the metro config causes hanging on AsyncStorage.getItem method.
Changing inlineRequires to false is not an option since this is the part of official set up of react-native and for 0.68 version is must have option.
@krizzu

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working platform: Android This is Android specific
Projects
None yet
Development

No branches or pull requests

4 participants