Coil Vs Glide

Singhparakram
HealthifyMe Tech
Published in
3 min readDec 27, 2021

In this article, we will do a comparison between Glide and Coil and make an understanding about which one is better right now.

Glide is a fast and efficient open-source image loading framework for Android which a large number of people are using, whereas Coil is a new library that is gaining popularity these days. Basic functionalities for both the libraries are the same; they both use BitmapFactory to decode the data and use the same Android SDK APIs to read data from the file.

So why is its popularity increasing and how is it different from glide?

It is the only image loading library that is backed by Kotlin Coroutine. It is using libraries like Coroutines, OkHttp, Okio, AndroidX Lifecycles which are already being used in the android project, thus making it lightweight. But to choose which one is good, we have to compare their performance.

How can we compare performance?

I have created two small projects using Glide in one and Coil in the other respectively. This is a simple project which loads five images and sets them in a grid recyclerView. With these projects, we are comparing the image loading speed of each library.

This article is based on the current latest version of Glide and Coil for analysis

For Coil:

implementation("io.coil-kt:coil:1.4.0")

For Glide:

implementation 'com.github.bumptech.glide:glide:4.12.0'

Code to load image and calculate loading time:

For Glide :

fun ImageView.loadImage(url: String, context: Context, position: Int) {
val t = System.currentTimeMillis()
Glide.with(context).load(url).placeholder(R.drawable.ic_launcher_background).into(object : CustomTarget<Drawable>() {
override fun onLoadCleared(placeholder: Drawable?) {
}
override fun onResourceReady(resource: Drawable, transition: Transition<in Drawable>?) {
this@loadImage.setImageDrawable(resource)
Log.d("LoadImage", "$position ${System.currentTimeMillis()-t}")
}
})
}

For Coil :

private fun ImageView.loadImage(url: String, position: Int) {
val t = System.currentTimeMillis()
this.load(url) {
target { drawable ->
this@loadImage.setImageDrawable(drawable)
Log.d("LoadImage", "$position ${System.currentTimeMillis()-t}")
}
}
}

Below are the graphs that tell the time taken to load the image in recyclerView.

To make the test more accurate, we ran the app five times, and then we took the average of each value.

These tests are done on the 4G network device.

There are two tests one with small size images and one with large size:

With Small size images:

When images are loaded for the first time:

When images are loaded from cache:

With Large size images:

When images are loaded for the first time:

When images are loaded from cache:

From these results, for now, in terms of performance Glide is comparatively faster than Coil but if you have used Jetpack, Kotlin Coroutines, OkHttp in your project, then Coil will be more suitable for your project.

--

--