glide icon indicating copy to clipboard operation
glide copied to clipboard

Retry policy for failures

Open trevorhackman opened this issue 3 years ago • 2 comments

Glide Version: 4.10.0

Issue details / Repro steps / Use case background:

I have a list of items in a RecyclerView and each item has an image url. I want to load images. I have a problem with handling failures. Sometimes an image fails to load. And what I've found is that Glide doesn't have any api for adding a retry policy or retry count (Please correct me if I'm wrong on this and just couldn't find it, sorry if that's the case).

When an image of mine fails to load, and the user scrolls that item off the screen then scrolls that item back on the screen we're rebinding the item and making the same Glide request. And the same request is resulting in a failure to load. There is no end to this, so it ends up spamming a lot of identical network requests in an attempt to load the same image that will never load. Problem is minor but can be exacerbated the more images, the more failures, and the more scrolling that you have.

I could implement my own retry policy myself by tracking the number of times a failure happens for a given url somewhere and keying off of that, but it would be nicer if something like this was possible:

requestBuilder.load(network.fullLogoUrl).maxRetryCount(3)....

Or I could imagine a more complex RetryPolicy that you could set and configure, such as if you only want to retry if >30 seconds has gone by or something, but in my case I am only interested in a max retry count.

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

requestBuilder.load(network.fullLogoUrl).listener(GlideUtil.getGlideResponseListener(
    onSuccess = {},
    onFailure = { errorImageFailedToLoad() }
)).into(image)

trevorhackman avatar Jan 26 '22 06:01 trevorhackman

@trevorhackman Found a way to retry globally?

emouawad avatar Apr 06 '22 21:04 emouawad

Any news? The retry function would be still helpful. Please note, there are places in the world where connection is intermittent. Also there is always Not 100% availability for CDN services which provide images.

Andrew0000 avatar Dec 22 '23 07:12 Andrew0000