Skip to content

Memory test on scrolling large images quickly#46184

Merged
fluttergithubbot merged 4 commits intoflutter:masterfrom
liyuqian:local_image_test
Dec 6, 2019
Merged

Memory test on scrolling large images quickly#46184
fluttergithubbot merged 4 commits intoflutter:masterfrom
liyuqian:local_image_test

Conversation

@liyuqian
Copy link
Copy Markdown
Contributor

@liyuqian liyuqian commented Dec 5, 2019

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)

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.
@fluttergithubbot fluttergithubbot added the c: contributor-productivity Team-specific productivity, code health, technical debt. label Dec 5, 2019
@fluttergithubbot
Copy link
Copy Markdown
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.

@liyuqian liyuqian changed the title Local image test Memory test on scrolling large images quickly Dec 5, 2019
Now we can finally reproduce the issue
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;
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: a comment explaiing why we've done this as opposed to Image.asset would be helpful.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done. Thanks!

Copy link
Copy Markdown
Contributor

@dnfield dnfield left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@liyuqian liyuqian added perf: memory Performance issues related to memory c: performance Relates to speed or footprint issues (see "perf:" labels) waiting for tree to go green a: tests "flutter test", flutter_test, or one of our tests labels Dec 5, 2019
And remove the unused class.
@fluttergithubbot fluttergithubbot merged commit a2005ea into flutter:master Dec 6, 2019
@liyuqian liyuqian deleted the local_image_test branch December 6, 2019 18:18
@github-actions github-actions Bot locked as resolved and limited conversation to collaborators Aug 2, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

a: tests "flutter test", flutter_test, or one of our tests c: contributor-productivity Team-specific productivity, code health, technical debt. c: performance Relates to speed or footprint issues (see "perf:" labels) perf: memory Performance issues related to memory

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants