-
Notifications
You must be signed in to change notification settings - Fork 13.4k
Description
Bug Report
Ionic version:
[x] 4.x
Current behavior:
Having many Ionic 4 components on a page slows down the initial display significantly. Having investigated the performance profile, it was found that custom element callbacks such as attributeChangedCallback were triggered many many times and Angular's change detection (NgZone#onMicrotaskEmpty -> ApplicationRef#tick) gets triggered every time.
Expected behavior:
Unnecessary change detection should not run while each Ionic component's element are created.
Steps to reproduce:
- Ionic 4.2.0
- Angular 7.2.11
- zone.js 0.8.29
Opening (i.e. navigating to) a page with many many Ionic components while taking profile on Chrome Inspector's Performance tab. Searching for 'detectChanges' will tell you a large number of change detection has run.
Related code:
Having following line in zone-flags.ts, which is imported in polyfills.ts just before zone.js is imported, resolves the issue.
(window as any).__Zone_disable_customElements = true;
Alternatively downgrading zone.js to 0.8.26 should have the same effect as zone.js only patches customElement v1 since 0.8.27 (see angular/zone.js#1133).
Other information:
I have given a quick search over existing issues:
- performance issue reported in Performance issue in creating ion-select of 250 options #17641 may be related
Ionic info:
Ionic:
ionic (Ionic CLI) : 4.12.0
Ionic Framework : @ionic/angular 4.2.0
@angular-devkit/build-angular : 0.13.6
@angular-devkit/schematics : 7.3.6
@angular/cli : 7.3.6
@ionic/angular-toolkit : 1.4.1
Cordova:
cordova (Cordova CLI) : 8.0.0
Cordova Platforms : android 7.1.4, browser 6.0.0, ios 5.0.0
Cordova Plugins : cordova-plugin-ionic 4.1.7, cordova-plugin-ionic-keyboard 2.1.3, cordova-plugin-ionic-webview 2.4.1, (and 21 other plugins)
System:
Android SDK Tools : 26.0.2 (/■■■■■/Android/sdk)
ios-deploy : 1.9.2
ios-sim : 7.0.0
NodeJS : v8.9.1 (/■■■■■/node/v8.9.1/bin/node)
npm : 6.8.0
OS : macOS Mojave
Xcode : Xcode 10.1 Build version 10B61