Skip to content
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

iOS crashed when loading thousands Images with CachedNetworkImageProvider in Listview #970

Open
1 task
boomery opened this issue Sep 11, 2024 · 6 comments
Open
1 task

Comments

@boomery
Copy link

boomery commented Sep 11, 2024

🐛 Bug Report

Rapidly scrolling through a ListView in iOS , when i stop scrolling, the memory usage keep rising until the app crashes.

Expected behavior

The image cache usage should be kept within the restricted range.

Reproduction steps

already set the cache limit in main.dart

PaintingBinding.instance.imageCache.maximumSize = 10;
PaintingBinding.instance.imageCache.maximumSizeBytes = 1024 *1024 * 100;//MB

i've used ScrollAwareImageProvider ,set maxWidth&maxHeight for CachedNetworkImageProvider

Configuration

**Version: Flutter 3.22.2 Dart 3.4.3

Platform:

  • 📱 iOS
@boomery
Copy link
Author

boomery commented Sep 11, 2024

I printed out the values using a timer and found that while the scrolling was paused, the value of PaintingBinding.instance.imageCache.liveImageCount would keep increasing, is there anyway to limit it

@boomery
Copy link
Author

boomery commented Sep 11, 2024

It feels like all the picture widgets I've scrolled through are still being downloaded and cached, even though they are no longer displayed on the current screen, and they cannot be released, ultimately leading to a memory overflow.

@boomery
Copy link
Author

boomery commented Sep 11, 2024

WechatIMG131

When I stop scrolling Listview after a while, pendingImageCount first increases gradually and then decreases to 0. Before pendingImageCount reaches 0, the memory usage remains in an upward state. The memory usage is released entirely when pendingImageCount reaches 0 instantaneously, just as shown in the picture

@drnko
Copy link

drnko commented Dec 2, 2024

Hi,

We too are facing the same issue by loading only 10 images in a listView and the web app crashes.

The issue still persists even after resizing the images. We are using the canvaskit for rendering.
We do not want to use the 3rd party dependency storage for uploading/retrieving.

You can check it out the Web App, below on the Android/iOS/Windows browsers, except iOS everywhere the web app is working fine:

https://web.drnko.com/

Demo user mobile number: 1234567890
OTP: Enter 1234

Regards!

@VB10
Copy link

VB10 commented Dec 6, 2024

Hi
I getting same issue in my list view. Do you have any idea for this problem or any suggestion. Thank you so much. Then when i open detail page, it also crash again.

(I've improved some logical operation like mem cache size etc. It temprorary work but i think we need the beter solution for next time usage)

@ziqq
Copy link

ziqq commented Dec 13, 2024

Hello, I have this same issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants