Glide download error debugging

94 views
Skip to first unread message

M Chandravati

unread,
Apr 2, 2024, 12:05:36 PM4/2/24
to Glide
Hi,
I am trying to store Image bitmap/icon drawable in a file using Glide.

```
val drawable = icon.get().loadDrawable(context) as BitmapDrawable
val bitmap = drawable.bitmap
logger.atInfo().log("bitmap: %s", bitmap.byteCount)
try {
val file = GlideFutures.submit(imageManager.downloadOnly().load(drawable)).await()
logger.atInfo().log("path %s", calculateValue(file))
} catch (e: Exception) {
logger.atSevere().withCause(e).log("Exception %s", e)
}
```

Its failing with error
```
03-30 02:02:35.137 17971 23632 W Glide : Load failed for [android.graphics.Bitmap@2667bdb] with dimensions [-2147483648x-2147483648]
03-30 02:02:35.137 17971 23632 W Glide : class com.bumptech.glide.load.engine.GlideException: Failed to load resource
03-30 02:02:35.138 17971 18252 E ErrorLoggingExecutor: Uncaught exception from runnable
03-30 02:02:35.138 17971 18252 E ErrorLoggingExecutor: class com.bumptech.glide.load.engine.GlideException: Failed to load resource
03-30 02:02:35.138 17971 18252 E ErrorLoggingExecutor: Uncaught exception from runnable
03-30 02:02:35.138 17971 18252 E ErrorLoggingExecutor: class com.bumptech.glide.load.engine.GlideException: Failed to load resource

Glide load is failing.

```

Not seeing any other stackstaces or Glide debug logs.

Its a valid bitmap. How to further debug the rootcause?

Thanks

Róbert Papp (TWiStErRob)

unread,
Apr 2, 2024, 4:15:10 PM4/2/24
to Glide
You already have the bitmap, why not Bitmap.compress it?


You can use
  • ByteArrayOutputStream to keep it in memory
  • FileOutputStream to save to file
  • OutputStream from a network library to send it over the wire.

M Chandravati

unread,
Apr 2, 2024, 4:46:11 PM4/2/24
to Glide
Doesn't glide provide additional storage management? DiskLruCache storage? 
How to maintain the file storage?

Róbert Papp (TWiStErRob)

unread,
Apr 2, 2024, 5:33:44 PM4/2/24
to Glide
Ah, makes sense. Sorry, I wasn't clear on what you want to do with the File.
Mind you that using Glide's internal cache means it might evict your "File" when the app just displays images from network due to internal caching during normal operation.

> Its a valid bitmap.
I that case the problem might be that Glide doesn't know how to downloadOnly() a local in-memory resource (drawable) you pass in.
On a related note: have you tried load(bitmap) instead of load(drawable)?

> How to further debug the rootcause?
First I would recommend setting GlideBuilder.setLogLevel(Log.VERBOSE) in your AppGlideModule.applyOptions.

Then, if that's not enough, your best bet is enabling some TAGs with setprop (to VERBOSE), for example "log.tag.Engine" from the Engine class. Looking at your use case I would go with:
Glide, GlideRequest, Engine, GlideExecutor, DecodeJob, DecodePath, SourceGenerator, LruBitmapPool, BitmapEncoder, BitmapImageDecoder, DrawableToBitmap
which is probably way too much information, but if you try to debug one isolated load between two LogCat points, it should give you a clue of what's wrong.

M Chandravati

unread,
Apr 2, 2024, 5:50:47 PM4/2/24
to Glide
I did try load(Bitmap), fails with the same error.

M Chandravati

unread,
Apr 2, 2024, 6:08:01 PM4/2/24
to Glide
Any other Tags missing? 
I did set all these 
`adb shell setprop log.tag.Glide VERBOSE;adb shell setprop log.tag.GlideRequest VERBOSE;adb shell setprop log.tag.Engine VERBOSE;adb shell setprop log.tag.GlideExecutor VERBOSE;adb shell setprop log.tag.DecodeJob VERBOSE;adb shell setprop log.tag.DecodePath VERBOSE;adb shell setprop log.tag.SourceGenerator VERBOSE;adb shell setprop log.tag.LruBitmapPool VERBOSE;adb shell setprop log.tag.BitmapEncoder VERBOSE;adb shell setprop log.tag.BitmapImageDecoder VERBOSE;adb shell setprop log.tag.DrawableToBitmap VERBOSE
`

seeing only the above two Glide: Load resource failed errors.  
Reply all
Reply to author
Forward
0 new messages