-
Notifications
You must be signed in to change notification settings - Fork 30.1k
Description
codec.cc tries to cache as many of the decoded animated image frames in memory as possible, up to a ratio based on the size of the original image. This saves the CPU/battery that would be used to decode the frames on subsequent loops of the image but isn't strictly necessary, takes up a large amount of memory, and has caused multiple bugs in the past based on flutter apps using too much memory. Even with the ratio and various memory fixes in place it's still possible for Flutter apps to crash with OOM exceptions playing animated images if the code doesn't lower the ratio to 1.0 manually (effectively disabling the cache) and try to display multiple large images at once.
Moving forward it would be better to just remove the bonus cache entirely. This does introduce a regression on the CPU/battery side for the case of apps that are displaying a single small image with just a few frames, but that tradeoff is probably better than the occasional OOM crashes we have now.
Some of the previous issues and discussion around the memory issues with the decoded cache:
- Displaying multiple large GIFs causes out of memory exception #14344
- Animated gif is causing my App to crash on some Android devices and iOS 12. Seems fine on iOS 11 and below. #20998
- Add a ratio cap to decoded animated image frames engine#6310
- OOM crashes still possible for GIFs with a high number of required frames #24835
- Only overflow the cache for one required frame engine#7048
/cc @amirh