Glide: You cannot start a load for a destroyed activity: on clear

Created on 6 Dec 2017  路  6Comments  路  Source: bumptech/glide

Glide Version: 4.3.1

Device/Android Version: S8, S7, Pixel

Issue details / Repro steps / Use case background:

Similar to #138 and #803

I've never gotten this error until I updated to v4 and started using the generated api. The only code that got changed was specific to the refactor required for the library update. The odd thing is that the crash appears to be happening on the clear method and not the actual load. I'm only seeing the crash as it pertains to usage in a RecyclerView.

I'm using the FastAdapter library for my recyclerviews.

Glide load line / GlideModule (if any) / list Adapter code (if any):

@GlideModule
class AppGlideModule : AppGlideModule() {}

// how it is being loaded in bindView
 GlideApp
            .with(holder.itemView.context)
            .asBitmap()
            .load(profilePicture)
            .circleCrop()
            .placeholder(R.drawable.basic_circle_loader_animation)
            .into(holder.itemView.profile_pic)

// how its being cleard in unbindView
GlideApp.with(holder.itemView.context).clear(holder.itemView.profile_pic)


Stack trace / LogCat:

Fatal Exception: java.lang.IllegalArgumentException: You cannot start a load for a destroyed activity
       at com.bumptech.glide.manager.RequestManagerRetriever.assertNotDestroyed(RequestManagerRetriever.java:302)
       at com.bumptech.glide.manager.RequestManagerRetriever.get(RequestManagerRetriever.java:127)
       at com.bumptech.glide.manager.RequestManagerRetriever.get(RequestManagerRetriever.java:112)
       at com.bumptech.glide.Glide.with(Glide.java:609)
       at com.my.app.GlideApp.with(GlideApp.java:70)
       at com.my.app.Item.bindView(Item.kt:156)
       at com.my.app.Item.unbindView(Item.kt:28)
       at com.mikepenz.fastadapter.listeners.OnBindViewHolderListenerImpl.unBindViewHolder(OnBindViewHolderListenerImpl.java:51)
       at com.mikepenz.fastadapter.FastAdapter.onViewRecycled(FastAdapter.java:706)
       at android.support.v7.widget.RecyclerView$Recycler.dispatchViewRecycled(RecyclerView.java:6190)
       at android.support.v7.widget.RecyclerView$Recycler.addViewHolderToRecycledViewPool(RecyclerView.java:5961)
       at android.support.v7.widget.RecyclerView$Recycler.recycleViewHolderInternal(RecyclerView.java:5922)
question stale

Most helpful comment

i have same issues with this, and i have been solved

Glide.with(holder.itemView.getContext())
.load(listPresident.get(position).getPhoto())
.apply(new RequestOptions().override(55, 55))
.into(holder.imgPhoto);

thanks you

All 6 comments

Not much has changed here, it looks like onViewRecycled is just being called after onDestroy.

You can try memoizing the RequestManager:

RequestManager requestManager = Glide.with(fragment);
requestManager.load(...

If this is reproducible in a sample app I'd be happy to take a look. Although we can't easily start new loads from destroyed activities, in some circumstances it's plausible we could clear the Targets.

Thanks for the feedback @sjudd. If I keep a reference to my GlideRequest what is the most efficient way to clear the load in the adapter unbindView? I can't find anything in the samples that clears it in this way.

Keep a reference to the RequestManager, not to the GlideRequest.

Then just requestManager.clear(imageView) is fine.

This issue has been automatically marked as stale because it has not had activity in the last seven days. It will be closed if no further activity occurs within the next seven days. Thank you for your contributions.

i have same issues with this, and i have been solved

Glide.with(holder.itemView.getContext())
.load(listPresident.get(position).getPhoto())
.apply(new RequestOptions().override(55, 55))
.into(holder.imgPhoto);

thanks you

Was this page helpful?
0 / 5 - 0 ratings

Related issues

billy2271 picture billy2271  路  3Comments

Tryking picture Tryking  路  3Comments

AndroidJohnsonWang picture AndroidJohnsonWang  路  3Comments

sant527 picture sant527  路  3Comments

Morteza-Rastgoo picture Morteza-Rastgoo  路  3Comments