Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

When list items are removed list.layout is called multiple times can causes a performance issue #1927

Closed
YonatanKra opened this issue Nov 1, 2020 · 2 comments · Fixed by #1928 or #1951
Assignees
Labels
Type: Bug Something isn't working

Comments

@YonatanKra
Copy link
Contributor

YonatanKra commented Nov 1, 2020

Describe the bug
The list-item's disconnected callback triggers the list's layout which triggers the updateItems. This causes a major performance issue with big lists.

To Reproduce
Steps to reproduce the behavior:

  1. Go to https://codesandbox.io/s/cool-paper-0k530?file=/src/index.js
  2. Open the developer tools in the performance tab and profile
  3. Click on the clear everything button
  4. Stop profiling
  5. See that:
    5.1 layout shift is reported
    5.2 The task takes a huge amount of time (and blocks the UI for that amount of time)

Expected behavior
I'd expect the list items to be removed without a performance overhead.

Screenshots
That's how it looks in the "lab test" from the sandbox example:
image
This is how it looks in a real life example from an angular application using the mwc-select with mwc-list-item:
image

Browser Version (please complete the following information):

  • OS: MacOS
  • Browser Chrome, Brave

**Additional context
There's a need for this amount of items in the select. For instance - to show all the available timezones (around 400 timezones on earth apparently).

@YonatanKra
Copy link
Contributor Author

Locally I've solved it with debouncing the layout method. It breaks tons of tests (due to the layout method becoming async).

@YonatanKra YonatanKra changed the title When list items are removed update items is called and causes a performance issue When list items are removed list.layout is called multiple times can causes a performance issue Nov 1, 2020
@YonatanKra
Copy link
Contributor Author

I've created #1928 to show a possible solution for this.
Definitely not complete, but we have a similar solution working in production at the moment.
Would love to sort this out with you.

@e111077 e111077 self-assigned this Nov 2, 2020
copybara-service bot pushed a commit that referenced this issue Nov 12, 2020
when removing an item.

Closes #1927

See my remarks blow regarding the outcome of this performance improvement, and proposed changes to this PR.

FUTURE_COPYBARA_INTEGRATE_REVIEW=#1928 from YonatanKra:fix-list-performance-issue d47cf23
PiperOrigin-RevId: 341937184
copybara-service bot pushed a commit that referenced this issue Nov 12, 2020
when removing an item.

Closes #1927

See my remarks blow regarding the outcome of this performance improvement, and proposed changes to this PR.

FUTURE_COPYBARA_INTEGRATE_REVIEW=#1928 from YonatanKra:fix-list-performance-issue d47cf23
PiperOrigin-RevId: 341937184
copybara-service bot pushed a commit that referenced this issue Nov 13, 2020
when removing an item.

Closes #1927

See my remarks blow regarding the outcome of this performance improvement, and proposed changes to this PR.

FUTURE_COPYBARA_INTEGRATE_REVIEW=#1928 from YonatanKra:fix-list-performance-issue d47cf23
PiperOrigin-RevId: 341937184
copybara-service bot pushed a commit that referenced this issue Nov 16, 2020
when removing an item.

Closes #1927

See my remarks blow regarding the outcome of this performance improvement, and proposed changes to this PR.

FUTURE_COPYBARA_INTEGRATE_REVIEW=#1928 from YonatanKra:fix-list-performance-issue d47cf23
PiperOrigin-RevId: 341937184
copybara-service bot pushed a commit that referenced this issue Nov 17, 2020
when removing an item.

Closes #1927

See my remarks blow regarding the outcome of this performance improvement, and proposed changes to this PR.

FUTURE_COPYBARA_INTEGRATE_REVIEW=#1928 from YonatanKra:fix-list-performance-issue d47cf23
PiperOrigin-RevId: 341937184
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Bug Something isn't working
Projects
None yet
2 participants