Notice (2018-05-24): bugzilla.xamarin.com is now in
Please join us on
Visual Studio Developer Community and in the
Mono organizations on
GitHub to continue tracking issues. Bugzilla will remain
available for reference in read-only mode. We will continue to work
on open Bugzilla bugs, copy them to the new locations
as needed for follow-up, and add the new items under Related
Our sincere thanks to everyone who has contributed on this bug
tracker over the years. Thanks also for your understanding as we
make these adjustments and improvements for the future.
Please create a new report on
Developer Community or GitHub with
your current version information, steps to reproduce, and relevant error
messages or log files if you are hitting an issue that looks similar to
this resolved bug and you do not yet see a matching new report.
The Xamarin.Forms image cache does persist HTTP errors in the image cache instead of ignoring them.
Steps to reproduce
1) Load an Image with UriImageSource and caching enabled that returns a 404 or any other HTTP error
2) Make sure the same Uri now does provide a valid image
3) Load the Image from the same location again
The image is still empty, the persisted error is loaded again.
The error should not have been cached and the image now loads successfully.
Affected Builds and Hardware
All Xamarin.Forms versions from 1.3 up to 2.1 show the same behaviour
The Error happens only on iOS, Android is not affected
The problem seems to be that UriImageSource.GetStreamAsyncUnchecked uses Device.GetStreamAsync which does not check for successful HTTP status codes. Therefore any result will be cached a few lines below.
Seems like the only real workaround would be to implement dependency services that can try and read from the ImageLoaderCache and delete the entry if it's filesize is 0.. ? Would really love to see this fixed, without it I can't actually use the image cacheing abilities (which otherwise work great).
We implemented a workaround like this and delete empty cache files. This works fine as long as your server does not send any content in the body of the error response. If you get a body, it will be stored in the cache file and it's going to be hard to find those. ;)
Should be fixed in 2.2.0-pre1.
I have checked this issue with Xamarin.Forms 126.96.36.199-pre1 and observed that this issue has been fixed. To verify this issue I have used the sample project attached in comment #2. Image render successfully when upload on provided empty url.
If you still getting same issue please feel free to reopen this issue or filed the separate issue for the same.