My project the ionic 2 ru.0 … and my project open android 12-25 sec it takes a lot of time. when my project was in ionic 2 beta.11 download was asynch and project load faster
My project doesn’t load after minutes. It is a disaster. I have tried it for a couple of days. Change config.xml, add and remove SplashScreen. No help.
@mhartington You should seriously consider updating publishing guide (https://ionicframework.com/docs/guide/publishing.html) that tells to use
cordova to build application.
All the time, I thought that
ionic command is in most cases just an alias to
cordova with some addons. Yesterday, I’ve build a clean starter app with:
$ sudo npm install -g ionic@latest (...) $ ionic -v 2.1.1 $ ionic start vanilla-mobile --v2
and then generated APK with
$ cordova platform add android && cordova build --release android
(according to https://ionicframework.com/docs/guide/publishing.html)
signed it with a key, uploaded to phone and this is what I saw:
I was about to write a post about this here. For beta, I’d agree that 5-7 seconds of load time is acceptable, but for RC it’s not.
After reading this thread, I took the same project and built it with
ionic instead of
cordova. Signed the APK, uploaded to my phone and… Well, see the difference youself:
I’ve also observed that the APK size is different. With
cordova it was 3,6MB with
ionic it’s 2,9MB.
Please don’t tell me that I’m wrong and
ionic build is an alias to
cordova build and the boot speed up time is just a whim of my phone
3secs for a starter app with just three pages isn’t spectacular, but still 2 times faster than the same built with
This is on Huawei P8 Lite (Hisilicon Kirin 620 CPU 8 X 1.2GHz, 2GB RAM, Android 5.0.1).
We found an interesting phenomenon.
If we install our app by “ionic run android”, our note4 took 7s to load, but if we use “ionic build android --release” instead, our note4 took 13s to load!! rc1 is used.
The release version is slower than the debug version. It is mind blowing.
Not a line of code has been changed.
I’m curious, without “–release”, still 13s?
Aka only “ionic build android”
It is opposite. Without --release flag, it is 7s, but with --release flag, it is 13s. That’s why it is mind blowing to us. It is 5s in Iphone6 though. That is why we only release in iOS, but that defeats the purpose of using ionic, right? And that is why we are extremely looking forward to use angular router + lazy loading. We suspected the links, of different pages, in the dashboard page force the app to load all module at startup and cause the poor boot up time problem.
I updated to RC0 build and increased speed 2x faster for android (ios not tested).
from 9 seconds to 4-5 seconds. drastically improved.
Thx for the feedback. I would be happy to hear something from the Ionic team about that differences of “–release”…kind of really surprising as you say. Also the difference between iOs and Android is surprising.
Hey @grapemix I was really curious and I just tested my login time on my phone (Nexus 5X) for a version created with “ionic build android --release”. Actually it took the same time to boot up as without “–release”. Don’t know if that could help but thought you might be interested by that information.
So this week I did refactoring (again) in my app and today I decided to save more user data on the device (localforage) to avoid to perform a login on each use of my app but to only perform a login when the token gonna be expired (I set a week). The start gonna be slower once a week because of that but at least not each time.
Results of my boot time are now:
Xcode debug simulator iPhone 6s / iOS 9.1 / UIWebView : 2 seconds
Real device Nexus 5X with XWalk: 6 seconds
Real device iPhones 4s / iOS 9.1 / UIWebView: 8 seconds
Still too slow, but what I learned there
The problem isn’t my login and navigation code (2 seconds in debug, that’s fine for me)
I could already notice a difference using Xcode and simulator and Xcode with a real device (of course 6s is way faster than 4s, but still my real android phone is slow too). I compared both logs and found these warning which are fired using a real phone and are not fired using simulator:
THREAD WARNING: [‘Device’] took ‘28.238037’ ms. Plugin should use a background thread.
THREAD WARNING: [‘StatusBar’] took ‘17.428223’ ms. Plugin should use a background thread.
deviceready has not fired after 5 seconds.
DEVICE READY FIRED AFTER 3954 ms
THREAD WARNING: [‘StatusBar’] took ‘99.757080’ ms. Plugin should use a background thread.
Where using simulator I’ve got no warnings and following results
DEVICE READY FIRED AFTER 440 ms
Somewhere in this massive thread we already discuss that the problem should be the plugins and that kind of give weight for that idea, I guess. But anyone has had the the same behavior and may have found a solution or workaround? or any ideas?
Thx in advance for your feedback
Especially after switching to rc1 (from beta.11) and ngmodule I saw a significant rise in boot time (from 4s to 13s).
This is not because of plugins or optimization but because of the declaration of all the pages on start up.
This architecture scales VERY badly with bigger apps (I guess from 20 pages up). But it’s not an ionic issue, it’s Angular.
It is impossible to get a decent startup time without aot and Angular >rc4.
After I tried AoT boot time went down to 1-2s on an iphone 5s, and around 7-10s on a 2013 Nexus7.
I’m just mentioning this because some people stated that they saw no decrease in startup time with aot, which makes no sense in the first place.
Especially if you use ionic-app-scripts which also gives you stripping of comments/uglify etc.
So don’t only give rc1 a try, also use AoT.
It took me around 2 hours to migrate an app with around 250 files to rc1. The only hickup I had were changes in theming which destroyed some of my layout.
For AoT I also had to rewrite the FormControls in templates files (e.g. control.name => get(‘name’))
But besides that it went pretty fast and smoothly.
Hey @ventr1x maybe I’m misreading wrongly your post or missing something, but you are saying that you kind of activated something to try AoT?
Basically you migrated to RC.1, boot time was slow, and then you activated AoT and boot time went faster, right? In such case, could you point out what did you do?
I thought that AoT was kind of the default build option in RC.0 or RC.1, that is maybe my biggest mistake
if you build with --release tag you should have AOT
ionic build android --release
Is it really?
With RC.0 or RC.1 and app-scripts 0.0.39 I’ve heard that there is no such option as --release while building.
Furthermore, in my case, when I add that options to the cmd, my app is build but at the end of the process I end up with the previous build I did without that option aka nothing new is generated (I opened an issue about that https://github.com/driftyco/ionic-app-scripts/issues/279)
I honestly don’t know how to build for AoT with ionic build. It did never work for me and there is no documentation on it whatsoever. It starts with app.module.ngFactory not being found (d’uh, it has to be generated first but how and where?).
That is basically the official doc to it: https://ionicframework.com/docs/v2/cli/build/
A joke! As you can see --release is even undocumented and not to be trusted in the first place.
If it’s really “just a proxy for cordova”, AoT should actually not be included with it. Or since when does cordova exclusively build for Angular2?
Yes I compared ionic serve (uploaded to build.phonegap) with AoT (ionic-app-scripts works, or simply use Angular2 yourself).
Looking into the source code you should easily see if it’s just concatenated files or made with AoT/uglify etc.
It was/is also for me really unclear what commands do what. Therefore I opened a post here
The output of the discussion was
The command “ionic help” give back the list of commands and their options
In the readme of ionic-app-scripts (see “All Available Tasks”) there is some more options
But at the end in both places, --release, which is often use and posted, isn’t documented anywhere, that’s why I was asking. But well let’s see what the Ionic team answer to my issue 0.0.37-2 ionic build android --release doesn't build a new release! · Issue #279 · ionic-team/ionic-app-scripts · GitHub
Good to know that --release works for you and generate AoT but if it’s really the solution to release an application with AoT, then my above issue is quite a problem for me, because running the command with that option doesn’t produce any new version of my application in my case. Hope we gonna sort out these questions.
Have you read the last blog post about the build process?
Within the many good news, one point had my attention
ngc = AoT compilation
Therefor, I guess, with “ionic serve” or “ionic build …” in both case, since this appears as log, AoT is compiled
Well, we can’t all monitor github, reddit, blogs, twitter, forums, docs etc. for changes every day.
Problems start with docs not having any versioning. Especially descriptions for plugins constantly change, many things are not documented at all (I bet I could find undocumented functions and classes for every single plugin).
ionic-app-scripts for example is not even mentioned anywhere in any docs or tutorial. Why? It seems an integral part of a production app, if you don’t want to write all the scripts yourself. Someone that doesn’t go through all the github projects might never know about it in the first place.
I’m around since ionic 1 and I actually didn’t know about it, though I had my own setup with ionic 1.
Tried deleting .tmp? Then it has to regenerate the files.
Thx for the idea, unfortunately, deleting .tmp didn’t worked
The Ionic team answered the question on the tracking system.
ionic serve = no AoT
ionic build = AoT, minify, etc.
And furthermore, there is no such option as --release aka when you do “ionic build android/ios” the all productive build is executed aka this option isn’t necessary
So that clear up my question about AoT and --release
Now I still have to discover why my app start in 2 seconds with the emulator and 2-3 times slower on a real devices, even brand new one