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 issue with syncing large attachments

See original GitHub issue

I’m experiencing an Android issue in RN 60.5 that’s not present in the demo RN 59.1. https://github.com/craftzdog/pouchdb-react-native-demo

iOS does not have this issue.

When syncing an attachment (image) of size from 1mb to 10mb it works fine in the demo and successfully syncs. However, when running the identical code using RN 60.5 and any file over 1.6mb, I get an error:

Possible Unhandled Promise Rejection (id: 0):
TypeError: Cannot read property 'length' of null
TypeError: Cannot read property 'length' of null
    at parseHexString
    at SQLTask.sqlCallback
    at blob
    at onSuccess
    at tryCallOne
    at blob
    at blob
    at _callTimer
    at _callImmediatesPass
    at Object.callImmediates

I’m pretty sure this issue comes from something failing within the WebSQL transaction process: https://github.com/nolanlawson/node-websql/blob/ab6d7e06e00909046b98250da71248802935a284/lib/websql/WebSQLTransaction.js#L54

I have the same setup in the demo app and the RN 60.5 test app with the same code MainApplication.java change:

try {
  Field field = CursorWindow.class.getDeclaredField("sCursorWindowSize");
  field.setAccessible(true);
  field.set(null, 100 * 1024 * 1024); //the 100MB is the new size
} catch (Exception e) {
  if (e != null) {
    e.printStackTrace();
  }
}

There also seems to be an identical issue listed here, but this from 2016: https://github.com/pouchdb/pouchdb/issues/5500#issue-167407541

I have searched for differences between RN 59.1 and 60.5, but can’t find any reason why there would be a difference.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:9 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
Dhurzocommented, Nov 26, 2019

Hello,

I was experiencing this issue with RN 61.5 & react-native-sqlite-2: 3.0.1. I solved the problem downgrading react-native-sqlite-2 to 2.0.4 and increasing the cursor as is described in the README:

try { Field field = CursorWindow.class.getDeclaredField("sCursorWindowSize"); field.setAccessible(true); field.set(null, 100 * 1024 * 1024); //the 100MB is the new size } catch (Exception e) { if (DEBUG_MODE) { e.printStackTrace(); } }

Hope this helps.

0reactions
zefranlopescommented, Jul 4, 2021

Close the cursors opened previously, the code above seems valid, but investigating further I noticed that some cursors still needed to close, I just closed them and the problem was solved.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Why Did Email Stop Syncing on Android? 8 Ways to Fix It
If your email won't sync on Android, we show you several methods to get your emails back on your device.
Read more >
Android Sync fails in attachments - Zimbra Forums
What happens is that when you try to sync in android it fails when the message you are getting has some attachments. After...
Read more >
Collaborating on Documents with Oracle Content Management
If you're syncing a file and you lose your connection to Oracle Content or to the network. Try re-syncing the individual file or...
Read more >
Sync big amount of data on mobile - Android - ownCloud Central
Hi, this is just a question. Time ago I installed owncloud app to sync 17G of data on and iPad. I found out...
Read more >
Syncing very large folders on Android - Syncthing Forum
Problem is that i can not sync those files to my laptop (let alone android device), as there is not enough space on...
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