|Summary:||Image View does cache failed HTTP responses|
|Product:||Forms||Reporter:||Stefan Reinhard <stefan>|
|Component:||iOS||Assignee:||Rui Marinho <rui.marinho>|
|Severity:||normal||CC:||bryan.hunter, parmendrak, philipp, roger.peters, rui.marinho, sahou|
|Tags:||ac||Is this bug a regression?:||---|
|Last known good build:|
Description Stefan Reinhard 2016-03-04 12:33:22 UTC
Overview 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 Actual Results The image is still empty, the persisted error is loaded again. Expected Results 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
Comment 1 Philipp 2016-03-04 12:55:36 UTC
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.
Comment 3 Roger Peters 2016-03-24 16:08:34 UTC
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).
Comment 4 Philipp 2016-03-24 16:13:00 UTC
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. ;)
Comment 5 Samantha Houts [MSFT] 2016-03-30 20:37:07 UTC
Should be fixed in 2.2.0-pre1.
Comment 7 Parmendra Kumar 2017-02-02 12:32:50 UTC
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. Thanks.