Open animeshPE91 opened 1 year ago
Have you solved this problem
I have a similar problem too, which is occurred after user opening app from background.
It's expected to set ImageView's imageDrawable
null, if the Bitmap in Drawable the ImageView holds is recycled. But obviously, here the Drawable that ImageView holds is not set null.
I don't know whether system or Glide recycled that Bitmap.
The following is the code:
fun ImageView.setTransformedImageBitmap(
imageUrl: String?,
transformation: Transformation<Bitmap>,
currentUrlFetcher: () -> String?
) {
Glide.with(this)
.asBitmap()
.load(imageUrl)
.transform(transformation)
.transform(WebpDrawable::class.java, WebpDrawableTransformation(transformation))
.transition(BitmapTransitionOptions.withCrossFade())
.diskCacheStrategy(DiskCacheStrategy.ALL)
.listener(
object : RequestListener<Bitmap> {
override fun onLoadFailed(
e: GlideException?,
model: Any?,
target: Target<Bitmap>,
isFirstResource: Boolean
): Boolean {
e?.run {
// some error logic
}
return false
}
override fun onResourceReady(
resource: Bitmap,
model: Any,
target: Target<Bitmap>,
dataSource: DataSource,
isFirstResource: Boolean
): Boolean {
val currentUrl = currentUrlFetcher()
val resourceValid = !resource.isRecycled
if (currentUrl != imageUrl) {
Log.e(TAG, "Image url are inconsistent!")
return true
}
if (!resourceValid) {
Log.e(TAG, "Resource invalid!")
return true
}
return false
}
}
)
.into(this)
}
@Madderate were you able to find a fix for this? having a similar issue when a user opens the app from the background as well
is there any update, guys? Check is resource recycled which is not a quite good solution, the callback should do onLoadFailed()
instead i think.
Recently, the crash of recycled bitmap have been increased which is reported from Firebase Crashlytics. does anyone meet same problem? Workaround check is bitmap recycled before using which is not actually quite good solution, we need to handle same as onLoadFailed
Hi Glide team,
Recently after app release we started seeing this issue for few users.
java.lang.RuntimeException: Canvas: trying to use a recycled bitmap android.graphics.Bitmap@ea5bf3d
The glide that we are using is com.github.bumptech.glide:glide:4.11.0
the retrofit library that we are using is com.squareup.retrofit2:retrofit:2.9.0
Following is the code snippet I am using for loading a image using glide into imageView
The error that I am getting on firebase is as follows
Can you please help me understand what I am doing wrong here; Or if i can replace/improve this code to avoid this issue