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

Thread race - Same image url will get fetched even though there is already an on-going request #427

Closed
ItamarM opened this issue Apr 20, 2015 · 4 comments
Labels
Milestone

Comments

@ItamarM
Copy link

ItamarM commented Apr 20, 2015

Latest version of Glide/OkHttp integration with DiskCacheStrategy.ALL.

Two different size ImageViews will try to fetch an image from Amazon AWS. For example "https://databricks-training.s3.amazonaws.com/img/spark-logo-77x50px-hd.png".

Glide library will execute two web requests (for the same web resource). Then it will fail on the DecodeJob as the LRUCache is writing the "first to return" network request to the file system.
I've created a small project that simulates the issue - https://github.com/ItamarM/GlideOkHttpTwoImagesBug.

@sjudd sjudd added the bug label Apr 20, 2015
@sjudd sjudd added this to the 3.6.0 milestone Apr 20, 2015
@sjudd
Copy link
Collaborator

sjudd commented Apr 20, 2015

We ran into a similar issue in the v4 branch as well. We can and will fix the disk cache race.

Unfortunately it's much more complicated to avoid making two requests because both Glide's default HttpUrlConnection based ModelLoader and the OkHttp based ModelLoader use streaming APIs.

If you need to avoid the multiple network requests, consider an alternate networking library that will do this for you, like Volley.

@ItamarM
Copy link
Author

ItamarM commented Apr 20, 2015

Got it! tnx.

@sjudd
Copy link
Collaborator

sjudd commented Apr 26, 2015

Fixed here: 31640f6

@sjudd sjudd closed this as completed Apr 26, 2015
@ItamarM
Copy link
Author

ItamarM commented Apr 27, 2015

Thanks @sjudd good job!

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

No branches or pull requests

2 participants