Repository navigation
Fix LRUness of ScrollAwareImageProvider - #50242
Merged
Merged
Conversation
goderbauer
approved these changes
Feb 6, 2020
| // the image we want before getting to this method. We should avoid calling | ||
| // load again, but still update the image cache with LRU information. | ||
| if (stream.completer != null) { | ||
| PaintingBinding.instance.imageCache.putIfAbsent( |
Member
There was a problem hiding this comment.
Maybe assert after this that it returned stream.completer as expected?
Contributor
Author
|
The tree is not red, manually checked - we're having issues with cocoon right now when it tries to check status. Landing. |
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
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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
#49389 introduced a subtle bug where, if an image got precached while you are scrolling fast, the scrolling image provider would not update the ImageCache's LRU information. The test for this is very highly constructed to push this, as it would be very hard to do this in a real application. I actually discovered this while working through a solution for #49456, where this will become more important, but it's fixable by itself so I'm splitting it out.
Related Issues
The two linked bugs above.
Tests
I added the following tests:
A test that precaches an image while scrolling fast, and then observes that our image overwrites it in the cache (cache size = 1) once it completes, still while scrolling fast. This test is highly constructed, and would be very difficult to achieve in a real application without writing custom image providers.
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
Did any tests fail when you ran them? Please read Handling breaking changes.