Title: Performance issue in Firefox with ng-container inside a
Open Graph Title: Performance issue in Firefox with ng-container inside a
X Title: Performance issue in Firefox with ng-container inside a
Description: Which @angular/* package(s) are the source of the bug? platform-browser Is this a regression? No Description I have a list of ~2000 entries (US Universities) in a
Open Graph Description: Which @angular/* package(s) are the source of the bug? platform-browser Is this a regression? No Description I have a list of ~2000 entries (US Universities) in a
X Description: Which @angular/* package(s) are the source of the bug? platform-browser Is this a regression? No Description I have a list of ~2000 entries (US Universities) in a <select> element, with some ...
Opengraph URL: https://github.com/angular/angular/issues/50233
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Performance issue in Firefox with ng-container inside a \u003cselect>","articleBody":"### Which @angular/* package(s) are the source of the bug?\r\n\r\nplatform-browser\r\n\r\n### Is this a regression?\r\n\r\nNo\r\n\r\n### Description\r\n\r\nI have a list of ~2000 entries (US Universities) in a `\u003cselect>` element, with some dynamic filtering done with an `ngIf`. In short the code looks like this:\r\n\r\n```\r\n \u003cselect>\r\n \u003cng-container *ngFor=\"let option of options\">\r\n \u003coption\r\n *ngIf=\"true\"\r\n [ngValue]=\"option.value\"\r\n >\r\n {{ option.displayText ?? 'Please select' }}\r\n \u003c/option>\r\n \u003c/ng-container>\r\n \u003c/select>\r\n```\r\n\r\nWhile this works fine in Chrome, this causes Firefox to freeze. Spinning up the Firefox DevTools shows that the native DOM `Node.insertBefore` for each of the 2000 select items take almost 1s, compare to ~300ms in Chrome (x3000 faster).\r\n\r\nFirefox:\r\n\r\n\u003cimg width=\"1624\" alt=\"Screenshot 2023-05-05 at 09 48 12\" src=\"https://github.com/angular/angular/assets/2169585/9e817714-25e8-481f-a9de-f47ce39e7496\">\r\n\r\nChrome:\r\n\r\n\u003cimg width=\"1624\" alt=\"Screenshot 2023-05-05 at 09 49 05\" src=\"https://github.com/angular/angular/assets/2169585/8cfa6a87-1889-4f90-8e54-20c2cac52a90\">\r\n\r\nPlaying around with the repro in https://stackblitz.com/edit/angular-f1vhwu?file=src%2Fmain.ts shows that removing the `*ngIf` & moving the `*ngFor` to the `\u003coption>` element (aka removing the `\u003cng-container>`) works around the issue, although in my case I cannot do that (e.g. pre-filter the `options` object) as I use the `*ngIf` to handle select groups/items.\r\n\r\nIn addition, this issue seems to be specific to `\u003cng-container>`s inside `\u003cselect>` elements, as a simple list of `\u003cdiv>`s load fine in Firefox (https://stackblitz.com/edit/angular-akq8zj?file=src/main.ts):\r\n\r\n```\r\n \u003cng-container *ngFor=\"let option of options\">\r\n \u003cdiv *ngIf=\"true\">\r\n {{ option.displayText ?? 'Please select' }}\r\n \u003c/div>\r\n \u003c/ng-container>\r\n```\r\n\r\nIn short, there seem to be a performance bug specific to Firefox with the way Angular handles `\u003cng-container>` elements within `\u003cselect>`\r\n\r\n### Please provide a link to a minimal reproduction of the bug\r\n\r\nhttps://stackblitz.com/edit/angular-f1vhwu?file=src%2Fmain.ts\r\n\r\n### Please provide the exception or error you saw\r\n\r\n```true\r\nFirefox becomes unresponsive and shows the \"This page is slowing down Firefox..\" banner\r\n```\r\n\r\n\r\n### Please provide the environment you discovered this bug in (run `ng version`)\r\n\r\n```true\r\nI'm on v14 but I've upgraded the StackBlitz to latest and it still happens\r\n```\r\n\r\n\r\n### Anything else?\r\n\r\nOur CEO happens to be using Firefox 😀","author":{"url":"https://github.com/laurentgoudet","@type":"Person","name":"laurentgoudet"},"datePublished":"2023-05-10T14:34:19Z","url":"https://github.com/angular/angular/issues/50233"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:ea76385e-d610-ae78-03bd-3e3fe6fdb224 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | EA40:19AA62:1864B3B:1EFFF2D:6B0140BB |
| html-safe-nonce | 1ee44e7dbc3058518a8462373171422cc6685664df3fb6aca56e0884e3cb5748 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFQTQwOjE5QUE2MjoxODY0QjNCOjFFRkZGMkQ6NkIwMTQwQkIiLCJ2aXNpdG9yX2lkIjoiNTM1NTQ5MTAyMDYzOTM4NzgzNSIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 98ee3ea96e7842d455dc7e4cd7930088d92e52d92501694484f582cb5257e103 |
| hovercard-subject-tag | issue:1704068493 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/angular/angular/50233/issue_layout |
| twitter:image | https://opengraph.githubassets.com/33d70ae00129ee1295d48b8448bc81462d7e65ea8c109c95a8b4cb8d2a856c54/angular/angular/issues/50233 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/33d70ae00129ee1295d48b8448bc81462d7e65ea8c109c95a8b4cb8d2a856c54/angular/angular/issues/50233 |
| og:image:alt | Which @angular/* package(s) are the source of the bug? platform-browser Is this a regression? No Description I have a list of ~2000 entries (US Universities) in a |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | laurentgoudet |
| hostname | github.com |
| expected-hostname | github.com |
| None | cc5dfdd32f62ebd3223cab3af3aa2b268d3605218237326a48a99d1efd89495c |
| turbo-cache-control | no-preview |
| go-import | github.com/angular/angular git https://github.com/angular/angular.git |
| octolytics-dimension-user_id | 139426 |
| octolytics-dimension-user_login | angular |
| octolytics-dimension-repository_id | 24195339 |
| octolytics-dimension-repository_nwo | angular/angular |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 24195339 |
| octolytics-dimension-repository_network_root_nwo | angular/angular |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 8c77c9e8439031ad54c75a250694842892f693e1 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width