Prashant Borde
Prashant Borde

Reputation: 1178

High CPU usage when playing GIFs

I am displaying GIFs in a RecyclerView. Code:

Glide.with(acitivity)
  .load(url)
  .placeholder(R.drawable.image_placeholder)
  .diskCacheStrategy(DiskCacheStrategy.SOURCE)
  .listener(listener)
  .into(viewHolder.imageView);

If I keep the Fragment containing this RecyclerView open, very high amount of CPU (~40%) is used by the app. And the phone heats up if I use the Fragment for 1-2 minutes. Is it normal for GIFs? Am I doing anything wrong here?

Upvotes: 4

Views: 1475

Answers (1)

Prashant Borde
Prashant Borde

Reputation: 1178

Got response from Glide contributors on Github. Here is what they say -

High CPU consumption is normal. Glide does this to save memory and eventually the evil OOM Exceptions.

Suggestions -

  1. Use static Bitmap image for preview, avoid auto-play.
  2. Use timeout or setLoopCount on GlideDrawable/GifDrawable

More: https://github.com/bumptech/glide/issues/1029

Edit:

Check this issue if you are using ViewPager: https://github.com/bumptech/glide/issues/1028

Upvotes: 3

Related Questions