Memory test on scrolling large images quickly#46184
Merged
fluttergithubbot merged 4 commits intoflutter:masterfrom Dec 6, 2019
Merged
Memory test on scrolling large images quickly#46184fluttergithubbot merged 4 commits intoflutter:masterfrom
fluttergithubbot merged 4 commits intoflutter:masterfrom
Conversation
For flutter#19558 This test reveals the issue that Flutter currently retains as much as 200MB memory after scrolling. (200MB can further grow if we scroll more times). There should be plenty of time for the GC to clean such memory.
Contributor
|
It looks like this pull request may not have tests. Please make sure to add tests before merging. If you need an exemption to this rule, contact Hixie. Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing. |
Now we can finally reproduce the issue
b21cd67 to
fba51a9
Compare
dnfield
reviewed
Dec 5, 2019
Comment on lines
+26
to
+64
| class DummyImage extends StatelessWidget { | ||
| DummyImage(this.index) : super(key: ValueKey<int>(index)); | ||
|
|
||
| @override | ||
| Widget build(BuildContext context) { | ||
| final Future<ByteData> pngData = _getPngData(context); | ||
|
|
||
| return FutureBuilder<ByteData>( | ||
| future: pngData, | ||
| builder: (BuildContext context, AsyncSnapshot<ByteData> snapshot) { | ||
| return snapshot.data == null | ||
| ? Container() | ||
| : Image.memory(snapshot.data.buffer.asUint8List()); | ||
| }, | ||
| ); | ||
| } | ||
|
|
||
| final int index; | ||
|
|
||
| Future<ByteData> _getPngData(BuildContext context) async { | ||
| return DefaultAssetBundle.of(context).load('assets/999x1000.png'); | ||
| } | ||
| } | ||
|
|
||
| class ImagePainter extends CustomPainter { | ||
| ImagePainter(this.image); | ||
|
|
||
| @override | ||
| void paint(Canvas canvas, Size size) { | ||
| canvas.drawImage(image, Offset.zero, Paint()); | ||
| } | ||
|
|
||
| @override | ||
| bool shouldRepaint(CustomPainter oldDelegate) { | ||
| return false; | ||
| } | ||
|
|
||
| final ui.Image image; | ||
| } |
Contributor
There was a problem hiding this comment.
nit: a comment explaiing why we've done this as opposed to Image.asset would be helpful.
And remove the unused class.
979b432 to
64395d4
Compare
This was referenced Mar 10, 2020
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.
For #19558
This test reveals the issue that Flutter currently retains as much as
500MB memory after scrolling. (500MB can further grow if we scroll more
times). There should be plenty of time for the GC to clean such memory.
We've identified the issue to be in the IO thread: #19558 (comment)