angular: For loops in new control flow are extremely slow and taking much more memory than ngFor
Which @angular/* package(s) are the source of the bug?
core
Is this a regression?
Yes
Description
I recently upgraded an Angular app to new control flow. All I did was:
- Run automatic migration
- Fix components where the migration didn’t properly updated the code to the new syntax
On few components where we have large lists with infinite scroll, the app becomes very unresponsive as soon as we start loding more data to the list and list becomes large.
This was working perfectly with old ngFor syntax.
I have tried it with inline list as well as moving list to a seperate component with ChangeDetectionStrategy.OnPush
.
Please provide a link to a minimal reproduction of the bug
For this I can add you to a private repo
Please provide the exception or error you saw
The app becomes unresponsive and starts consume more memory 4Gb-6Gb.
Please provide the environment you discovered this bug in (run ng version
)
Angular CLI: 17.0.0-rc.3
Node: 18.18.2
Package Manager: npm 9.8.1
OS: win32 x64
Angular: 17.0.0-rc.2
... animations, common, compiler, compiler-cli, core, forms
... platform-browser, platform-browser-dynamic, platform-server
... router, service-worker
Package Version
---------------------------------------------------------
@angular-devkit/architect 0.1700.0-rc.3
@angular-devkit/build-angular 17.0.0-rc.3
@angular-devkit/core 17.0.0-rc.3
@angular-devkit/schematics 17.0.0-rc.3
@angular/cdk 17.0.0-rc.1
@angular/cli 17.0.0-rc.3
@angular/fire 16.0.0
@angular/google-maps 17.0.0-rc.1
@angular/material 17.0.0-rc.1
@angular/pwa 17.0.0-rc.3
@schematics/angular 17.0.0-rc.3
rxjs 7.8.1
typescript 5.2.2
zone.js 0.14.0
Anything else?
No response
About this issue
- Original URL
- State: closed
- Created 8 months ago
- Comments: 21 (19 by maintainers)
Commits related to this issue
- fix(core): properly update collection with repeated keys in @for This change fixes a bug in the new list reconcilation algorithm that could lead to an infinite loop in certain situations. More speci... — committed to pkozlowski-opensource/angular by pkozlowski-opensource 8 months ago
- fix(core): properly update collection with repeated keys in @for (#52697) This change fixes a bug in the new list reconcilation algorithm that could lead to an infinite loop in certain situations. M... — committed to angular/angular by pkozlowski-opensource 8 months ago
- fix(core): limit rate of markers invocations This PR assures that the performance markers are invoked only once for a given feature. Closes #52524 — committed to pkozlowski-opensource/angular by pkozlowski-opensource 8 months ago
- fix(core): limit rate of markers invocations This PR assures that the performance markers are invoked only once for a given feature. Closes #52524 — committed to pkozlowski-opensource/angular by pkozlowski-opensource 8 months ago
- fix(core): limit rate of markers invocations This PR assures that the performance markers are invoked only once for a given feature. Closes #52524 — committed to pkozlowski-opensource/angular by pkozlowski-opensource 8 months ago
- fix(core): limit rate of markers invocations This PR assures that the performance markers are invoked only once for a given feature. Closes #52524 — committed to pkozlowski-opensource/angular by pkozlowski-opensource 8 months ago
- fix(core): limit rate of markers invocations (#52742) This PR assures that the performance markers are invoked only once for a given feature. Closes #52524 PR Close #52742 — committed to angular/angular by pkozlowski-opensource 8 months ago
- fix(core): properly update collection with repeated keys in @for (#52697) This change fixes a bug in the new list reconcilation algorithm that could lead to an infinite loop in certain situations. M... — committed to tbondwilkinson/angular by pkozlowski-opensource 8 months ago
- fix(core): limit rate of markers invocations (#52742) This PR assures that the performance markers are invoked only once for a given feature. Closes #52524 PR Close #52742 — committed to tbondwilkinson/angular by pkozlowski-opensource 8 months ago
- fix(core): properly update collection with repeated keys in @for (#52697) This change fixes a bug in the new list reconcilation algorithm that could lead to an infinite loop in certain situations. M... — committed to ChellappanRajan/angular by pkozlowski-opensource 8 months ago
- fix(core): limit rate of markers invocations (#52742) This PR assures that the performance markers are invoked only once for a given feature. Closes #52524 PR Close #52742 — committed to ChellappanRajan/angular by pkozlowski-opensource 8 months ago
- fix(core): properly update collection with repeated keys in @for (#52697) This change fixes a bug in the new list reconcilation algorithm that could lead to an infinite loop in certain situations. M... — committed to happytrip/angular by pkozlowski-opensource 8 months ago
- fix(core): limit rate of markers invocations (#52742) This PR assures that the performance markers are invoked only once for a given feature. Closes #52524 PR Close #52742 — committed to happytrip/angular by pkozlowski-opensource 8 months ago
Yay, @jessicajaniuk did a fantastic job cutting another release. @naveedahmed1 17.0.2 should be on npm: https://www.npmjs.com/package/@angular/core/v/17.0.2
Re-opening since we will need another PR to fully resolve it.
@naveedahmed1 after profiling your scenario it turns out that your issue is not linked to the repeater at all. So the issue I’ve fixed in https://github.com/angular/angular/pull/52697 is a different one.
I do understand what is going on in your case and working on a fix. Thnx for reporting and sharing a reproduction scenario!
I believe that I’ve go a fix for this issue in https://github.com/angular/angular/pull/52697 - it is really one-liner change in https://github.com/angular/angular/pull/52697/files#diff-50d29735590abe5158e57a756c63b2d04c0bfd65bbd6a75c4ee48ca82c8ee1caR291 - if anyone is facing similar issue and want to test with a patched Angular version it would be appreciated!