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

[Bug/Performance]: Presence doesn't check if timeout exists #1526

Open
spaceemotion opened this issue Dec 28, 2024 · 0 comments
Open

[Bug/Performance]: Presence doesn't check if timeout exists #1526

spaceemotion opened this issue Dec 28, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@spaceemotion
Copy link

spaceemotion commented Dec 28, 2024

Environment

Developement/Production OS: Windows 10
Node version: 22
Package manager: pnpm@8
Radix Vue version: 1.9.11
Vue version:  3.5.13 
CSS framework: tailwindcss@3

Link to minimal reproduction

https://jsben.ch/pvIYE

Steps to reproduce

  1. Have over a thousand menus on the screen (e.g. a long list of non-virtualized elements)
  2. Load the page with the profiler open
  3. See many clearTimeouts tanking the performance

Describe the bug

We got a user report where the page loads quite slow for them. Turns out they're an outlier, but they still have about 900 entries in our system, each causing 2 Dropdown menus to be rendered on the screen (in a container with a scrollbar, but still).

After some digging, I saw that the Presence system seems to be the cause:

ownerWindow?.clearTimeout(timeoutId)

When a menu is still invisible and hasn't been interacted with, the timeout doesn't need to be cleared, but it's called regardless. The repro link is a JS benchmark that compares:

  1. calling clearTimeout even with an undefined ID
  2. checking if the ID is undefined before calling clearTimeout.

It seems that not calling it seems to bring a big performance boost (at least in the benchmark). I wasn't able to test this in reality (don't have a fork of redux-vue ready).

Expected behavior

Hundreds of (closed) Dropdowns not blocking the app for seconds / hundreds of milliseconds.

Context & Screenshots (if applicable)

image
image
image
image

@spaceemotion spaceemotion added the bug Something isn't working label Dec 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant