question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Improved render performance while scrolling in Chrome under weird condition

See original GitHub issue

First of all, thanks for all your contributions to the community and in particular this amazing library. Second, I want to apologise in advance if this has already been noted elsewhere and I have missed it.

While creating some debug overlays to visualise the rendered item regions, I stumbled on a weird situation in Chrome (Version 80.0.3987.163) on macOS Catalina where I see improved performance if I cover the scroll region with an absolute-positioned element with pointerEvents: "none" styling:

react-window-performance

Here is a codesandbox.io link that demonstrates the situation - because react-window is so performant already, I find it’s best to break the preview off into its own window and scroll vigorously (really get those fingers flyin’) to see the flashes of empty content. Then tick on the “show overlay” checkbox at the bottom of the page and observe the difference. It’s odd, but no matter how hard I try I can’t get the flash to occur while the overlay is visible.

I’m curious if someone can enlighten me as to what might be happening here? I’ve probably neglected to think of something obvious. Are there any drawbacks you can think of if I just…keep this overlay there all the time? Thanks for your thoughts!

Issue Analytics

  • State:open
  • Created 3 years ago
  • Comments:7

github_iconTop GitHub Comments

2reactions
JavanPoiriercommented, Sep 28, 2021

Thanks @beauroberts. This was occurring only on Chrome on Mac, where list items would not show when swiping/scrolling fast and I was definitely lost as to why. Having tested a few different list library examples, this only occurred with react-virtualized and react-window out of those I tested.

2reactions
beaurobertscommented, Apr 22, 2020

Hey @olehhusiev thanks for confirming that it works for you too! I have a test environment with 10,000 items and it seems to be performing nicely also.

By “heavier-weight cell” I mean a cell that takes more time to render than the simple text cell I used in my example. When this hack is in place, you can get poor scrolling performance if the individual items are very costly. But if you have optimised the rendering of your items, it seems like this hack can lead to better perceived performance.

My colleague @woollenhat did more thorough investigation into this than I did, and discovered a couple of interesting things:

First, that the performance is actually better without the hack, as demonstrated by the two halves of the profiler output here. The left half is without the overlay hack and the right half is with the overlay hack:

Screenshot 2020-04-20 at 11 18 58

Second, he noticed that when you place the overlay over only half of the scroll container, the performance changes based on where your mouse is. That effect can be seen in this forked sandbox - scroll with the trackpad rapidly on the overlay half and you have different behaviour than when you scroll on the non-overlay half. So it is related to the element the mouse is over at the time of scrolling, maybe?

Screenshot 2020-04-20 at 11 21 07

He realised that scrolling over the overlay seems to enable a different scroll mode, as can be seen in the call trees here:

with_overlay without_overlay

Note that one is gesturescrollupdate and the other is just scroll.

He also pointed me to this article about changes to the scrolling implementation in Chrome, moving it off of the main thread.

Read more comments on GitHub >

github_iconTop Results From Across the Web

slow rendering while scrolling - Google Chrome Community
I'm scrolling via a touchpad if that matters. I see the same behavior when scrolling by grabbing the scroll bar and moving it....
Read more >
Chrome Bug - window.scroll method intercepts DOM Rendering
If you call a window scroll function, immediately after you update some DOM properties, Chrom won't fully render all your DOM modifications.
Read more >
RenderingNG: An architecture that makes and keeps Chrome ...
Yes, it seems like smooth scrolling is prioritized over low latency. On Windows I even get 3 frames (48ms) of lag (presumably because...
Read more >
Discover issues with rendering performance
Open the Rendering tab and check Scrolling Performance Issues. Observe the potentially problematic elements highlighted. Scrolling Performance ...
Read more >
Chrome Rendering Performance Issues: How to Avoid Them
Our first solution was to remove the background-attachment:fixed property, which was causing the lag when the element was not displayed (using ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found