4.16.0, SDK 35, log spam "BitmapDrawable created with null Bitmap"
- Dominant language
- Java
- Stars
- 35k
- Forks
- 6.2k
- Avg merge
- 1d 11h
- Merged PRs (30d)
- 8
Description
I'm updating my app to SDK 35 per the Google Play requirements -- https://support.google.com/googleplay/android-developer/answer/11926878?hl=en
I've noticed the logs are now being spammed by
> BitmapDrawable created with null Bitmap
That's in the Android sources for BitmapDrawable.java in two functions next to each other:
```java
@Deprecated
public BitmapDrawable(Bitmap bitmap) {
if (bitmap == null) {
Log.w(TAG, "BitmapDrawable created with null Bitmap");
}
init(new BitmapState(bitmap), null);
}
/**
* Create drawable from a bitmap, setting initial target density based on
* the display metrics of the resources.
*/
public BitmapDrawable(Resources res, Bitmap bitmap) {
if (bitmap == null) {
Log.w(TAG, "BitmapDrawable created with null Bitmap");
}
init(new BitmapState(bitmap), res);
}
```
Putting a breakpoint on those log lines and walking up the stack trace the culprit is in Glide's `ImageViewTarget.java`, specifically:
```java
public void onLoadStarted(@Nullable Drawable placeholder) {
super.onLoadStarted(placeholder);
setResourceInternal(null);
setDrawable(placeholder);
}
```
That `setResourceInternal(null);` line eventually results in the call to `BitmapDrawable` (the deprecated version), hence the log.
The full stack trace is:
```
:154, BitmapDrawable (android.graphics.drawable)
setImageBitmap:764, ImageView (android.widget)
setImageBitmap:124, AppCompatImageView (androidx.appcompat.widget)
setResource:35, BitmapImageViewTarget (com.bumptech.glide.request.target)
setResource:10, BitmapImageViewTarget (com.bumptech.glide.request.target)
setResourceInternal:126, ImageViewTarget (com.bumptech.glide.request.target)
onLoadStarted:67, ImageViewTarget (com.bumptech.glide.request.target)
begin:263, SingleRequest (com.bumptech.glide.request)
runRequest:41, RequestTracker (com.bumptech.glide.manager)
track:688, RequestManager (com.bumptech.glide)
into:858, RequestBuilder (com.bumptech.glide)
into:917, RequestBuilder (com.bumptech.glide)
set:1325, MainDrawerImageLoader (app.pachli)
...
```
In my code the line 1325 call site looks like this:
```kotlin
1320: override fun set(imageView: ImageView, uri: Uri, placeholder: Drawable, tag: String?) {
1321: val glide = Glide.with(imageView)
1322: if (animateAvatars) {
1323: glide.load(uri).placeholder(placeholder).into(imageView)
1324: } else {
* 1325: glide.asBitmap().load(uri).placeholder(placeholder).into(imageView)
1326: }
1327: }
```
Contributor guide
Assessment
This issue has not been assessed yet.