flutter_cached_network_image icon indicating copy to clipboard operation
flutter_cached_network_image copied to clipboard

App is crashing while loading an images by using the cached network image

Open venkateshavenki opened this issue 2 years ago • 25 comments

I am using cache network image for displaying images but it is crashing every time while loading images and it is showing errors like the below.

thread https://github.com/flutter/flutter/pull/11, name = 'io.flutter.1.io', stop reason = EXC_RESOURCE RESOURCE_TYPE_MEMORY (limit=2098 MB, unused=0x0) frame #0: 0x00000001084d0e68 Fluttervoid downsample_2_2<ColorTypeFilter_8888>(void*, void const*, unsigned long, int) + 84 Flutterdownsample_2_2<ColorTypeFilter_8888>: -> 0x1084d0e68 <+84>: st1.s { v0 }[0], [x0], https://github.com/flutter/flutter/issues/4 0x1084d0e6c <+88>: subs x8, x8, #0x1 0x1084d0e70 <+92>: b.ne 0x1084d0e24 ; <+16> 0x1084d0e74 <+96>: ret Target 0: (Runner) stopped. thread https://github.com/flutter/flutter/pull/11, name = 'io.flutter.1.io', stop reason = EXC_RESOURCE RESOURCE_TYPE_MEMORY (limit=2098 MB, unused=0x0) frame #0: 0x00000002232e1aa8 libsystem_platform.dylib_platform_memmove + 88 libsystem_platform.dylib_platform_memmove: -> 0x2232e1aa8 <+88>: stnp q0, q1, [x3] 0x2232e1aac <+92>: add x3, x3, #0x20 0x2232e1ab0 <+96>: ldnp q0, q1, [x1] 0x2232e1ab4 <+100>: add x1, x1, #0x20

venkateshavenki avatar Jul 01 '22 07:07 venkateshavenki

the same as you

Hurdery avatar Jul 04 '22 07:07 Hurdery

Facing same issue.

ujjwalglostars avatar Jul 07 '22 15:07 ujjwalglostars

the same as you ,100 pictures are easier

wanghuasheng avatar Jul 29 '22 03:07 wanghuasheng

Any update on this?

jugal-k-j avatar Aug 03 '22 15:08 jugal-k-j

same here.

Arlovzki avatar Aug 22 '22 14:08 Arlovzki

I got these errors and

  • using Image widget in imageBuilder allow to avoid crash of the app on some http error during laoding
  • passing the cacheWidth and cacheHeight to the Image reduce the problem of memory by far. You should also look on the size of the images you are loading.
  • Avoid think like shrinkWrap: true or automaticKeepAlive: true for scrollviews .
  • I also see an error on this package that removes images from cache every 10 seconds that is marked as "old" (the package checks the header of the image to see if it's valid) so if the maxAge header is like NOW then the image will be erased from cache and rebuilding your widget will make another api call.

maxusr avatar Aug 22 '22 14:08 maxusr

Hi, @all even I am facing the same issue, can anyone have a proper answer? for this issue.

pavanZibtek avatar Oct 18 '22 10:10 pavanZibtek

Any update on this..?

Venkateshazibtek avatar Oct 26 '22 07:10 Venkateshazibtek

Hi @maxusr, If we use cacheWidth and cacheHeight, It will resize the image, and the image quality will go.

Venkateshazibtek avatar Oct 26 '22 07:10 Venkateshazibtek

same issue on our end, prepping for production release

parker-sherrill avatar Nov 02 '22 17:11 parker-sherrill

Hey, did anyone found a proper solution to this problem?

addet avatar Jan 19 '23 16:01 addet

I faced this issue and ended up replacing the package. The issue was due to memory leak when there's too many images to load and unload. I think the cache is not well handled (through a maxAge header for example that is NOW) causing the image to be reload everytime the widget is built rather than using only the one in cache.

mcssym avatar Jan 21 '23 17:01 mcssym

Keeps crashing for me too

esodot avatar Jan 26 '23 13:01 esodot

the same issue from our side also the crash when loading the image @BeMacized did you have any recommendation to avoid this crash ?

mahmoudalaa97 avatar Jan 29 '23 13:01 mahmoudalaa97

This image shows clearly the issue when we stop scrolling faster, the memory starts to increase until loading all images, and if it touches 2gb the app crashes. Probably there are multiple operations running for all images when we stop scrolling, even for the images that are not visible anymore.

Screen Shot 2023-01-30 at 7 30 32 PM

lubritto avatar Jan 30 '23 16:01 lubritto

Hey, did anyone found a proper solution to this problem ?????

JiyadAhammad avatar Feb 15 '23 07:02 JiyadAhammad

I'm facing the same issue.

Natnaelk avatar Feb 28 '23 04:02 Natnaelk

In my personal experience, the images in our DB were being uploaded way with a large size around 1-2MB. I was using the flutter ImagePicker plugin to store user photos and not resizing them using the plugin's maxHeight and maxWidth params. The large photos in a listview cause insane memory issues especially without pagination. Now the photos stored are never more than 50 KB and CachedNetwork image works perfectly. Been released on app store for 3 months now with no issues.

Let me know if this helps anyone!

https://apps.apple.com/us/app/circl-bring-people-together/id1610676363

Here's the app if anyone wants to check it out

parker-sherrill avatar Mar 14 '23 15:03 parker-sherrill

memory crash can try this framework https://github.com/LianjiaTech/keframe it's worked for me!

lyb5834 avatar Mar 23 '23 09:03 lyb5834

memory crash can try this framework https://github.com/LianjiaTech/keframe it's worked for me!

@lyb5834, The below link is not working. https://github.com/LianjiaTech/keframe

venkateshavenki avatar Mar 23 '23 12:03 venkateshavenki

@venkateshavenki why? i'v tried it, memory cache rising very slowly and safe

lyb5834 avatar Mar 23 '23 12:03 lyb5834

what about high res image in ios? https://github.com/flutter/flutter/issues/110331

rocksolid911 avatar Mar 23 '23 12:03 rocksolid911

same question

XDChang avatar Oct 07 '23 09:10 XDChang

@venkateshavenki why? i'v tried it, memory cache rising very slowly and safe

Hi @lyb5834, Yes it is working for low-resolution images. However, we are encountering a memory issue when dealing with high-resolution images in ios.

venkateshavenki avatar Oct 09 '23 06:10 venkateshavenki

Waiting for the big picture solution.

YoungShi avatar Nov 17 '23 07:11 YoungShi