devtools icon indicating copy to clipboard operation
devtools copied to clipboard

Flame chart - jumpTo called before scroll position offsets have new size

Open kenzieschmoll opened this issue 5 years ago • 7 comments

In flame_chart.dart, we call

linkedHorizontalScrollControllerGroup.jumpTo(newScrollOffset);

to update the scroll offset as we zoom. We call this inside of an animation controller listener zoomController.addListener(() { ... }). At times when we call this, scrollController.position.maxScrollOffset is not updated for the new zoom level and layout size, causing jumpTo to fire BallisticScrollActivities to bounce the scroll offset back to what it thinks is the maxScrollOffset.

We need to have a way to call jumpTo when we can guarantee that the min / max scroll offsets are updated for the new zoom value.

I attempted to set these offsets manually using scrollController.position.applyContentDimensions(minScrollOffset, maxScrollOffset) but this results in an error regarding gesture detectors: The replaceGestureRecognizers() method can only be called during the layout phase.

kenzieschmoll avatar May 29 '20 17:05 kenzieschmoll

@dnfield @HansMuller for any ideas on how to workaround this.

kenzieschmoll avatar May 29 '20 17:05 kenzieschmoll

/cc @dkwingsmt who may know about the gesture recognizer interaction(s).

dnfield avatar May 29 '20 17:05 dnfield

Some more speculation on this from https://github.com/flutter/devtools/pull/2808#discussion_r595362000

"Perhaps we need a custom scroll controller class that lets us update its extent immediately based on the new size to avoid all these annoying edge cases?"

kenzieschmoll avatar Mar 16 '21 17:03 kenzieschmoll

Some updated code links here: The call to update the horizontal scroll position where the position.maxScrollExtent may not have been updated for the new size of the scroll controller (size changes as the flame chart zooms in and out via an animation controller): https://github.com/flutter/devtools/blob/master/packages/devtools_app/lib/src/charts/flame_chart.dart#L460

Here we are forced to use a post frame callback to ensure that the maxScrollExtent has been updated for the new zoom level after we zoom: https://github.com/flutter/devtools/blob/master/packages/devtools_app/lib/src/charts/flame_chart.dart#L543-L551

cc @Piinks

kenzieschmoll avatar Apr 16 '21 16:04 kenzieschmoll

Thanks for the update! I think the primary issue here is that the Scrollable is being manipulated and accessed at the same time. I am not sure how we can fix that, cc also @goderbauer who is looking into official support for 2D scrolling in Flutter.

Piinks avatar Apr 16 '21 17:04 Piinks

@goderbauer has there been any progress on a lazy 2D view? The scrolling issues we are experiencing in DevTools flame chart are proving very difficult to avoid.

kenzieschmoll avatar Jun 09 '21 19:06 kenzieschmoll

I've been digging into this and I think it is close to being resolved. I have found what is causing the issue for the select-zoom-scroll functionality (https://github.com/kenzieschmoll/devtools/pull/2), and am currently looking into the pointerScroll-zoom-scroll jumpiness.

Piinks avatar Jun 14 '21 21:06 Piinks