-
Notifications
You must be signed in to change notification settings - Fork 3.6k
[two_dimensional_scrollables] optimizes tableview janks with >250k rows #10738
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[two_dimensional_scrollables] optimizes tableview janks with >250k rows #10738
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code Review
This pull request introduces a significant performance optimization for TableView when dealing with a large number of rows. The linear search for visible cells has been replaced with a more efficient binary search, which will reduce scrolling jank. The implementation of the binary search is sound and new tests have been added to ensure correctness. My feedback includes a few suggestions related to repository contribution guidelines for the CHANGELOG.md and pubspec.yaml files, as well as a minor refactoring opportunity in the new test to improve maintainability.
packages/two_dimensional_scrollables/test/table_view/table_test.dart
Outdated
Show resolved
Hide resolved
…x release version
…x release version
…x release version
Piinks
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah thank you thank you! This LGTM. I will seek a second stamp so we can get this in.
packages/two_dimensional_scrollables/test/table_view/table_test.dart
Outdated
Show resolved
Hide resolved
…x remove test code.
chunhtai
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
flutter/packages@d80c60e...9010299 2026-01-21 jhy03261997@gmail.com [batch-release] Step2 : Publish packages from the release branch (flutter/packages#10459) 2026-01-21 dpxhfxywang@163.com [two_dimensional_scrollables] optimizes tableview janks with >250k rows (flutter/packages#10738) 2026-01-21 magder@google.com [url_launcher_ios] Migrate XCTest to Swift Testing (flutter/packages#10780) 2026-01-21 edpizzi@gmail.com [in_app_purchase] Fix an issue causing StoreKit 2 transactions remain unfinished (flutter/packages#10656) 2026-01-21 stuartmorgan@google.com [google_maps_flutter] Restructure iOS to prep for SwiftPM (flutter/packages#10839) 2026-01-21 jhy03261997@gmail.com [batch-release] Step3: Adds github action to create a PR to sync changes on the go_router release branch back to the main branch (flutter/packages#10393) 2026-01-21 nateshmbhat1@gmail.com feat(ios): add audio track selection support for AVFoundation (flutter/packages#10313) 2026-01-21 49699333+dependabot[bot]@users.noreply.github.com [dependabot]: Bump androidx.core:core from 1.13.1 to 1.17.0 in /packages/image_picker/image_picker_android/android (flutter/packages#10504) 2026-01-21 38853913+AlexDochioiu@users.noreply.github.com [vector_graphics_compiler] Fix rgb/rgba color parsing to support modern CSS syntax (flutter/packages#10538) If this roll has caused a breakage, revert this CL and stop the roller using the controls here: https://autoroll.skia.org/r/flutter-packages-flutter-autoroll Please CC flutter-ecosystem@google.com on the revert to ensure that a human is aware of the problem. To file a bug in Flutter: https://github.com/flutter/flutter/issues/new/choose To report a problem with the AutoRoller itself, please file a bug: https://issues.skia.org/issues/new?component=1389291&template=1850622 Documentation for the AutoRoller is here: https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
Description:
This PR optimizes the scrolling jank issue of the TableView component when the number of rows exceeds 250,000.
Root Cause:
The _updateFirstAndLastVisibleCell method in RenderTableViewport uses linear for-loop traversal on _columnMetrics and _rowMetrics to locate the visible boundary cells: _firstNonPinnedRow, _lastNonPinnedRow, _firstNonPinnedColumn, and _lastNonPinnedColumn. When the number of rows/columns is extremely large (e.g., >250k rows), this linear traversal causes significant main-thread blocking and scrolling jank.
Solution:
Replace the linear for-loop with binary search algorithm to find the visible boundary cells (_firstNonPinnedRow, _lastNonPinnedRow, _firstNonPinnedColumn, _lastNonPinnedColumn). Binary search reduces the time complexity from O(n) to O(log n), effectively optimizing the scrolling jank issue under large data volumes.
Fixes: #138271
Video performance comparison
before:
https://github.com/user-attachments/assets/ca5b8821-4bdb-411f-bb2c-63998ac7c0d9
after:
https://github.com/user-attachments/assets/ebbf96d9-9e04-4ede-ae79-cd433885d3ab
Pre-Review Checklist
[shared_preferences]pubspec.yamlwith an appropriate new version according to the [pub versioning philosophy], or I have commented below to indicate which [version change exemption] this PR falls under[^1].CHANGELOG.mdto add a description of the change, [following repository CHANGELOG style], or I have commented below to indicate which [CHANGELOG exemption] this PR falls under[^1].///).