Android wipes app data on some devices
See original GitHub issueCurrent behavior
Currently async storage works great on all iOS devices and most of Android devices. The issue has been reporting by android users of my app since I released the app on android about 6 months ago. The users report that when they make changes in the app, and reopen the app again all their saved setting & data would reset and clear. (I use async storage as the main storage for the app) This is really frustrating and I can’t detect exactly what causes it. I am noticing most users report this from Huawei phones some from Samsung phones. I have a Vivo Y15 phone and I seem to get this issue once a month the app would clear the storage, though theres alot of free space on the phone. How ever on another One plus phone I tested on, it never happens. I would say it happen in about 20% of Android phones. How can I debug this and know what causes it? I produce apps in AAB format could this be an issue? and I am not enabling hermes.
Expected behavior
The app won’t wipe the data on android with no reason.
Repro steps
I am testing more and was able to reproduce it. The issue happens when data stored increase to around up to 4 ~ 6 mb. After that I close the app and open it again, and everything is wiped. I use asyncStorage with redux-persist and some posts and data that the user loads get stored with asyncStorage though this delete all data not only on redux but also on data that I used setItem with. again this issue does not happen with most Android phones, some phones even with lots of ram up to 6gb and free space it still happens, not sure why!
Log error:
Logged error in android studio when I launch the app and a wipe happens:
E/SQLiteQuery: exception: Row too big to fit into CursorWindow requiredPos=0, totalRows=1; query: SELECT key, value FROM catalystLocalStorage WHERE key IN (?)
I tried to increase the storage, adding this to my android/gradle.properties:
AsyncStorage_db_size_in_MB=50
but still the wipe occurs on reopen when storage is between 4 ~ 6 mb
Environment
- Platforms tested:
- Android
- iOS
- macOS
- Windows
- AsyncStorage version: 1.13.3
- Environment: System: OS: macOS 11.1 CPU: (4) x64 Intel® Core™ i5-7400 CPU @ 3.00GHz Memory: 961.64 MB / 8.00 GB Shell: 3.2.57 - /bin/bash Binaries: Node: 15.2.0 - /usr/local/bin/node Yarn: 1.22.0 - ~/.yarn/bin/yarn npm: 7.0.10 - /usr/local/bin/npm Watchman: 4.9.0 - /usr/local/bin/watchman Managers: CocoaPods: 1.9.3 - /usr/local/bin/pod SDKs: iOS SDK: Platforms: iOS 14.4, DriverKit 20.2, macOS 11.1, tvOS 14.3, watchOS 7.2 Android SDK: Not Found IDEs: Android Studio: 4.1 AI-201.8743.12.41.7042882 Xcode: 12.4/12D4e - /usr/bin/xcodebuild Languages: Java: 11.0.2 - /usr/bin/javac Python: 2.7.16 - /usr/bin/python npmPackages: @react-native-community/cli: Not Found react: 16.13.1 => 16.13.1 react-native: ^0.63.4 => 0.63.4 react-native-macos: Not Found npmGlobalPackages: react-native: Not Found
Issue Analytics
- State:
- Created 3 years ago
- Reactions:10
- Comments:13 (2 by maintainers)
Top GitHub Comments
I was able to solve this issue modifying the onCreate method in MainApplication.java for android Just add this at the end of the method
try { Field field = CursorWindow.class.getDeclaredField(“sCursorWindowSize”); field.setAccessible(true); field.set(null, 100 * 1024 * 1024); //100MB } catch (Exception e) { if (BuildConfig.DEBUG) { e.printStackTrace(); } }
Thanks!
It appears I was chasing the wrong repo/issues anyway. I didn’t realize that redux-persist just stores the entire store in one json file. I thought it acted like a db backed storage engine and set/get a group of items at a time and merged them at runtime.
That was of course wrong - thanks for the help. We stopped the bleeding for now and investigating a proper way to persist a redux store with large amounts of data which may just be a filesystem based driver.
My references for other googlers: https://github.com/rt2zz/redux-persist/issues/199 https://github.com/rt2zz/redux-persist/issues/284