Hi,
I have a strange performance issue on my app on both simulators (iOS and Android). I am displaying 6 times the same image from the network. Images are not big and they load quite fast.
The CPU usage of the app (Runner.app & qemu-system-i386) goes up and stay at at least 100% CPU and the usage stays like this forever.
My app has a refresh (reloads a JSON than trigger a rebuild of my list with the 6 items) and when I hit the refresh, the CPU goes back to normal (around 0.5-2%).
I tried a simple test by replacing the CachedNetworkImage with a simple Placeholder widget, I don't have this issue at all.
As soon as I replace it back with a CachedNetworkImage wdiget, I get the high CPU usage until I do a refresh, and then it all goes smoothly.
I am using cached_network: ^1.0.0 version with Flutter stable 1.7.8.
Any idea what could produce this ?
I am investigating this issue. Not sure where it is coming from.
Thanks!
Here is the code snippet I am using for displaying the image :
@override
Widget build(BuildContext context) {
return CachedNetworkImage(
imageUrl: imageUrl,
placeholder: (_, url) => Container(
width: width,
height: height,
child: Center(
child: CircularProgressIndicator(),
),
),
fit: BoxFit.cover,
width: width,
height: height,
errorWidget: (_, url, error) => Container(),
);
}
Maybe a hint:
I've noticed that the CircularProgressIndicator widget is a very CPU intensive widget (especially in debug mode).
So if the placeholder widget is not disposed correctly when the image is loaded & displayed, that might explained the CPU hogs as I might have 6 progress indicators still animating somehow.
The rebuild probably don't use the placeholders since the images are restored from cache...
What do you think ?
That seems to be the problem indeed. Pull request #194 seems to fix this (among with the better animation), so it will probably be better in the next version.
@renefloor I've tried with the master branch, and I confirm that this PR has fixed my issue! 馃憤
Any idea when you'll release a new version of the package?
Yes, released it Saturday (1.1.0)
Most helpful comment
@renefloor I've tried with the master branch, and I confirm that this PR has fixed my issue! 馃憤
Any idea when you'll release a new version of the package?