[SOLVED] Sporadic launch problem on iOS?

Sometimes (infrequently, but enough that I notice) my angular code just doesn’t seem to run, and I’m wondering if any others are seeing this. I put comments in the .config and .run blocks of my app, which should get run first. When the app successfully loads, the Xcode log looks like this:

2015-01-28 12:44:49.436 MyApp[1334:455832] DiskCookieStorage changing policy from 2 to 0, cookie file: file:///private/var/mobile/Containers/Data/Application/AE96FA8E-0C1D-4358-913C-74B9D9694F87/Library/Cookies/Cookies.binarycookies
2015-01-28 12:44:49.586 MyApp[1334:455832] Apache Cordova native platform version 3.7.0 is starting.
2015-01-28 12:44:49.588 MyApp[1334:455832] Multi-tasking -> Device: YES, App: YES
2015-01-28 12:44:49.592 MyApp[1334:455832] Unlimited access to network resources
2015-01-28 12:44:49.597 MyApp[1334:455832] 

Started backup to iCloud! Please be careful.
Your application might be rejected by Apple if you store too much data.
For more information please read "iOS Data Storage Guidelines" at:
https://developer.apple.com/icloud/documentation/data-storage/
To disable web storage backup to iCloud, set the BackupWebStorage preference to "local" in the Cordova config.xml file

2015-01-28 12:44:49.674 MyApp[1334:455832] [CDVTimer][keyboard] 0.193000ms
2015-01-28 12:44:49.679 MyApp[1334:455832] [CDVTimer][socialsharing] 4.478037ms
2015-01-28 12:44:49.679 MyApp[1334:455832] Init FacebookConnect Session
2015-01-28 12:44:49.682 MyApp[1334:455832] [CDVTimer][facebookconnectplugin] 2.996981ms
2015-01-28 12:44:49.706 MyApp[1334:455832] [CDVTimer][file] 23.240030ms
2015-01-28 12:44:49.757 MyApp[1334:455832] [CDVTimer][splashscreen] 50.797999ms
2015-01-28 12:44:49.768 MyApp[1334:455832] [CDVTimer][statusbar] 10.823011ms
2015-01-28 12:44:49.768 MyApp[1334:455832] [CDVTimer][TotalPluginStartup] 94.417036ms
2015-01-28 12:44:49.955 MyApp[1334:455832] Resetting plugins due to page load.
2015-01-28 12:44:50.075 MyApp[1334:455832] Finished load of: file:///private/var/mobile/Containers/Bundle/Application/5B5AC4D4-E5FB-46D5-AFD1-A58EFDCC7B76/MyApp.app/www/index.html
2015-01-28 12:44:51.104 MyApp[1334:455832] CONFIG 1
2015-01-28 12:44:51.105 MyApp[1334:455832] CONFIG 2
2015-01-28 12:44:51.105 MyApp[1334:455832] CONFIG 3
2015-01-28 12:44:51.105 MyApp[1334:455832] CONFIG 4
2015-01-28 12:44:51.105 MyApp[1334:455832] CONFIG 5
2015-01-28 12:44:51.106 MyApp[1334:455832] ***** PRODUCTION

Where all the “CONFIG” statements are from my .config block, and the “***** PRODUCTION” statement is from my .run block. Sometimes when I start the app, it gets stuck on the splash screen with the spinning indicator in the center, and the Xcode log stops after the load of index.html

2015-01-28 12:36:25.488 MyApp[1327:454778] DiskCookieStorage changing policy from 2 to 0, cookie file: file:///private/var/mobile/Containers/Data/Application/4131A4B9-1EBC-405A-80FA-D8ED32CEE86B/Library/Cookies/Cookies.binarycookies
2015-01-28 12:36:25.640 MyApp[1327:454778] Apache Cordova native platform version 3.7.0 is starting.
2015-01-28 12:36:25.642 MyApp[1327:454778] Multi-tasking -> Device: YES, App: YES
2015-01-28 12:36:25.647 MyApp[1327:454778] Unlimited access to network resources
2015-01-28 12:36:25.652 MyApp[1327:454778] 

Started backup to iCloud! Please be careful.
Your application might be rejected by Apple if you store too much data.
For more information please read "iOS Data Storage Guidelines" at:
https://developer.apple.com/icloud/documentation/data-storage/
To disable web storage backup to iCloud, set the BackupWebStorage preference to "local" in the Cordova config.xml file

2015-01-28 12:36:25.741 MyApp[1327:454778] [CDVTimer][keyboard] 0.194013ms
2015-01-28 12:36:25.745 MyApp[1327:454778] [CDVTimer][socialsharing] 4.108012ms
2015-01-28 12:36:25.746 MyApp[1327:454778] Init FacebookConnect Session
2015-01-28 12:36:25.749 MyApp[1327:454778] [CDVTimer][facebookconnectplugin] 3.369033ms
2015-01-28 12:36:25.776 MyApp[1327:454778] [CDVTimer][file] 26.789010ms
2015-01-28 12:36:25.825 MyApp[1327:454778] [CDVTimer][splashscreen] 49.018979ms
2015-01-28 12:36:25.836 MyApp[1327:454778] [CDVTimer][statusbar] 10.357976ms
2015-01-28 12:36:25.836 MyApp[1327:454778] [CDVTimer][TotalPluginStartup] 95.737040ms
2015-01-28 12:36:26.107 MyApp[1327:454778] Resetting plugins due to page load.
2015-01-28 12:36:26.171 MyApp[1327:454778] Finished load of: file:///private/var/mobile/Containers/Bundle/Application/45F40F65-EAB2-43D0-BD91-4B634C3B6E06/MyApp.app/www/index.html

So it appears that the angular startup code isn’t being called at all. Debugging with Safari shows that all the JS and HTML files have been loaded properly. Has anyone else seen this kind of behavior?

I can replicate this on an iPad Mini 2 w/retina, running iOS 8.1.2, and also on the iOS simulator (iPhone 5, iOS 8.1 and iOS 7.0).

It only ever seems to happen when I delete the app from the device and do a new install/run from Xcode. I can’t get it to happen on subsequent runs - everything works fine after the first failed load.

After some more testing, I realized this was related to my use of Cordova App Loader, and not any core part of any of the frameworks I’m using.

1 Like