Flame chart - jumpTo called before scroll position offsets have new size
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.
@dnfield @HansMuller for any ideas on how to workaround this.
/cc @dkwingsmt who may know about the gesture recognizer interaction(s).
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?"
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
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.
@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.
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.