UI discussion: verticalScrollToTrack

45 views
Skip to first unread message

kk-wang

unread,
Feb 5, 2025, 11:03:05 PMFeb 5
to Perfetto Development - www.perfetto.dev
I added a track using a UI plugin. When I click a button, I want to scroll to that track. I found that there's a capability to achieve this by using `ScrollHelper` in the `ui/src/core/scroll_helper.ts` file.

However, I encountered a problem: after scrolling, the track is only partially visible on the screen. I want the entire track to be displayed.

I searched the source code and found the `verticalScrollToTrack` method, which currently uses:
element.scrollIntoView({behavior: 'smooth', block: 'nearest'});
I am considering whether it would be better to use `block: 'center'` instead of `block: 'nearest'` in order to ensure the entire track is in view.

Steve Golton

unread,
Feb 6, 2025, 3:53:44 AMFeb 6
to Perfetto Development - www.perfetto.dev
Hello, and thanks for the suggestion.

TBH I think that would be an excellent idea. I've been thinking the same for a while now but never got around to doing anything about it.

I'll have a CL out shortly and it'll be available on the autopush channel shortly after that.

Steve Golton

unread,
Feb 6, 2025, 10:09:13 AMFeb 6
to Perfetto Development - www.perfetto.dev
This has landed in https://android-review.googlesource.com/c/platform/external/perfetto/+/3477720 and is available now on the autopush channel.

kk-wang

unread,
Feb 18, 2025, 5:09:34 AMFeb 18
to Perfetto Development - www.perfetto.dev
Hello,

I've noticed that the CL has been reverted. The reason given for the revert was: "Using mode 'center' means that the track is always centered on the screen even if the track is already visible, which can be annoying. Using scroll-margin-top is the correct approach."

In my opinion, when people use 'verticalScrollToTrack', they are generally focused on seeing the track clearly on their screen. If the track is positioned towards the bottom of the screen and is already visible, there may be no scrolling response after invoking 'verticalScrollToTrack'. In such scenarios, it might be difficult for users to notice the track because there is no movement to draw their attention to it. This could potentially lead to user confusion or dissatisfaction as they might not realize that the track they are looking for is already in view.

I appreciate your consideration of this viewpoint and look forward to your response.

Thank you.

Steve Golton

unread,
Feb 19, 2025, 6:28:44 AMFeb 19
to Perfetto Development - www.perfetto.dev
I think this is a bit of a gray area, and verticalScrollToTrack is possibly a little overused.

I'd say folks use verticalScrollToTrack for the following reasons:
1. Ensure a track is visible in the viewport.
2. Draw attention to a given track / event.

I suspect the current behavior is best for 1. When selecting slices using various navigation tools such as the '<', '>' hotkeys, we want to make sure the track that the selected event is on is scrolled into view. We don't want to always move it to the center. In fact I'd argue we want to minimize scrolling at all costs in this case, and avoid moving the viewport unless necessary.

For 2, I'd suggest that relying on centering/movement is a fool's errand. If the track is at the top or bottom of the list of tracks for example, we cannot center it anyway and the viewport might not even move at all. I'd suggest the correct solution is to instead make the track/selected event highlight more noticeable. Admittedly, the black outline for event highlighting doesn't stand out as much as it should.

kk-wang

unread,
Feb 20, 2025, 9:30:43 PMFeb 20
to Perfetto Development - www.perfetto.dev
I completely understand your concern. Perhaps I should implement my `verticalScrollToTrack` for my top track.

Thank you for your reply.
Reply all
Reply to author
Forward
0 new messages