Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ANR during RequestManager Initialization #5459

Open
prithvibhola opened this issue Oct 23, 2024 · 2 comments
Open

ANR during RequestManager Initialization #5459

prithvibhola opened this issue Oct 23, 2024 · 2 comments

Comments

@prithvibhola
Copy link

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:

   at com.bumptech.glide.request.RequestOptions.decodeTypeOf(RequestOptions.java:213)
   at com.bumptech.glide.RequestManager.<clinit>(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.

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:

<ImageView
            android:id="@+id/profilePicture"
            android:layout_width="48dp"
            android:layout_height="48dp"
            android:layout_marginStart="16dp"
            android:layout_marginTop="16dp"
            android:clickable="true"
            android:elevation="8dp"
            android:focusable="true"
            android:src="@drawable/home_page_avatar_placeholder"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toTopOf="parent" />
@mikelhm
Copy link

mikelhm commented Oct 24, 2024

I meet the the same problem

com.bumptech.glide.request.target.ImageViewTarget. (ImageViewTarget.java)
com.bumptech.glide.request.target.BitmapImageViewTarget. (BitmapImageViewTarget.java)
com.bumptech.glide.request.target.ImageViewTargetFactory.buildTarget (ImageViewTargetFactory.java:18)
com.bumptech.glide.GlideContext.buildImageViewTarget (GlideContext.java:103)
com.bumptech.glide.RequestBuilder.into (RequestBuilder.java:877)

@AlexeyGodyaev
Copy link

AlexeyGodyaev commented Oct 30, 2024

Almost the same problem ANR main thread, I'm trying to use workmanger. Am I using it right?
Glide.with(context).asBitmap().load(logo).override(24,24).submit(24,24).get()
com.github.bumptech.glide:glide:5.0.0-rc01

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants