question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Android wipes app data on some devices

See original GitHub issue

Current 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:closed
  • Created 3 years ago
  • Reactions:10
  • Comments:13 (2 by maintainers)

github_iconTop GitHub Comments

16reactions
imarsigliacommented, Feb 18, 2021

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(); } }

2reactions
iBotPeachescommented, Mar 17, 2021

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

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to clear App Data or Cache on Android devices in bulk?
Go to Actions > Clear App Data. Select the required application(s) and click on Next. Specify the number of selected applications and click...
Read more >
Top 6 Android Data Erase Apps to Protect Privacy - Dr.Fone
Here are some of the best one so read on to find THE one Android data wipe app that will suit your every...
Read more >
How to Wipe the Cache Partition and Clear Data on Android
How to Wipe the Cache Partition and Clear Data on Android ; Open Settings. Navigate to Apps. Tap on the app you want...
Read more >
Wipe corporate data from a device - Cloud Identity Help
Wipe a device—If it's a company-owned or personal device that's lost or stolen. This option removes all work data and apps from the...
Read more >
How to Clear Cache Data on Your Android - Lifewire
Pre-Oreo: Tap Settings > Storage > Devices (or similar) > Cached data > Clear cached data > OK. This article explains how to...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found