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:

  1. Run automatic migration
  2. 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

Most upvoted comments

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!