Android issue with syncing large attachments
See original GitHub issueI’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:
- Created 4 years ago
- Comments:9 (4 by maintainers)
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.
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.