Reputation: 21
Cordova app working on Android, but thread seems to freeze on ios. Version 6.1 of Cordova using iOS plugin version 4.1.1. App works fine on Android emulator and device.
When running on device from XCode app seems to load. Home screen appears fine but I do not see any console.log statements that should appear after the deviceready event UNTIL I hit the home button on the phone. Then all the console log statements for the first few functions, connecting to SQLite DB, etc appear at once.
Plugins in use:
I can then tap on the launcher icon again and interact with the app but nothing will appear in the console until I hit the home button again. I cannot queue more than one DB transaction or one call to my barcode scanner before hitting the home button to let it run.
The console.log messages called after deviceready do NOT appear, however the code that makes the navigation in the app does run because the navigation through the app works. It seems that it is just the plugins are being held up.
Sample code:
var app ={
init: function(){
document.addEventListener("deviceready", app.onDeviceReady);
},
onDeviceReady: function(ev){
console.log("device ready"); //this does NOT appear in the console
//add some click listeners to buttons for navigation
//and this code DOES run
console.log("another test message"); //does NOT appear
app.setUpDB();
},
setUpDB: function(){
console.log("setting up DB"); //this does NOT appear in console
//code to open DB and create tables
//this code will not run until after the home button clicked
},
... more functions ...
}
app.init();
console.log("this won't appear before home button click");
Message in console BEFORE clicking home button
2016-04-08 08:35:42.900 MeetCute-MadLib[387:141553] Apache Cordova native platform version 4.1.1 is starting.
2016-04-08 08:35:42.903 MeetCute-MadLib[387:141553] Multi-tasking -> Device: YES, App: YES
2016-04-08 08:35:43.000 MeetCute-MadLib[387:141553] Using UIWebView
2016-04-08 08:35:43.005 MeetCute-MadLib[387:141553] [CDVTimer][handleopenurl] 0.510991ms
2016-04-08 08:35:43.012 MeetCute-MadLib[387:141553] [CDVTimer][intentandnavigationfilter] 5.966008ms
2016-04-08 08:35:43.012 MeetCute-MadLib[387:141553] [CDVTimer][gesturehandler] 0.219047ms
2016-04-08 08:35:43.012 MeetCute-MadLib[387:141553] [CDVTimer][TotalPluginStartup] 8.069038ms
2016-04-08 08:35:43.451 MeetCute-MadLib[387:141553] Resetting plugins due to page load.
2016-04-08 08:35:43.807 MeetCute-MadLib[387:141553] Finished load of: file:///var/containers/Bundle/Application/2DC8233D-0BA4-4BE9-8689-53D492193E64/MeetCute-MadLib.app/www/index.html
Then... as soon as clicking the home button the rest of this appears
2016-04-08 08:48:58.538 MeetCute-MadLib[391:143286] Initializing SQLitePlugin
2016-04-08 08:48:58.538 MeetCute-MadLib[391:143286] Detected docs path: /var/mobile/Containers/Data/Application/10EE751F-CE70-449E-800D-817371C9813E/Documents
2016-04-08 08:48:58.539 MeetCute-MadLib[391:143286] Detected Library path: /var/mobile/Containers/Data/Application/10EE751F-CE70-449E-800D-817371C9813E/Library
2016-04-08 08:48:58.539 MeetCute-MadLib[391:143286] no cloud sync at path: /var/mobile/Containers/Data/Application/10EE751F-CE70-449E-800D-817371C9813E/Library/LocalDatabase
2016-04-08 08:48:58.540 MeetCute-MadLib[391:143286] device is ready
2016-04-08 08:48:58.540 MeetCute-MadLib[391:143286] tagname a
2016-04-08 08:48:58.540 MeetCute-MadLib[391:143286] test the sqlitePlugin
2016-04-08 08:48:58.540 MeetCute-MadLib[391:143286] set up DB
2016-04-08 08:48:58.540 MeetCute-MadLib[391:143345] open full db path: /var/mobile/Containers/Data/Application/10EE751F-CE70-449E-800D-817371C9813E/Library/LocalDatabase/DBmeetcute
2016-04-08 08:48:58.584 MeetCute-MadLib[391:143286] THREAD WARNING: ['Console'] took '43.607910' ms. Plugin should use a background thread.
2016-04-08 08:48:58.589 MeetCute-MadLib[391:143286] about to openDatabase
2016-04-08 08:48:58.589 MeetCute-MadLib[391:143286] OPEN database: DBmeetcute
2016-04-08 08:48:58.589 MeetCute-MadLib[391:143286] database already open: DBmeetcute
2016-04-08 08:48:58.590 MeetCute-MadLib[391:143286] create the tables IF NOT EXISTS
2016-04-08 08:48:58.590 MeetCute-MadLib[391:143286] new transaction is waiting for open operation
2016-04-08 08:48:58.590 MeetCute-MadLib[391:143286] fetching profile
2016-04-08 08:48:58.590 MeetCute-MadLib[391:143286] new transaction is waiting for open operation
2016-04-08 08:48:58.596 MeetCute-MadLib[391:143345] Good news: SQLite is thread safe!
2016-04-08 08:48:59.237 MeetCute-MadLib[391:143286] DB opened: DBmeetcute
Upvotes: 2
Views: 731
Reputation: 23273
I was able to get a copy of @prof3ssorSt3v3 index.html. The CSP was incorrect as it was missing gap:
which allows the JS and native side to communicate. So if you are running into something like this check your CSP tag in index.html.
<meta http-equiv="Content-Security-Policy"
content="default-src 'self' data: gap: https://ssl.gstatic.com
'unsafe-eval'; style-src 'self' 'unsafe-inline'; media-src *">
Upvotes: 2