Intent to Implement: Impl threaded scrollbar scrolling

902 views
Skip to first unread message

Rahul Arakeri

unread,
Mar 8, 2019, 8:14:16 PM3/8/19
to blin...@chromium.org, inpu...@chromium.org, David Bokan, Sam Fortiner, Rick James, Daniel Libby, Matt Rakow

Hello blink-dev,

 

Please take a look at the attached intent to implement for Impl threaded scrollbar scrolling.

 

Quick Summary:

This proposal is to move composited scrollbar scrolling to the impl thread so that even when the main thread is busy, users can continue to interact with and scroll using scrollbars. The code will live mostly in cc.

 

Thanks,

Rahul

impl scrollbar i2i.docx

Rahul Arakeri

unread,
Mar 8, 2019, 8:51:16 PM3/8/19
to blin...@chromium.org, inpu...@chromium.org, David Bokan, Sam Fortiner, Rick James, Daniel Libby, Matt Rakow

Pasting the contents here:

 

Impl threaded scrollbar scrolling

 

Subject

Intent to implement Impl threaded composited scrollbar scrolling for MouseEvent(s).

Contact emails

ara...@microsoft.com, sam...@microsoft.com, dli...@microsoft.com, ri...@microsoft.com, mar...@microsoft.com

Design doc/spec

https://github.com/MicrosoftEdge/MSEdgeExplainers/blob/master/Scrolling/ImplScrollbars/dev-diagram.md

Summary

This proposal is to move composited scrollbar scrolling to the impl thread so that even when the main thread is busy, users can continue to interact with and scroll using scrollbars. The code will live mostly in cc.

Motivation

Scrollbar scrolling using the mouse happens on the main thread in Chromium. If the main thread is busy (due to reasons like long running JS, etc), scrolling by clicking on the scrollbar will appear to be janky as the events keep getting queued up on the MainThreadEventQueue, waiting for the main thread to free up. We observe on average scrollbar drags have ~2-4x higher latency in Chromium as compared to EdgeHTML today, worse on particularly busy sites.  We attribute this gap primarily to EdgeHTML’s feature for off-thread scrollbar drags.  By avoiding the main thread in Chromium as well, we believe we can bring the performance of scrollbar drags more in line with what we observe in EdgeHTML.

Will this feature be supported on all six Blink platforms (Windows, Mac, Linux, Chrome OS, Android, and Android WebView)?

Yes

Ongoing technical constraints

None (and this feature will be staged using a base::Feature flag)

Tracking bug

938619

Demo links

Attachment to crbug.com/938619: https://bugs.chromium.org/p/chromium/issues/attachment?aid=382732&signed_aid=sAa8q1u-nTAvDsa4W8HQvA==

Stephen Mcgruer

unread,
Mar 21, 2019, 4:57:33 PM3/21/19
to Rahul Arakeri, Ian Vollick, blin...@chromium.org, inpu...@chromium.org, David Bokan, Sam Fortiner, Rick James, Daniel Libby, Matt Rakow
Hi Rahul,

This is exciting! I would love to see more smooth scrolling in Chrome.

