coil-kt / coil

Image loading for Android and Compose Multiplatform.

Home Page:https://coil-kt.github.io/coil/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Support in-memory caching for non-bitmap drawables.

colinrtwhite opened this issue · comments

Is your feature request related to a problem? Please describe.
Coil's memory cache currently only supports storing Bitmaps. Notably, animated drawables (e.g. AnimatedImageDrawable and MovieDrawable) cannot be stored in the MemoryCache and must be re-decoded for each new image request.

Describe the solution you'd like
Support storing non-bitmap Drawables in MemoryCache.

Additional context
Any solution will likely have to be opt-in since unlike (immutable) Bitmaps, which can be used by multiple targets at the same time, animated drawables are often stateful and can't be used by multiple targets at the same time. This mean we need to remove the drawable from the memory cache when it's in-use and only re-add it once the Target finishes using it. Additionally, parameters like AnimationCallbacks and other listeners will have to be added to the memory cache key.

Would this issue also add support for AnimatedSVGs in AsyncImage with the SVGDecoder?

Any update on this?

commented

Support storing NinePatchDrawable in MemoryCache