storesafe/cordova-sqlite-storage

No success or error callback - Testing on Samsung S4 & S6

WHarris22 opened this issue · 4 comments

I have an Ionic app which uses this plugin to store data in a single table and I get an issue where I execute a query on the table and I receive no success or error callback instead it just hangs. It has happened on a Samsung S4 and S6 but I dont have a IOS test device so cannot confirm if its the same for IOS as well.

Closing the app and re-opening it opens the DB again and things start working again.

I have no idea what chain of events cause this (it just seems random) so replicating it is hard but my app consists of inserting a single record into said table, selecting ALL from table, updating a single record, and deleting a single record.

Also, it doesn't happen very often so 90% of the time the queries I have written will work as expected.

Just to note:

  • I use the ng-cordova wrapper class $cordovaSQLite.execute() so that queries get returned as promises.
  • I'm not working with much data either. It can happen with just 1-5 records in the table.

If you need more info or you want to see code let me know.

Update

I think I've found the cause for this. I have a list in one of my views and for each item there is an option to open it in the native Google maps app on the device. When I click this and then return to the app the database stops working. By not working I mean none of my queries return a success or error callback.

My code that opens the native map is:

 function OpenMap(sLat, sLng, eLat, eLng) {
        var googleUrl = 'http://maps.google.com/maps?saddr=' + sLat + ',' + sLng + '&daddr=' + eLat + ',' + eLng;
        window.open(encodeURI(googleUrl), '_blank');
}

I have never seen an issue like this before and find it really strange. I wonder if the issue is specific to this plugin or if it may affect other plugins such as cordova-plugin-file. You may want to try closing the database before such a window "navigation" event and reopening it when you need to do the database operation.

It is really strange, would be good to know if anybody else has ever experienced this because I don't think any of my code does anything out of the ordinary.

I do make use of the cordova-plugin-file so I will knock up a test method and see what happens. I'm going to be out of office until the new year so won't be able to report back until then.

I just realised I've experienced something like this before when using the Google Maps JavaScript API in an Ionic project and it turned out I didn't whitelist the URL in the config.xml.

i've just added <allow-intent href="*" /> to my config.xml as stated in the cordova-plugin-whitelist docs for when you use window.open() and I think that has now fixed it, shall I delete this issue now?

I documented this in README.md. I also published brodybits / Cordova-quick-start-checklist and brodybits / Cordova-troubleshooting-guide with tips to check the intent in the whitelist. Closing for now, please report if you find any related issues thanks!