简体   繁体   中英

pouchdb putAttachment never returns on Android (possibly due to system update)

Issue Having made no changes to our Ionic app, calls to putAttachment are now failing on some Android devices.

Info:

  • Environment: Ionic/Angular
  • Platform: Android
  • Adapter:cordova-plugin-sqlite-2
  • Server: CouchDB

Our app has been working fine for years without changes to the usage of pouchdb. But just in the last two weeks, we are having troubles saving document attachments (jpeg images).

I have been able to reproduce this issue in my development environment and isolated the issue to the putAttachment method never returning. Nor does it throw any errors. I have upgraded to the latest pouchdb and cordova-plugin-sqlite-2 adapter with no change. We suspect that since our app has not changed, that something in the Android OS has changed, but we have little insight into that. Our users have a variety of devices and we have seen failures on Android 9, 10, 11, and 12.

I have refactored the code to inline the attachment when creating the original document, but in that case the post() method does not return. In both cases, we are adding the attachment (type image/jpeg) as a Blob.

I also tried adding the attachment as just the base64 encoded image data as a string. In that case putAttachment or post does work and we seem to get a valid document and attachment in the local database, but in this case, the local document fails to sync back to CouchDB (possibly due to a 409/Conflict, but I haven't dug into that yet).

I really don't think that there is necessarily something wrong with the pouchdb code, but I am looking for insight on how to debug this. How can I identify at which point inside the putAttachment method we are locking up? And I am also putting this out there to find out if anybody else is having similar issues. This has been going on for maybe two weeks. There were various Android updates released in late July, so that's why we think that is the cause.

Not sure what in Android changed to cause the issue, but it seems to be related to this issue .

There are a few fixes mentioned in the thread, start by trying placing polyfils.js before cordova.js inside index.html ( referenced here )

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM