Ionic very slow to go from splash screen to app start


#1

I’ve recently upgraded from Ionic 2->3. My spash screen used to hang around for around 3-5 seconds before the app opened… now that wait is around 12-15 seconds. In the ADB log I see the ubiquitous 5 second messages…

W/BatteryStatsImpl( 1720): Couldn’t get kernel wake lock stats
D/SystemWebChromeClient( 3531): file:///android_asset/www/build/main.js: Line 3303 : Angular is running in the development mode. Call enableProdMode() to enable the production mode.
I/chromium( 3531): [INFO:CONSOLE(3303)] “Angular is running in the development mode. Call enableProdMode() to enable the production mode.”, source: file:///android_asset/www/build/main.js (3303)
D/SystemWebChromeClient( 3531): file:///android_asset/www/cordova.js: Line 1223 : deviceready has not fired after 5 seconds.
I/chromium( 3531): [INFO:CONSOLE(1223)] “deviceready has not fired after 5 seconds.”, source: file:///android_asset/www/cordova.js (1223)
D/SystemWebChromeClient( 3531): file:///android_asset/www/cordova.js: Line 1216 : Channel not fired: onDOMContentLoaded
I/chromium( 3531): [INFO:CONSOLE(1216)] “Channel not fired: onDOMContentLoaded”, source: file:///android_asset/www/cordova.js (1216)
D/SystemWebChromeClient( 3531): file:///android_asset/www/build/main.js: Line 41610 : Native: deviceready did not fire within 5000ms. This can happen when plugins are in an inconsistent state. Try removing plugins from plugins/ and reinstalling them.
I/chromium( 3531): [INFO:CONSOLE(41610)] “Native: deviceready did not fire within 5000ms. This can happen when plugins are in an inconsistent state. Try removing plugins from plugins/ and reinstalling them.”, source: file:///android_asset/www/build/main.js (41610)
D/SystemWebChromeClient( 3531): file:///android_asset/www/build/main.js: Line 150993 : Ionic Native: deviceready did not fire within 5000ms. This can happen when plugins are in an inconsistent state. Try removing plugins from plugins/ and reinstalling them.
I/chromium( 3531): [INFO:CONSOLE(150993)] “Ionic Native: deviceready did not fire within 5000ms. This can happen when plugins are in an inconsistent state. Try removing plugins from plugins/ and reinstalling them.”, source: file:///android_asset/www/build/main.js (150993)
D/CordovaWebViewImpl( 3531): onPageFinished(file:///android_asset/www/index.html)

here is my package.json:
{
“name”: “schej”,
“author”: “Novel Design Ltd”,
“homepage”: “http://www.schej.co.uk/”,
“private”: true,
“scripts”: {
“ionic:build”: “ionic-app-scripts build”,
“ionic:serve”: “ionic-app-scripts serve”
},
“dependencies”: {
"@angular/common": “4.0.2”,
"@angular/compiler": “4.0.2”,
"@angular/compiler-cli": “4.0.2”,
"@angular/core": “4.0.2”,
"@angular/forms": “4.0.2”,
"@angular/http": “4.0.2”,
"@angular/platform-browser": “4.0.2”,
"@angular/platform-browser-dynamic": “4.0.2”,
"@angular/platform-server": “4.0.2”,
"@ionic-native/core": “^3.8.1”,
"@ionic-native/native-storage": “^3.4.2”,
"@ionic-native/push": “^3.5.0”,
"@ionic-native/splash-screen": “3.4.2”,
"@ionic-native/status-bar": “3.4.2”,
"@ionic/cloud-angular": “^0.11.0”,
"@ionic/storage": “2.0.1”,
“cordova-plugin-actionsheet”: “^2.3.3”,
“cordova-plugin-admobpro”: “^2.29.0”,
“cordova-plugin-camera”: “^2.4.1”,
“cordova-plugin-compat”: “^1.1.0”,
“cordova-plugin-console”: “^1.0.7”,
“cordova-plugin-contacts”: “^2.3.1”,
“cordova-plugin-device”: “^1.1.6”,
“cordova-plugin-extension”: “^1.5.1”,
“cordova-plugin-nativestorage”: “^2.2.2”,
“cordova-plugin-network-information”: “^1.3.3”,
“cordova-plugin-screen-orientation”: “^2.0.1”,
“cordova-plugin-splashscreen”: “^4.0.3”,
“cordova-plugin-statusbar”: “^2.2.3”,
“cordova-plugin-whitelist”: “^1.3.2”,
“ionic-angular”: “3.0.0”,
“ionic-plugin-keyboard”: “^2.2.1”,
“ionicons”: “3.0.0”,
“phonegap-plugin-push”: “^1.10.4”,
“rxjs”: “5.3.0”,
“sw-toolbox”: “3.6.0”,
“uk.co.workingedge.phonegap.plugin.launchnavigator”: “^3.2.2”,
“zone.js”: “^0.8.5”
},
“devDependencies”: {
"@ionic/app-scripts": “1.3.4”,
"@ionic/cli-plugin-cordova": “^1.3.0”,
"@ionic/cli-plugin-ionic-angular": “^1.3.0”,
“retyped-phonegap-tsd-ambient”: “^2.3.0-0”,
“typescript”: “~2.2.1”
},
“cordovaPlugins”: [
“cordova-plugin-whitelist”,
“cordova-plugin-statusbar”,
“cordova-plugin-console”,
“cordova-plugin-device”,
“cordova-plugin-splashscreen”,
“cordova-plugin-actionsheet”,
“cordova-plugin-nativestorage”,
“ionic-plugin-keyboard”,
“cordova-plugin-contacts”,
“cordova-plugin-screen-orientation”,
“cordova-plugin-network-information”,
“cordova-plugin-camera”,
“uk.co.workingedge.phonegap.plugin.launchnavigator”
],
“cordovaPlatforms”: [],
“description”: “Schej: Integrated scheduling for families, groups, clubs and organisations”,
“cordova”: {
“plugins”: {
“phonegap-plugin-push”: {
“SENDER_ID”: “85075801930”
},
“cordova-plugin-compat”: {},
“cordova-plugin-whitelist”: {},
“cordova-plugin-console”: {},
“cordova-plugin-device”: {},
“cordova-plugin-actionsheet”: {},
“uk.co.workingedge.phonegap.plugin.launchnavigator”: {},
“cordova-plugin-nativestorage”: {},
“cordova-plugin-splashscreen”: {},
“cordova-plugin-statusbar”: {},
“ionic-plugin-keyboard”: {},
“cordova-plugin-contacts”: {},
“cordova-plugin-camera”: {},
“cordova-plugin-network-information”: {},
“cordova-plugin-extension”: {},
“cordova-plugin-admobpro”: {}
}
},
“config”: {
“ionic_generate_source_map”: “false”
}
}

I’ve removed and re-added all plugins since the upgrade to ionic3 by the way… that made no difference, and I’ve added the 'ionic_generate_source_map - false option to both limit the size of the apk but also hope to speed things up. It really seems to be a time-out issue somewhere.

Any help or pointers would be gratefully received.

Thanks
Chris


#2

If you build your app using the --prod flag, you will notice a difference :wink:


#3

Hi LoLStats
I thought I was… but on analysis… I was using ‘cordova build android --prod --release’ since with ionic at the front it was throwing an error.

so cordova build… is not the same as ionic cordova build…

Reading a number of post it seems that @ionic/cloud-angular was the culprit. I upgraded to 0.12.0, then the ionic build… script worked and properly minified things, and the app now starts properly within a couple of seconds of the splash screen starting.

Thanks for the pointer.

Thanks
Chris


#4

ionic cordova is the Ionic CLI wrapping the cordova CLI but doing additional stuff - like building the app with --prod argument. With some other commands it doesn’t matter if you keep the ionic in front or not, but here it is important as the app doesn’t get built if running with cordova directly.


#5

I was able to solve my problem with slow loading. I remember when I first created an app in ionic last month, the app boots for around 3 seconds. When I installed different plugins and added some modules and components, my app boots for 14 seconds! I tried to lazy load all my modules however, when I am trying to navpush on the first run, the particular page loads very slow but it became faster when doing the navpush at the second time. So what I did is, lazy load only the homepage which is being my rootpage. The other modules are not lazy loaded. So from 14 seconds, it became 7 seconds on ionic cordova build android --release. When I tried ionic cordova build android --prod --release, the app boots in almost 3 seconds. From 14 seconds to 3 seconds I think I should be happy. :wink: I think we do not need to remove and re-add plugins because I did not do that and still I was able to manage my problem.