-
Notifications
You must be signed in to change notification settings - Fork 29.8k
Re-Land of HighlightMode change with benchmark improvements. #39589
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
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1279f6c to
5529f9f
Compare
5529f9f to
77b92ec
Compare
9 tasks
goderbauer
reviewed
Sep 3, 2019
This re-lands the highlight mode change.
77b92ec to
96c4170
Compare
goderbauer
approved these changes
Sep 3, 2019
Member
goderbauer
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
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Labels
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
This re-lands my automatic focus highlight mode change that was reverted in #38866, and originally introduced in #37825.
The original caused a regression in the gallery transition performance benchmark. I tracked this down to adding and removing listeners (mostly removing) in the
ObserverListthat it used to track the listeners. I tried a number of things, but what it comes down to is thatObserverListis only efficient for small numbers of observers, and with the highlight mode change, it was getting hundreds of observers (even if they weren't being notified very often).This adds a new
HashedObserverListclass that is based on a hash map that reference-counts the observer callbacks, and only notifies once for each callback. This can't be used in place ofObserverListinChangeNotifier(the main use ofObserverList) because it makes things slower.For small numbers of observers, the O(N) behavior of the remove method on
ObserverListis not a problem, but because the constant for adding an item to a hash map is larger than the constant of appending an item to a small list, it would slow things down overall to use a HashMap for everything. It also would change the notification semantics, but internal Google tests indicate that that is not a problem, as most observers don't assume an order.Also fixed two memory leaks that @ds84182 found in #38767.
Related Issues
#38860
Tests
ObserverListandHashedObserverList.Checklist
Before you create this PR confirm that it meets all requirements listed below by checking the relevant checkboxes (
[x]). This will ensure a smooth and quick review process.///).flutter analyze --flutter-repo) does not report any problems on my PR.Breaking Change
Does your PR require Flutter developers to manually update their apps to accommodate your change?