Ian (cc'd) and I were chatting today and were wondering if (and how) you plan to handle updating the scrollbar visuals on the compositor. If this was left to main (as it is today for wheel scrolls), then when main is busy the user could 'grab' the scrollbar and drag it, and see the contents move smoothly but the scrollbar lag behind - which might be confusing for the user.

Drawing the scrollbar on the compositor is made more complex by the various pseudo-selectors that Chrome supports. Take for example the beautiful example that is https://output.jsbin.com/tahugop - a composited scroller, but non-trivial to draw (repeating, stretching images, gradients, etc). I'm not sure if any of those pseudo-selectors can cause content that is impossible for the compositor to draw, but certainly could be tricky! :)

Thanks,
Stephen

--
You received this message because you are subscribed to the Google Groups "blink-dev" group.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/blink-dev/BYAPR21MB127109AF1E81EAAB8A3CA9DDA64E0%40BYAPR21MB1271.namprd21.prod.outlook.com.

David Bokan

unread,
Mar 21, 2019, 5:42:29 PM3/21/19
to Stephen Mcgruer, Rahul Arakeri, Ian Vollick, blin...@chromium.org, inpu...@chromium.org, Sam Fortiner, Rick James, Daniel Libby, Matt Rakow
I can speak to this as I've been working with Rahul on the design.

The design as stated will work only on composited scrollers. If the scroller is uncomposited, we don't get a cc::Layer for it nor its scrollbars so there's nothing for us to grab there. The goal here is to allow composited scrollers to scroll on the compositor thread when manipulating scrollbars; today we fallback to main as that's where the mouse event handling code lives. We have no plan (here) to make main thread scrollers scroll off the compositor thread somehow.

The (very) long term plan is a combination of scroll unification (removing gesture handling from blink) and raster-inducing scroll.

With scroll unification, CC will "know" about _all_ scrollers, even uncomposited ones. This means, given enough information/rects from Blink, we can find and mutate an uncomposited ScrollNode in Blink and force a commit. This won't provide (significant) performance improvements on its own, but it does remove all the code duplication that exists today.

However, if we then add raster-inducing scroll (and composite after paint, which is a pre-req), it will allow us to reraster already painted scrolling contents without going back to Blink. I believe most of the reasons we have to force main thread scrolling today is paint-order (bad compositing decisions) and raster-related reasons. Once we have all these pieces in place, we should be able to perform scrolling off the main thread in most (all?) cases. 

Stephen Mcgruer

unread,
Mar 22, 2019, 10:51:50 AM3/22/19
to David Bokan, Rahul Arakeri, Ian Vollick, blin...@chromium.org, inpu...@chromium.org, Sam Fortiner, Rick James, Daniel Libby, Matt Rakow
Thanks for the thorough answer David, sgtm.

One minor nit: we should be careful about terminology. The scroller in my lovely cat example is composited (in my eyes); there are layers for the contents, the scrollbars, and the scroll corner (on Linux)*. It also has composited wheel scrolling, so scrolling the contents will be smooth under main thread jank. What is 'wrong' is that the compositor is unable to render the scrollbar thumb or the tracks without main-thread involvement. I don't think there's any succinct way to describe this, but maybe I'm just not up to date on terminology :D.

* Fun fact: on an example where the compositor *is* able to move the scrollbar today without the main thread involvement (https://output.jsbin.com/marimex/3, on Linux again), there are only two layers - the contents and the scroll corner. Layering is fun.

Adrienne Walker

unread,
Mar 22, 2019, 1:49:02 PM3/22/19
to Stephen Mcgruer, David Bokan, Rahul Arakeri, Ian Vollick, blin...@chromium.org, inpu...@chromium.org, Sam Fortiner, Rick James, Daniel Libby, Matt Rakow
cc has three different kinds of scrollbars that it deals with, all are subclasses of ScrollbarLayerInterface.  All three of these types of scrollbars update on the compositor thread with respect to the current scroll position.  The "painted" scrollbar types have two resources, track and thumb, and moving the scroller adjusts the position of the thumb in the track.  There's also solid color scrollbars that we draw directly.  Even though they emit multiple quads, all scrollbar layers are still a single layer with respect to cc.

Themed scrollbars can't be represented as just a track and a thumb (as you can do things like color one side of the track differently than the other, etc) and so they behave like normal content on the page.  Such scrollbars don't update scroll positions on the compositor thread, but they might still be a composited (PictureLayer) themselves.  We raster the bitmaps for the painted scrollbar resources all on the main thread and that's why we can't update these scrollbars when they scroll.

Rahul Arakeri

unread,
Mar 25, 2019, 1:46:38 PM3/25/19
to Adrienne Walker, Stephen Mcgruer, David Bokan, Ian Vollick, blin...@chromium.org, inpu...@chromium.org, Sam Fortiner, Rick James, Daniel Libby, Matt Rakow

Thanks for all your inputs :)

 

As David rightly said, this intent is scoped to handling composited scrollbars only. We have a CL up for handling mouse clicks on composited scrollbar arrows and are currently working out the specifics of other composited scrollbar mouse interactions (like thumb drag, keeping the mouse pressed on the arrows/track etc).

Rahul Arakeri

unread,
Apr 19, 2019, 1:48:52 PM4/19/19
to Adrienne Walker, Stephen Mcgruer, David Bokan, Ian Vollick, blin...@chromium.org, inpu...@chromium.org, Sam Fortiner, Rick James, Daniel Libby, Matt Rakow, Bogdan Brinza

Hi everyone,

 

Quick update. A couple of days ago, we landed a changelist which enables support for compositor threaded scrollbar scrolling using arrows (for now).

Chrome Canary (75.0.3769.0 and higher) should have the change. You can use this test page for reference: https://rahul8805.github.io/DemoPages/main_thread_jank.html

Thanks to all the code reviewers !

 

In the coming days, we’ll keep adding more functionality to it 😊

 

Thanks,

Rahul

Rahul Arakeri

unread,
May 13, 2019, 5:42:47 PM5/13/19
to Adrienne Walker, Stephen Mcgruer, David Bokan, Ian Vollick, blin...@chromium.org, inpu...@chromium.org, Sam Fortiner, Daniel Libby, Bogdan Brinza

Updates:

 

More functionality (+a couple of bug fixes) has been added. Scrollbar thumb drag on the compositor thread is now supported (landed last week). Those interested in checking it out, please feel free to use this demo page.

 

We’re continuing to add more functionality. Continuous-scrolling (for when you click and hold the scrollbar arrow) is currently being prototyped. Thank you for all the advice and code review feedback. 😊

Rahul Arakeri

unread,
Jul 8, 2019, 4:25:44 PM7/8/19
to blin...@chromium.org, inpu...@chromium.org, Daniel Libby

Update:

 

We’ve merged a couple of changelists that enable autoscrolling (for both, arrow and track). Please feel free to check it out using this demo page. There are still outstanding bugs that are currently being worked on.

 

Thanks to the code reviewers ! If you have any questions, please don’t hesitate to reach out 😊

 

Thanks,

Rahul Arakeri

Rahul Arakeri

unread,
Sep 3, 2019, 2:38:13 PM9/3/19
to blin...@chromium.org, inpu...@chromium.org

More updates:

 

Improvements to smooth autoscrolling (like infinite autoscrolling) and thumb dragging (like anchoring) have now been merged. Please feel free to check it out 😊

Demo page: https://rahul8805.github.io/DemoPages/main_thread_jank.html

 

PS :

(Based on a Slack discussion with David Bokan about the scope).

Please note that thumb invalidation (i.e changing the color of the thumb on hover on/off) and custom scrollbars scrolling will still happen on the main thread. These need additional work and are currently out of scope for the composited scrollbar scrolling.

Luciano Pacheco

unread,
Sep 4, 2019, 12:33:17 AM9/4/19
to blink-dev, inpu...@chromium.org
Hi, 

I've just got a weird scroll behaviour on Chrome Dev channel:  crbug.com/1000547

It leaves a rendering trace from the scroll bar from a <iframe> when scrolling the main window see the screencast below:

Sharing here in case it's related.

Cheers.


On Wednesday, September 4, 2019 at 4:38:13 AM UTC+10, Rahul Arakeri wrote:

More updates:

 

Improvements to smooth autoscrolling (like infinite autoscrolling) and thumb dragging (like anchoring) have now been merged. Please feel free to check it out 😊

Demo page: https://rahul8805.github.io/DemoPages/main_thread_jank.html

 

PS :

(Based on a Slack discussion with David Bokan about the scope).

Please note that thumb invalidation (i.e changing the color of the thumb on hover on/off) and custom scrollbars scrolling will still happen on the main thread. These need additional work and are currently out of scope for the composited scrollbar scrolling.

 

Thanks,

Rahul


[....] 

David Bokan

unread,
Sep 4, 2019, 8:57:46 AM9/4/19
to Luciano Pacheco, blink-dev, input-dev
That looks like a graphical glitch so I don't expect it would be related to the new scrollbar handler code. Will follow-up in the bug.

ara...@microsoft.com

unread,
Oct 2, 2019, 5:26:04 PM10/2/19
to blink-dev
September update. The following were implemented:

- Autoscroll play/pause.
- Fixes for jittery thumb drag.
- Shift + click on scrollbar
- Thumb snapping.

As always, please feel free to try these out on the latest Chrome Canary using this demo page:

Thanks,
Rahul

Rahul Arakeri

unread,
Nov 21, 2019, 12:16:37 PM11/21/19
to blink-dev
Time for another update !

October was focused mostly on Mac:
- Fixed hit testing bugs that enabled clicking on the track.
- Implemented Option + click on scrollbar track (i.e non-animated jump)
- Fixed bugs related to device scale factor.
- Fixed flaky tests.
- Started cleaning up tests and prepping them for re-enabling.

Lightning talk about the feature: https://www.youtube.com/watch?v=FOCHCuGA_MA&t=1150s

Thanks,
Rahul

Rahul Arakeri

unread,
Feb 28, 2020, 1:08:12 PM2/28/20
to blink-dev
Hi everyone,

After a bunch of work, compositor threaded scrollbar scrolling is finally on by default in chromium master. Today’s Chrome canary (82.0.4072.0) has it ON. Thanks to all those who helped and guided me along the way. This will be a perf win for scrolling on chromium based browsers and takes us all one step closer towards scrolling unification. 😃


Please feel free to reach out to me if you have any questions.
Rahul Arakeri: ara...@microsoft.com

Additional info:
 

Example of scrollbar drag when main thread is busy:

 

FEATURE OFF

Histogram: Event.Latency.ScrollUpdate.Scrollbar.TimeToScrollUpdateSwapBegin4 recorded 19 samples, mean = 240325.4 (flags = 0x41)

0       ...

109350  ----O                                                                     (1 = 5.3%) {0.0%}

126669  ...

169971  ----O                                                                     (1 = 5.3%) {5.3%}

196891  O                                                                         (0 = 0.0%) {10.5%}

228075  ------------------------------------------------------------------------O (17 = 89.5%) {10.5%}

264198  ...

 

FEATURE ON

Histogram: Event.Latency.ScrollUpdate.Scrollbar.TimeToScrollUpdateSwapBegin4 recorded 58 samples, mean = 14517.3 (flags = 0x41)

0      ...

10403  -----------------------------------------------O                          (11 = 19.0%) {0.0%}

12051  -----------------------------------------------------------O              (14 = 24.1%) {19.0%}

13960  ------------------------------------------------------------------------O (17 = 29.3%) {43.1%}

16171  -----------------------------------------------------------O              (14 = 24.1%) {72.4%}

18732  --------O                                                                 (2 = 3.4%) {96.6%}

21699  ...


Thanks,
Rahul

Chris Harrelson

unread,
Feb 28, 2020, 1:49:40 PM2/28/20
to Rahul Arakeri, blink-dev
Excellent work! These performance numbers look amazing.

--
You received this message because you are subscribed to the Google Groups "blink-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to blink-dev+...@chromium.org.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/blink-dev/9a0cd072-7533-4aef-b590-b6d2a383fa18%40chromium.org.
Reply all
Reply to author
Forward
0 new messages