diff --git a/nativescript-angular/directives/list-view-comp.ts b/nativescript-angular/directives/list-view-comp.ts index 546130fc1..cbf9aa46f 100644 --- a/nativescript-angular/directives/list-view-comp.ts +++ b/nativescript-angular/directives/list-view-comp.ts @@ -23,6 +23,7 @@ import { ListView, ItemEventData } from "tns-core-modules/ui/list-view"; import { View, KeyedTemplate } from "tns-core-modules/ui/core/view"; import { ObservableArray } from "tns-core-modules/data/observable-array"; import { LayoutBase } from "tns-core-modules/ui/layouts/layout-base"; +import { profile } from "tns-core-modules/profiling"; import { CommentNode } from "../element-registry"; import { isListLikeIterable } from "../collection-facade"; @@ -148,6 +149,7 @@ export class ListViewComponent implements DoCheck, OnDestroy, AfterContentInit { this._templateMap.set(key, keyedTemplate); } + @profile public onItemLoading(args: ItemEventData) { if (!args.view && !this.itemTemplate) { return; @@ -195,6 +197,7 @@ export class ListViewComponent implements DoCheck, OnDestroy, AfterContentInit { this.setupItemView.next({ view: viewRef, data: data, index: index, context: context }); } + @profile private detectChangesOnChild(viewRef: EmbeddedViewRef, index: number) { listViewLog("Manually detect changes in child: " + index); viewRef.markForCheck(); diff --git a/nativescript-angular/platform-common.ts b/nativescript-angular/platform-common.ts index bd2373347..374d9276c 100644 --- a/nativescript-angular/platform-common.ts +++ b/nativescript-angular/platform-common.ts @@ -6,6 +6,7 @@ import "./zone-js/dist/zone-nativescript"; import "reflect-metadata"; import "./polyfills/array"; import "./polyfills/console"; +import { profile } from "tns-core-modules/profiling"; import { Type, @@ -68,6 +69,7 @@ export class NativeScriptPlatformRef extends PlatformRef { super(); } + @profile bootstrapModuleFactory(moduleFactory: NgModuleFactory): Promise> { this._bootstrapper = () => this.platform.bootstrapModuleFactory(moduleFactory); @@ -76,6 +78,7 @@ export class NativeScriptPlatformRef extends PlatformRef { return null; // Make the compiler happy } + @profile bootstrapModule( moduleType: Type, compilerOptions: CompilerOptions | CompilerOptions[] = [] @@ -87,6 +90,7 @@ export class NativeScriptPlatformRef extends PlatformRef { return null; // Make the compiler happy } + @profile private bootstrapApp() { (global).__onLiveSyncCore = () => this.livesyncModule(); @@ -139,6 +143,7 @@ export class NativeScriptPlatformRef extends PlatformRef { return this.platform.destroyed; } + @profile private createNavigationEntry( bootstrapAction: BootstrapperAction, resolve?: (comp: NgModuleRef) => void, @@ -150,20 +155,25 @@ export class NativeScriptPlatformRef extends PlatformRef { const navEntry: NavigationEntry = { create: (): Page => { - let page = pageFactory({ isBootstrap: true, isLivesync }); + const page = pageFactory({ isBootstrap: true, isLivesync }); setRootPage(page); if (this.appOptions) { page.actionBarHidden = this.appOptions.startPageActionBarHidden; } - let initHandler = function () { + const initHandlerMethodName = + "nativescript-angular/platform-common.initHandler"; + const initHandler = profile(initHandlerMethodName, () => { page.off(Page.navigatingToEvent, initHandler); // profiling.stop("application-start"); rendererLog("Page loaded"); // profiling.start("ng-bootstrap"); rendererLog("BOOTSTRAPPING..."); - bootstrapAction().then((moduleRef) => { + + const bootstrapMethodName = + "nativescript-angular/platform-common.postBootstrapAction"; + bootstrapAction().then(profile(bootstrapMethodName, moduleRef => { // profiling.stop("ng-bootstrap"); rendererLog("ANGULAR BOOTSTRAP DONE."); lastBootstrappedModule = new WeakRef(moduleRef); @@ -172,9 +182,9 @@ export class NativeScriptPlatformRef extends PlatformRef { resolve(moduleRef); } return moduleRef; - }, (err) => { + }), err => { rendererError("ERROR BOOTSTRAPPING ANGULAR"); - let errorMessage = err.message + "\n\n" + err.stack; + const errorMessage = err.message + "\n\n" + err.stack; rendererError(errorMessage); let view = new TextView(); @@ -185,7 +195,7 @@ export class NativeScriptPlatformRef extends PlatformRef { reject(err); } }); - }; + }); page.on(Page.navigatingToEvent, initHandler); diff --git a/nativescript-angular/renderer.ts b/nativescript-angular/renderer.ts index c9ec5c122..b95318bc3 100644 --- a/nativescript-angular/renderer.ts +++ b/nativescript-angular/renderer.ts @@ -8,6 +8,7 @@ import { Device } from "tns-core-modules/platform"; import { View } from "tns-core-modules/ui/core/view"; import { addCss } from "tns-core-modules/application"; import { topmost } from "tns-core-modules/ui/frame"; +import { profile } from "tns-core-modules/profiling"; import { APP_ROOT_VIEW, DEVICE, getRootPage } from "./platform-providers"; import { isBlank } from "./lang-facade"; @@ -83,95 +84,114 @@ export class NativeScriptRenderer extends Renderer2 { traceLog("NativeScriptRenderer created"); } + @profile appendChild(parent: any, newChild: NgView): void { traceLog(`NativeScriptRenderer.appendChild child: ${newChild} parent: ${parent}`); this.viewUtil.insertChild(parent, newChild); } + @profile insertBefore(parent: NgView, newChild: NgView, refChildIndex: number): void { traceLog(`NativeScriptRenderer.insertBefore child: ${newChild} parent: ${parent}`); this.viewUtil.insertChild(parent, newChild, refChildIndex); } + @profile removeChild(parent: any, oldChild: NgView): void { traceLog(`NativeScriptRenderer.removeChild child: ${oldChild} parent: ${parent}`); this.viewUtil.removeChild(parent, oldChild); } + @profile selectRootElement(selector: string): NgView { traceLog("selectRootElement: " + selector); return this.rootView; } + @profile parentNode(node: NgView): any { return node.parent || node.templateParent; } + @profile nextSibling(node: NgView): number { traceLog(`NativeScriptRenderer.nextSibling ${node}`); return this.viewUtil.nextSiblingIndex(node); } + @profile createComment(_value: any): CommentNode { traceLog(`NativeScriptRenderer.createComment ${_value}`); return this.viewUtil.createComment(); } + @profile createElement(name: any, _namespace: string): NgView { traceLog(`NativeScriptRenderer.createElement: ${name}`); return this.viewUtil.createView(name); } + @profile createText(_value: string): CommentNode { traceLog(`NativeScriptRenderer.createText ${_value}`); return this.viewUtil.createText(); } + @profile createViewRoot(hostElement: NgView): NgView { traceLog(`NativeScriptRenderer.createViewRoot ${hostElement.nodeName}`); return hostElement; } + @profile projectNodes(parentElement: NgView, nodes: NgView[]): void { traceLog("NativeScriptRenderer.projectNodes"); nodes.forEach((node) => this.viewUtil.insertChild(parentElement, node)); } + @profile destroy() { traceLog("NativeScriptRenderer.destroy"); // Seems to be called on component dispose only (router outlet) // TODO: handle this when we resolve routing and navigation. } + @profile setAttribute(view: NgView, name: string, value: string, namespace?: string) { traceLog(`NativeScriptRenderer.setAttribute ${view} : ${name} = ${value}, namespace: ${namespace}`); return this.viewUtil.setProperty(view, name, value, namespace); } + @profile removeAttribute(_el: NgView, _name: string): void { traceLog(`NativeScriptRenderer.removeAttribute ${_el}: ${_name}`); } + @profile setProperty(view: any, name: string, value: any) { traceLog(`NativeScriptRenderer.setProperty ${view} : ${name} = ${value}`); return this.viewUtil.setProperty(view, name, value); } + @profile addClass(view: NgView, name: string): void { traceLog(`NativeScriptRenderer.addClass ${name}`); this.viewUtil.addClass(view, name); } + @profile removeClass(view: NgView, name: string): void { traceLog(`NativeScriptRenderer.removeClass ${name}`); this.viewUtil.removeClass(view, name); } + @profile setStyle(view: NgView, styleName: string, value: any, _flags?: RendererStyleFlags2): void { traceLog(`NativeScriptRenderer.setStyle: ${styleName} = ${value}`); this.viewUtil.setStyle(view, styleName, value); } + @profile removeStyle(view: NgView, styleName: string, _flags?: RendererStyleFlags2): void { traceLog("NativeScriptRenderer.removeStyle: ${styleName}"); this.viewUtil.removeStyle(view, styleName); @@ -179,23 +199,28 @@ export class NativeScriptRenderer extends Renderer2 { // Used only in debug mode to serialize property changes to comment nodes, // such as