Safari iOS 7 : persistent view query() silently fails when several attachments of about 300Ko

57 views
Skip to first unread message

Adrien Ménoret

unread,
Oct 16, 2015, 10:08:51 AM10/16/15
to PouchDB
Hello Nolan,

First of all thanks for PouchDB, the long polling sync gives the app a near realtime behavior, even for offline pictures, very cool !

Speaking attachments, we felt on a bug on Safari iOS 7, that only happens when more than 10 attachments of about 300ko are in the local Pouch Database.

When querying a local persistent view (defined in local _design doc) with or without attachment=true, with a limit=25, safari silently fails, never executing then() nor catch() of the promise.

After that, WebSQL seems to be corrupted on all safari pages, even after reload. All promises (event simple get()) are silently failing.

To get PouchDB working again, we have to clear all safari data.

We did not have this issue when no attachments was in the db.

Is this a known bug of safari iOS7 WebSQL ? Large base64 values corrupts WebSQL entirely until clearing all safari data ?

Thanks for your help,
Adrien

Nolan Lawson

unread,
Oct 16, 2015, 2:44:09 PM10/16/15
to PouchDB
Hi Adrien,

Hm, this is not a known bug that I'm aware of. When you initialized PouchDB, did you do:

    var db = new PouchDB('mydb', {size: 50}); // 50MB is the max that iOS will allow

On iOS, you have to be very cognizant of browser storage limits and ask for your data upfront (http://pouchdb.com/faq.html#data_limits). If this doesn't describe your bug, then I recommend creating a sample page and then filing a bug on Webkit: https://bugs.webkit.org/

Cheers,
Nolan

Adrien Ménoret

unread,
Oct 18, 2015, 12:15:42 PM10/18/15
to PouchDB
Hi Nolan,

Thanks for your reply.

This was indeed an iOS storage issue, but unrelated with attachments.

In fact, we were already asking for {size:50} when creating the db, and it turned out to be incompatible with persistent views.

We followed your advice to run persistent view indexing at startup, and discovered that indexing was silently failing.

I guess it was because with {size:50} main websql db used by PouchDB was eating all available storage, and when PouchDB tries to create persistent view indexes, iOS refuses to open websql db needed to store the new index, and index building silently fails.

Once we changed our instantiation with {size: 20}, everything worked fine, even if iOS prompts twice for storage allocation (25mb and then 50mb).

Maybe you could raise an error when PouchDB fails to open a dependent websql db ?

Cheers,
Adrien

Nolan Lawson

unread,
Oct 20, 2015, 11:08:55 AM10/20/15
to PouchDB
Ah yes, that makes sense. The issue is indeed that two separate WebSQL databases are opened, and each one takes in a different size.

I'll open an issue: https://github.com/pouchdb/pouchdb/issues/4493

Adrien Ménoret

unread,
Oct 20, 2015, 11:43:21 AM10/20/15
to PouchDB
Maybe you could put views indexes in the same websql db, but I guess you choosed to put views on separate websql db for a good reason ?
Reply all
Reply to author
Forward
0 new messages