angular / angular/components

Autocomplete slow to update with large data sets after material beta 12

未关闭
#7,749 18 条评论 17 个 reaction 已指派 0 人 在 GitHub 查看
area: material/autocomplete P4 perf
主要语言
TypeScript
星标
25k
派生
6.8k
平均合并
1 天 8 小时
30 天内合并 PR
91

描述

#### Bug, feature request, or proposal:
When displaying an autocomplete list with a large number of options it is slow to display. It appears that this is caused by 2 event listeners being created for each item in the list. This slowness started after updating to beta 12.

You can see the large number of event listeners being set up if you open the Chrome dev tools and set the logging level to verbose.
`[Violation] Added non-passive event listener to a scroll-blocking 'touchstart' event. Consider marking event handler as 'passive' to make the page more responsive. See https://www.chromestatus.com/feature/5745543795965952`

#### What is the expected behavior?
Similar performance when using autocomplete with 200+ data sets to older versions of material.

#### What is the current behavior?
Rendering an autocomplete with a large number of options has a delay, it is even longer when the dev tools are open due to the large number of event listeners being created causing logs to be written to the console

#### What are the steps to reproduce?
Open dev tools, set console logging to verbose and click the "Click to toggle autocomplete" button .
You can also see the behavior by filtering the list, type anything to shorten the length of the list, then clear the input and new event listeners will be created again for each item in the list causing additional slowdown.
https://plnkr.co/edit/QhlHy7FrlvQbDeRfncCo?p=preview

#### What is the use-case or motivation for changing an existing behavior?
Improve performance. Is it not possible to have a single event listener on the parent that catches click events that bubble up? If not do 2 event listeners need to be created for each item in the list?

#### Which versions of Angular, Material, OS, TypeScript, browsers are affected?
Angular: 4.4.4
Material: beta.12
All browsers

#### Is there anything else we should know?
Event handler times on beta.11
Clearing out the input box, causing all items to be displayed again
`[Violation] 'input' handler took 187ms`
Clicking the button to display the autocomplete
`[Violation] 'click' handler took 246ms`

Event handler times on beta.12 doing the same actions
`[Violation] 'input' handler took 1347ms`
`[Violation] 'click' handler took 1048ms`

贡献指南

打开贡献指南

调研方向

从链接的 Plunker 中的 autocomplete 复现开始,并使用 Chrome DevTools 的详细日志记录来比较 beta.12 和 beta.11。跟踪打开、筛选和清空列表时 listener 的创建;当大型选项集不再产生报告中的 listener 相关延迟,并且 event-handler 时间与旧版本相当时,即表示完成。

由索引模型根据 Issue 内容生成。

评估

技术栈
angular, typescript
领域
frontend, performance
Issue 类型
缺陷
难度
4/5
预计耗时
3-5 天
活跃度
停滞
描述清晰度
基本清楚
新手友好度
38/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。