Roudy Korkis Kanaan
09/01/2022, 3:28 AMval imageLoader = remember {
ImageLoader.Builder(context)
.bitmapFactoryMaxParallelism(10)
.respectCacheHeaders(false)
.build()
}
(I was playing around the bitmap parallelism and cache headers, I also tried providing disk/cache policies and enabling them in the ImageRequest
but it seems like Coil is quite slow to load the images after they are cached.
I tried my same code but use picasso-compose and the images load instantly (After being cached) whereas using Coil there's a split second load, I added a debugger to Coil to make sure it's not loading the image again from the internet (and it's not)
The above was on production build for both Coil and Picasso
Has anyone experience some performance issues with Coil in Compose?Colton Idle
09/01/2022, 4:29 AMColton Idle
09/01/2022, 4:30 AMColton Idle
09/01/2022, 4:32 AMColin White
09/01/2022, 4:33 AMColin White
09/01/2022, 4:34 AMRoudy Korkis Kanaan
09/01/2022, 4:34 AMColin White
09/01/2022, 4:35 AMColin White
09/01/2022, 4:36 AMColin White
09/01/2022, 4:37 AMRoudy Korkis Kanaan
09/01/2022, 4:38 AMval imageLoader = remember {
ImageLoader.Builder(context)
.bitmapFactoryMaxParallelism(10)
.respectCacheHeaders(false)
.memoryCache {
MemoryCache
.Builder(context)
.build()
}
.diskCache {
DiskCache.Builder()
.directory(context.cacheDir.resolve("image_cache"))
.build()
}
.build()
}
Roudy Korkis Kanaan
09/01/2022, 4:38 AMRoudy Korkis Kanaan
09/01/2022, 4:38 AMImageRequest.Builder(context)
.data(url)
.memoryCachePolicy(CachePolicy.ENABLED)
.diskCachePolicy(CachePolicy.ENABLED)
.allowHardware(true)
.diskCacheKey(url)
.memoryCacheKey(url)
.build()
Roudy Korkis Kanaan
09/01/2022, 4:38 AMColin White
09/01/2022, 4:39 AMRoudy Korkis Kanaan
09/01/2022, 4:40 AMRoudy Korkis Kanaan
09/01/2022, 4:45 AMColton Idle
09/01/2022, 4:45 AMRoudy Korkis Kanaan
09/01/2022, 4:46 AMColton Idle
09/01/2022, 4:46 AMAlso if you enable logging (check the faq in coil-kt.io) it’ll tell you why it’s missing
Roudy Korkis Kanaan
09/01/2022, 4:46 AMColton Idle
09/01/2022, 4:46 AMColton Idle
09/01/2022, 4:46 AMRoudy Korkis Kanaan
09/01/2022, 4:58 AMImageLoader
inside the remember
. Switching it to a single
inside my koin module fixed that.. There was a split second where the composable that hosts this one would actually be destroyed hence destroying this image loader..Roudy Korkis Kanaan
09/01/2022, 4:58 AMRoudy Korkis Kanaan
09/01/2022, 5:00 AMColton Idle
09/01/2022, 5:00 AMIt sounds like the image is missing the memory cache. Are you sharing one image loader for all your requests?
Colton Idle
09/01/2022, 5:00 AMRoudy Korkis Kanaan
09/01/2022, 5:01 AMRoudy Korkis Kanaan
09/01/2022, 5:01 AM