-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Performance degradation in onPress
#8086
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
Comments
I was worried about this but we tested before and couldn't reproduce a slowdown. Is there anything in particular about your page that could cause this? High number of Pressable elements? Which components are you using? Anything that can help us reproduce would be helpful. |
Thank you for the quick response! Yeah, in this particular case, we have over 2,000 pressables. It may seem a bit more than you might expect, but for us, it’s the perfect stress test. |
@devongovett Shouldn't the override in #8047 also be running on every render, making this degradation possibly worse? Currently the @MrFlashAccount Unfortunately I can't reproduce the degradation just by rendering 2000 Maybe it makes sense to add a |
We have the ‘<meta name=“viewport” content=“width=device-width”>’ set. Is it possible to provide an option or simply query the meta once in a provider? I can prepare a pull request to bump react-aria’s version in the meantime. However, you’d need to download an IDE and register. Also, since the product is open-source, it’s possible to explore the code. |
it’s worth noting that we have a variety of styles, and some of them may be ineffective, such as ‘.some-selector span’ and over 25,000 nodes on the page. |
@devongovett, @nwidynski , I’ve prepared a pull request (PR) where you can observe the degradation. Here’s the link: enso-org/enso#12846 To reproduce the issue, follow these steps:
Here’s the link to the job with the IDE artifacts: https://github.com/enso-org/enso/actions/runs/14442904237?pr=12846 — Here's a video how to register. CleanShot.2025-04-14.at.13.07.03.mp4Additionally, I’ve uploaded a video demonstrating the reproduction of the issue (due to its large size, it had to be uploaded to YouTube): |
@devongovett here's a codesandbox with a repro: https://codesandbox.io/p/devbox/modern-architecture-forked-5tyh5y?workspaceId=ws_FJECc2QX6MEMWWYxSwGxqp Hope this helps! |
You might need to add permissions for that code sandbox. I can't see it. |
Oh, I apologize for any inconvenience caused. Hope now it works! |
@MrFlashAccount Thanks for the repro 👍 While I can observe the forced reflow now, on my machine, the |
That's a lot, don't you think? |
As @nwidynski mentioned, we could potentially try inserting a CSS rule for this and see if that helps. It would need to be in the lowest CSS <style>
@layer {
:where([data-react-aria-pressable]) {
touch-action: pan-x pan-y pinch-zoom;
}
}
</style> If this rule is inserted at the start of the |
I think ':where' + putting this as the topmost style tag might be enough |
@uncvrd Yeah, it appears to be the same issue. You can try setting .react-aria-Cell {
touch-action: pan-x pan-y pinch-zoom;
} or possibly even globally, depending on your circumstances html {
touch-action: pan-x pan-y pinch-zoom;
} See https://developer.chrome.com/blog/300ms-tap-delay-gone-away for more info. |
Unfortunately this won't help, because the slowest part is the 'getComputedStyles' which is executed in either case. |
yea agreed, it did help a little bit but most of the performance hit comes from the |
It seems tailwind significantly slows down the style recalculation step: https://www.developerway.com/posts/tailwind-vs-linaria-performance So the 'gcs' significantly affects the projects with tailwind |
Provide a general summary of the issue here
After updating
react-aria-components
to the latest version (1.8.0) we faced a significant performance degradation, increasing passiveMountOnFiber duration from roughly 200ms to 1.8s(!)After digging into the issue we found that the root cause is in
usePress
hook: https://github.com/adobe/react-spectrum/blob/main/packages/%40react-aria/interactions/src/usePress.ts#L821 caused by: #8047Here's a recording from chrome devtools:
Trace-20250412T155902.json
Here's a screenshot, you can see that
usePress
schedules over 2000 style recalculations.🤔 Expected Behavior?
😯 Current Behavior
💁 Possible Solution
🔦 Context
🖥️ Steps to Reproduce
Version
1.8.0
What browsers are you seeing the problem on?
Chrome
If other, please specify.
No response
What operating system are you using?
MacOS
🧢 Your Company/Team
No response
🕷 Tracking Issue
No response
The text was updated successfully, but these errors were encountered: