18

I have just started moving from Universal Image Loader to Glide. However, when scrolling down and up again in recyclerview I get tons of warning messages.

W/Bitmap: Called reconfigure on a bitmap that is in use! This may cause graphical corruption!

If i swap out Glide for another image loading library, the warning goes away. Code in bindViewHolder related to images:

   Glide.with(viewHolder.imageView.getContext())
            .load(DisplayImageUtil.getImageUrl(item.getImageUrl(), 600))
            .diskCacheStrategy(DiskCacheStrategy.ALL)
            .into(viewHolder.imageView);

Tested on a Nexus 5.

Sam Judd
  • 7,317
  • 1
  • 38
  • 38
Bendik
  • 217
  • 1
  • 2
  • 7

5 Answers5

1

I run to the same issue after first run of my app on Android M (Nexus 5x).

EDIT: after opening the issue on Glide Github - https://github.com/bumptech/glide/issues/743, I found that my orignal "solution" did not solve the problem, only hide the messages. The warning comes from Android Bitmap and it is because Glide reuses the Bitmap for better performance.

JirkaV
  • 943
  • 1
  • 10
  • 16
  • Be careful, increasing item view count in the RecyclerView may lead to using more memory than necessary. – TWiStErRob Nov 13 '15 at 18:42
  • @TWiStErRob - you are right. I rather edited the answer to prevent mislead someone to wrong path. – JirkaV Nov 14 '15 at 19:27
0

This is discussed here ,

Usually this is the result of misusing Bitmaps, either by returning a Bitmap to the pool multiple times without an intermediate get, or by referencing the Bitmap after calling clear() on the corresponding Target. If you have custom transformations, that's a good place to look closely to make sure you aren't returning a Bitmap to the pool twice. You can see more about this issue on the wiki: https://github.com/bumptech/glide/wiki/Resource-re-use-in-Glide.

The log you see is from catch block (caught exception). Make sure you are :

  • Not trying to load 2 bitmap in one target view
  • Not clearing the resource to reuse the target view but holding on to resource's reference

since you are using recyclerView, probably second point is true i.e. recycling the view while holding on to all bitmap references

Nizamudeen Sherif
  • 1,002
  • 1
  • 12
  • 38
Karan
  • 2,120
  • 15
  • 27
  • 1
    I'm not sure I fully understand the problem. I'm not doing any custom recycling, i only load the image in bindViewHolder from the RecyclerView. The problem occurs when I scroll up, and the image is loaded again. Is this something I have to handle manually with Glide? Only used UIL before, and didn't run into any problems like these. – Bendik Oct 27 '15 at 12:22
  • @Kay, which "catch block" are you referring to? I found it's a warning from native [Bitmap.cpp](https://github.com/android/platform_frameworks_base/blob/marshmallow-release/core/jni/android/graphics/Bitmap.cpp#L256). – TWiStErRob Nov 13 '15 at 18:32
  • 3
    This answer is not correct, the quote references an IllegalArgumentException, not the warning here. The warning in the original question will occur during normal use of Glide and isn't the result of misusing Bitmaps. – Sam Judd Dec 04 '15 at 02:11
0

Try calling Glide.clear() before load the image.

Glide.clear(viewHolder.imageView);
Glide.with(viewHolder.imageView.getContext())
        .load(DisplayImageUtil.getImageUrl(item.getImageUrl(), 600))
        .diskCacheStrategy(DiskCacheStrategy.ALL)
        .into(viewHolder.imageView);

Hope this help.

0

I was getting the warning and graphical corruption. This was in the form of clipped bitmaps appearing at the top and bottom of the recycler view and staying there if scrolling too quickly.

Putting the image view inside the frame layout has gotten rid of the graphical corruption.

Meanman
  • 1,474
  • 20
  • 17
0

You can clean the logs with Logcat Filters on Android Studio.

Add ^(?!AbsListView|IInputConnectionWrapper|ApplicationPackageManager|Bitmap|ViewRootImpl) in Regex of Android Logcat filter.