-
-
Notifications
You must be signed in to change notification settings - Fork 63
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
Avoid flushSync on reverse lists / allow "starting at bottom" #628
Comments
Hi, thank you for raising this issue. Currently flushSync has 2 purposes, to reduce blank screen on huge scroll Line 304 in 5d5ef07
and to avoid layout shift on resize, especially when scrolling up. Line 390 in 5d5ef07
They might be overused. We can remove some of them if we doesn't see any visual difference after removing it (and E2Es should be passed). Maybe |
I've been testing removing it, but unfortunately I can't get the reverse list to scroll to the bottom without it consistently, even if i add various delays and re-call scrollToIndex a few times, it seems to never be fully accurate. I'll have to check into a more precise change. We have content that sometimes is very tall or short which probably doesn't help. |
Hm actually my problem goes deeper, it seems reverse mode doesn't load the last messages until after you call scrollToBottom, but then they load and change size and that means I need to retry scrolling to the bottom. Seems a better strategy would be to load the last messages up-front for reverse. |
Thanks for the report. I'll look into it myself when I have a time.
It seems like a similar issue to #415 . Maybe we need a new prop for initial scroll on mount, or should defer initial render when scrollToIndex is called on mount (inside of useLayoutEffect? not sure it's possible). |
So first I just love virtua it works wonderfully well.
I've been profiling my app a bit and found that the flushSync calls during intiial render are really hurting performance though.
Some of it just seems to happen on it's own, but a good chunk comes from needing to scrollToIndex because its reversed.
I'd be happy to help contribute here, but would like to find a way to get rid of as many flushSync as possible.
The text was updated successfully, but these errors were encountered: