-
-
Notifications
You must be signed in to change notification settings - Fork 241
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Very slow bootstrap after Angular RC-5 upgrade (>3 seconds) #474
Comments
I think the reason the application bootstrap got suddenly slow was than in the migration to RC5 the bootstrap of the module mean much more things to do that initially. Some comments/ideas guys ?, someone else experiencing the same ? It is possible to use Ahead-of-Time Compilation with Nativescript ? |
+1 |
No yet @gergderkson, but I wasn't yet able to upgrade to Angular 2.1 for example (I'm waiting for an issue with nativescript-ng2-translate NathanWalker/nativescript-ng2-translate#5 |
I confirm slow bootstrap time with many components even on iOS... |
Just to confirm, after upgrade to Angular 2.1.2, the problem still persists. |
I'm going to rewrite my app to use "simple" nativescript because startup time (a complex app with more than 20 pages) on devices is more than 10s on iOS and more than 20s on Android where the sluggishness is unbearable expecially on Android... I think this is a SERIOUS problem that prevents nativescript-angular to be used in production... |
The team is working on providing a solution here. There are several initiatives going on at the moment:
I can't say much about the release schedule for the improvements above yet. We'll track them in separate issues. |
@stefalda 20 seconds on Android is nowhere near the optimizal experience we offer with Angular :). you don't need to replace Angular, there is probably some problem in the way the components are imported at startup. Can you please share the code? The usual startup time is ~2seconds and we will make it even less in 2.5 release. Our goals is near 1sec startup time and we have ideas how to achieve it. 10/20 seconds is definitely a bug of some kind (either in the app, either a corner case we need to look at in our implmenetation) and not a normal behaviour! |
@stefalda let me comment that the total startup time exceeds 2 seconds, just the Angular bootstrapping also exceeds 2 seconds. The problem is that is literally a white screen lasting those 5 seconds while the bootstrapping takes place. |
@valentinstoychev I glaly would like so... Here's my main.ts and app-route.ts main.ts import { platformNativeScriptDynamic, NativeScriptModule } from "nativescript-angular/platform";
import { SIDEDRAWER_DIRECTIVES } from "nativescript-telerik-ui/sidedrawer/angular";
const application = require("application");
import { NgModule } from "@angular/core";
import { NativeScriptRouterModule } from "nativescript-angular/router";
import { AppComponent } from "./app.component";
import { routes, navigatableComponents, sharedComponents } from "./app.routing";
declare var GMSServices;
@NgModule({
declarations: [AppComponent,
...navigatableComponents,
...sharedComponents,
SIDEDRAWER_DIRECTIVES],
bootstrap: [AppComponent],
imports: [NativeScriptModule,
NativeScriptRouterModule,
NativeScriptRouterModule.forRoot(routes)
],
})
class AppComponentModule {}
if (application.ios){
GMSServices.provideAPIKey("XXXXX");
}
platformNativeScriptDynamic().bootstrapModule(AppComponentModule); app.routing.ts //Components
import {MenuComponent} from "./components/menu/menu";
import {PremioTheBestComponent} from "./components/premio-the-best/premio-the-best";
import {WebViewerComponent} from "./components/web-viewer/web-viewer";
import {SchedaAziendaComponent} from "./components/scheda-azienda/scheda-azienda";
import {MappaComponent} from "./components/mappa/mappa";
import {ListaPrincipaleComponent} from "./components/lista-principale/lista-principale";
import {AtlanteComponent} from "./components/atlante/atlante";
import {ListaAziendeTipoComponent} from "./components/lista-aziende-tipo/lista-aziende-tipo";
import {ListaAziendeRicercaComponent} from "./components/lista-aziende-ricerca/lista-aziende-ricerca";
import {ListaAziendeStatoComponent} from "./components/lista-aziende-stato/lista-aziende-stato";
import {AtlanteRegioniComponent} from "./components/atlante-regioni/atlante-regioni";
import {SchedaStatoComponent} from "./components/scheda-stato/scheda-stato";
import {SchedaRegioneComponent} from "./components/scheda-regione/scheda-regione";
import {DenominazioniComponent} from "./components/denominazioni/denominazioni";
import {OliveComponent} from "./components/olive/olive";
import {FlosOleiPointComponent} from "./components/flosolei-point/flosolei-point";
import {TestiETabelleComponent} from "./components/testi-e-tabelle/testi-e-tabelle";
import {SchedaDenominazioneComponent} from "./components/scheda-denominazione/scheda-denominazione";
import {SchedaOliveComponent} from "./components/scheda-olive/scheda-olive";
import {SchedaFlosOleiPointComponent} from "./components/scheda-flosolei-point/scheda-flosolei-point";
import {TecnicaDegustazioneComponent} from "./components/tecnica-degustazione/tecnica-degustazione";
import {GlossarioComponent} from "./components/glossario/glossario";
import {SchedaGlossarioComponent} from "./components/scheda-glossario/scheda-glossario";
import {FiltriRicercaComponent} from "./components/filtri-ricerca/filtri-ricerca";
import {ListaAziendeIntornoAMeComponent} from "./components/lista-aziende-intorno-a-me/lista-aziende-intorno-a-me";
import {PreferitiComponent} from "./components/preferiti/preferiti";
//Shared components
import {Indicatori} from "./components/shared/indicatori/indicatori";
import {Indicatore} from "./components/shared/indicatore/indicatore";
import {ListaAziende} from "./components/shared/lista-aziende/lista-aziende";
import {PickerComponent} from "./components/shared/picker/picker";
//import {SectionedListViewComponent} from "./components/shared/sectioned-list-view"
export const routes = [
{ path: "", component: MenuComponent },
{ path: "menu", component: MenuComponent },
{ path: "premio-the-best", component: PremioTheBestComponent },
{ path: "web-viewer/:page", component: WebViewerComponent },
{ path: "scheda-azienda/:id", component: SchedaAziendaComponent },
{ path: "mappa/:id", component: MappaComponent },
{ path: "mappa-fop/:id", component: MappaComponent },
{ path: "lista-aziende-intorno-a-me", component: ListaAziendeIntornoAMeComponent },
{ path: "mappa-aziende-intorno-a-me", component: MappaComponent },
{ path: "scheda-stato/:id", component: SchedaStatoComponent },
{ path: "scheda-regione/:id", component: SchedaRegioneComponent },
{ path: "scheda-denominazione/:id", component: SchedaDenominazioneComponent },
{ path: "scheda-flosolei-point/:id", component: SchedaFlosOleiPointComponent },
{ path: "scheda-olive/:id", component: SchedaOliveComponent },
{ path: "aziende-stato/:filter/:statoId", component: ListaAziendeStatoComponent},
{ path: "aziende-regione/:filter/:statoId/:regioneId", component: ListaAziendeStatoComponent},
{ path: "atlante", component: AtlanteComponent},
{ path: "flosolei-point", component:FlosOleiPointComponent},
{ path: "olive", component:OliveComponent},
{ path: "denominazioni", component: DenominazioniComponent},
{ path: "flosolei-point", component: FlosOleiPointComponent},
{ path: "atlante-regioni/:filter/:statoId", component: AtlanteRegioniComponent},
{ path: "lista-principale/:filter", component: ListaPrincipaleComponent,
children: [
{ path: "", redirectTo:"lista-aziende-tipo" },
{ path: "lista-aziende-tipo", component: ListaAziendeTipoComponent },
{ path: "olive", component: OliveComponent },
{ path: "denominazioni", component: DenominazioniComponent},
{ path: "flosolei-point", component: FlosOleiPointComponent},
{ path: "atlante", children:[
{path: "", component: AtlanteComponent},
{path:"lista-aziende-stato/:statoId", component: ListaAziendeStatoComponent},
] }
] },
{ path: "testi-e-tabelle", component: TestiETabelleComponent},
{ path: "glossario", component: GlossarioComponent },
{ path: "scheda-glossario/:id", component: SchedaGlossarioComponent },
{ path: "tecnica-degustazione", component: TecnicaDegustazioneComponent },
{ path: "filtri-ricerca", component: FiltriRicercaComponent },
{ path: "aziende-ricerca", component: ListaAziendeRicercaComponent},
{ path: "preferiti", component: PreferitiComponent},
];
export const navigatableComponents = [
MenuComponent,
PremioTheBestComponent,
WebViewerComponent,
SchedaAziendaComponent,
MappaComponent,
ListaPrincipaleComponent,
AtlanteComponent,
ListaAziendeTipoComponent,
ListaAziendeStatoComponent,
AtlanteRegioniComponent,
SchedaStatoComponent,
SchedaRegioneComponent,
DenominazioniComponent,
OliveComponent,
FlosOleiPointComponent,
TestiETabelleComponent,
SchedaDenominazioneComponent,
SchedaOliveComponent,
SchedaFlosOleiPointComponent,
GlossarioComponent,
SchedaGlossarioComponent,
TecnicaDegustazioneComponent,
FiltriRicercaComponent,
ListaAziendeRicercaComponent,
ListaAziendeIntornoAMeComponent,
PreferitiComponent
];
export const sharedComponents = [
Indicatori,
Indicatore,
ListaAziende,
PickerComponent
]; |
Hi, just updated to 2.4... On iOS it works (almost) ok: On Android the startup time is still a problem: Same app in pure nativescript: Startup time on iPhone 6 Plus: 2,45s Stefano |
the issue is exactly in the routing. You should use lazy loading in this case, because currently the way Angular works is that all the components will be parsed during the load of the application. To see how to implement this please check this sample application that loads ~200 pages - https://github.com/NativeScript/nativescript-sdk-examples-ng/blob/master/app/examples-list.module.ts Please also note that we are aware that the loading time with Angular is still not optimized and the team is working on full force to optimize this with the 2.5 release. Our goal is loading time of 1-2seconds depending on the device. Implementing the above lazy loading pattern will increase the loading time significantly though. Please keep us posted on the progress. |
Thanks @valentinstoychev the idea would be to split the application into modules and keep the initialization section on a separate small module right ? |
Yes, exactly. |
Guys I tried to implement the lazy loading but receiving an error when using it.
Here is the root module:
and the routes:
Am I doing something wrong ?, I saw also that @sis0k0 just modified the example to do it differently, but seems to be related to webpack, right ?, should I change it ?, because I'm also distributing with webpack. |
Hey guys, I do partially solve the problem by updating to the latest versions (I did realize there were new versions in the sample template). The problem that remains is that it does not recognize the lazy loaded feature module routes apart from the root one. For example, I have this routers for one of the feature modules:
but it throws this error when tapped:
|
Solved guys, just my mistake when constructing the route (it was global before so missing the parent path when updated to feature modules). Whenever you can please comment about the changes of @sis0k0. I moved to use the NsModuleFactoryLoader and to write the loadChildren in the regular NG way ( |
I've followed the Nativescript blog post about lazy loading and the lazyNinjas source but I wasn't unable to make it work... even the git repo crashes when launching the emulator :-(
|
Hey @stefalda, make sure you have the latest versions of the modules (angular 2.2.1, router 3.2.1, ...), create an empty project and compare the dependencies against. Secondly, to use the "./pages/main/main.module#MainModule" notation you will need to use the https://github.com/NativeScript/nativescript-sdk-examples-ng/blob/master/app/ns-module-factory-loader.ts as in here: https://github.com/NativeScript/nativescript-sdk-examples-ng/blob/master/app/app.module.ts After that you should be able to work it out. It does start relatively fast (1 or 1.5s). |
I'm getting this error: Uncaught (in promise): TypeError: undefined is not an object (evaluating ' Using the nativescript-sdk-examples-ng exactly, not sure whatsup. Any way to diagnose? |
Hi, I am using NS 2.5, with angular 2.4.3 and webpack. The app compiles and runs, but when I navigate to a component that is lazy loaded, I get Any suggestions? thanks :) |
I have detected that since the last update of angular (NG 2.0) the bootstrap of the application slows down dramatically (about 3 second of white screen after the splash screen on my laptop and even worse on the devices). Check out the log/code below running on the emulator.
I'm wondering which alternatives do I have to improve the startup speed ?
Check this log fragment:
The bootstrapping took 3 seconds:
Basically here is the code that produce the log:
And here the the current module (as an example of dimension of the app):
Let me add that I packaged the application with webpack recently (expecting this might cause an improvement) but basically remains the same.
The text was updated successfully, but these errors were encountered: