ANR during RequestManager Initialization
- Dominant language
- Java
- Stars
- 35k
- Forks
- 6.2k
- Avg merge
- 1d 11h
- Merged PRs (30d)
- 8
Description
We are encountering an ANR which appears to occur when Glide.with() is used to load images, with the stack trace pointing to delays during RequestManager initialization and decoding.
Here’s a relevant portion of the stack trace:
```main (runnable):tid=1 systid=13565
at com.bumptech.glide.request.RequestOptions.decodeTypeOf(RequestOptions.java:213)
at com.bumptech.glide.RequestManager.(RequestManager.java:59)
at com.bumptech.glide.GeneratedRequestManagerFactory.build(GeneratedRequestManagerFactory.java:18)
at com.bumptech.glide.manager.LifecycleRequestManagerRetriever.getOrCreate(LifecycleRequestManagerRetriever.java:43)
at com.bumptech.glide.manager.RequestManagerRetriever.get(RequestManagerRetriever.java:158)
at com.bumptech.glide.Glide.with(Glide.java:540)
...
```
The ANR happens during image loading, likely due to some operations such as decoding or request initialization being performed on the main thread.
**Glide Version**: 4.15.1
**Integration libraries**: No
**Device/Android Version**: Based on Firebase Crashlytics data, the ANR occurs on multiple devices, with a significant number of occurrences on Oppo devices running Android 11.
**Glide load line / `GlideModule` (if any) / list Adapter code (if any)**:
We have a helper function that is called from a fragment to load a profile image.
```kotlin
fun loadImageWithScopedContext(
context: Context,
imageView: ImageView,
photoUrl: String?,
@DrawableRes placeholder: Int
) {
if (isEmpty(photoUrl)) return
Glide.with(context)
.load(photoUrl)
.dontAnimate()
.diskCacheStrategy(DiskCacheStrategy.ALL)
.placeholder(placeholder)
.into(imageView)
}
```
**Layout XML**:
```xml
```
Contributor guide
Assessment
This issue has not been assessed yet.