coil
coil copied to clipboard
[Coil 3] Consider replacing coil internal LruCache with androidx one
Now that androidx collection 1.4.0 is released and KMP ready, LruCache is stable
https://developer.android.com/jetpack/androidx/releases/collection#1.4.0
https://github.com/coil-kt/coil/blob/eded350a4a1a197b61eaf5a119075ee3ec699889/coil-core/src/commonMain/kotlin/coil3/util/LruCache.kt#L7
Compose depends androidx collection anyway, so it will not introduce extra dependency.
Nice! I didn't think they were planning to support Js/Wasm, but agreed if Compose Multiplatform uses it we should too.
The only downside to this is we limit our memory cache max size to the size of signed int, which is ~2GB. This almost certainly isn't an issue for mobile apps, but it could be a limit for desktop. That said, it's likely still worth it to replace our custom implementation.
On second thought this might not be the best idea since it locks us into a max ~2GB memory cache size as mentioned previously. This could be a real limitation for image-heavy desktop apps. androidx's LruCache also has built in synchronization and locking, which we don't need.
It looks like androidx.collection.LruCache doesn't publish versions for JS and wasmJs either unfortunately.
Given these limitations I think it makes sense to keep Coil's custom LruCache. It's small (<100 lines) so it should be fairly easy to maintain.