-
Notifications
You must be signed in to change notification settings - Fork 28
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
Synching with PouchDB with attachments silently fails on Android #38
Comments
Thanks for the reproducible test case! I will take a look at this when I get a chance. In the meantime I can tell you this: I do not recommend SQLite Plugin 2 for Android for 99% of use cases, and I especially don't recommend it for large binary attachments. In WebSQL and in Cordova plugins, binary data needs to be serialized when sent back and forth between the JavaScript context and the native code, which is enormously inefficient and may lead to crashes if you try to do it all at once. Whereas in IndexedDB on Android, there is native support for Blobs, and so those Blobs can be directly saved to IndexedDB without ever reading anything into memory in JavaScript. (Try this with a Another issue: since your documents are huge, you may want to use a smaller batch_size when replicating. PouchDB will try to insert all records in a batch into IndexedDB/WebSQL/SQLite at once, which can exceed your memory limitations if you're not careful. Another option is to break up your attachments into smaller attachments and spread them across documents.
No, not unless you break up your attachments into smaller pieces and/or sync with a very low batch size. And unfortunately you probably can't use IndexedDB for that much data, because you'll hit the quota limit very quickly, and the Persistent Storage API has not officially shipped yet in any browser. If I were you, I would probably not use PouchDB, because I would want more fine-grained control over the attachment sizes and how I sync them. I might store md5 sums in PouchDB, but I would not store attachments. Instead, I would sync those separately using AJAX/fetch and then insert the data directly into SQLite Plugin 2, into as small chunks as possible. |
I have a similar problem! We are in the process of trying the following approach:
approach 1: approach 2: There are definitely many challenges, e.g.:
|
I had the same problem, PouchDB sync fails silently, when documents are loaded with attachments. I read the code, and I found out, the problem is with the readAsBinaryString function, more specifically with the FileReader.onloadend function, which wasn't triggered. The solution for this problem was a little bit more obvious and described here: https://stackoverflow.com/questions/36283445/filereader-not-firing-onloadend-in-ionic-2/43703344 Make sure that |
Closing old issues, please reopen as necessary. Seems this is an issue with ordering of dependencies in user code |
Could be related to #46 |
Overview
Environment
Ionic/Cordova/Angular hybrid app, using PouchDB & cordova-plugin-sqlite-2, for Android for phones and tablets
Details
Alternative
Risk
Reproducing the Problem
issue-38.zip
Test App Source Code:
The text was updated successfully, but these errors were encountered: