When attaching the itemCount of a ScrollablePositionedList.builder to a StreamBuilder and using WidgetsBinding.instance.addPostFrameCallback() to scroll to the new items, the performance is very glitchy. The scrolling has a double bounce effect, is jerky and sometimes momentarily displays the wrong content. Under stress - many items per second - it's even more glitchy. By contrast, the AnimatedList scrolling is very smooth if it directly takes the place of the ScrollablePositionedList. My use case is a chat message list which could be 1000s of messages in total, but obviously ScrollablePositionedList only requests those for display.
Notice how it displays 2 items without rebuilding the list, and every item thereafter refreshes the entire list on screen. The README gives some instructions on playing with the demo. If it is a bug, and you think you've fixed it, please stress the list out more by firing more messages in a shorter period to see how the scroll performance is affected.
It also seems to be requesting way more items than necessary - i.e. calls to itemBuilder().
Expected behavior
Smooth scrolling, with no jerkiness / refresh / double bounce. Calculated use of itemBuilder()
Actual behavior
Jerkiness / refresh / double bounce with intermittent momentary display of the wrong content. Over zealous use of itemBuilder()
Problem description
When attaching the itemCount of a ScrollablePositionedList.builder to a StreamBuilder and using WidgetsBinding.instance.addPostFrameCallback() to scroll to the new items, the performance is very glitchy. The scrolling has a double bounce effect, is jerky and sometimes momentarily displays the wrong content. Under stress - many items per second - it's even more glitchy. By contrast, the AnimatedList scrolling is very smooth if it directly takes the place of the ScrollablePositionedList. My use case is a chat message list which could be 1000s of messages in total, but obviously ScrollablePositionedList only requests those for display.
Steps to reproduce
This happens consistently. I've created an example repro here: https://github.com/PaulVipond/listglitch.git
Notice how it displays 2 items without rebuilding the list, and every item thereafter refreshes the entire list on screen. The README gives some instructions on playing with the demo. If it is a bug, and you think you've fixed it, please stress the list out more by firing more messages in a shorter period to see how the scroll performance is affected.
It also seems to be requesting way more items than necessary - i.e. calls to itemBuilder().
Expected behavior
Smooth scrolling, with no jerkiness / refresh / double bounce. Calculated use of itemBuilder()
Actual behavior
Jerkiness / refresh / double bounce with intermittent momentary display of the wrong content. Over zealous use of itemBuilder()
Environment
Testing on Windows 10 Pro, Flutter 1.22.6 • channel stable • https://github.com/flutter/flutter.git Framework • revision 9b2d32b605 (6 weeks ago) • 2021-01-22 14:36:39 -0800 Engine • revision 2f0af37152 Tools • Dart 2.10.5