FFImageLoading
FFImageLoading copied to clipboard
FFImageLoading.Exceptions.DownloadAggregateException
Description
If I try to set a ImageSource like this:
<Image Aspect="AspectFill"
Source="http://loremflickr.com/320/240/product?random=sample.jpg">
I am getting the following exception.
09-03 10:52:24.647 I/mono-stdout( 7828): at FFImageLoading.Retry.DoAsync[T] (System.Func`1[TResult] action, System.TimeSpan retryInterval, System.Int32 retryCount, System.Action onRetry) [0x0023b] in C:\projects\ffimageloading\source\FFImageLoading.Common\Helpers\Retry.cs:65
09-03 10:52:24.647 I/mono-stdout( 7828): at FFImageLoading.Cache.DownloadCache.DownloadAndCacheIfNeededAsync (System.String url, FFImageLoading.Work.TaskParameter parameters, FFImageLoading.Config.Configuration configuration, System.Threading.CancellationToken token) [0x00401] in C:\projects\ffimageloading\source\FFImageLoading.Common\Cache\DownloadCache.cs:57
09-03 10:52:24.648 I/mono-stdout( 7828): at FFImageLoading.DataResolvers.UrlDataResolver.Resolve (System.String identifier, FFImageLoading.Work.TaskParameter parameters, System.Threading.CancellationToken token) [0x00045] in C:\projects\ffimageloading\source\FFImageLoading.Common\DataResolvers\UrlDataResolver.cs:22
09-03 10:52:24.648 I/mono-stdout( 7828): at FFImageLoading.DataResolvers.WrappedDataResolver.Resolve (System.String identifier, FFImageLoading.Work.TaskParameter parameters, System.Threading.CancellationToken token) [0x0004e] in C:\projects\ffimageloading\source\FFImageLoading.Common\DataResolvers\WrappedDataResolver.cs:21
09-03 10:52:24.648 I/mono-stdout( 7828): at FFImageLoading.Work.ImageLoaderTask`3[TDecoderContainer,TImageContainer,TImageView].RunAsync () [0x00300] in C:\projects\ffimageloading\source\FFImageLoading.Common\Work\ImageLoaderTask.cs:618
09-03 10:52:24.648 I/mono-stdout( 7828): ---> (Inner Exception #0) FFImageLoading.Exceptions.DownloadHeadersTimeoutException: Headers timeout
09-03 10:52:24.649 I/mono-stdout( 7828): at FFImageLoading.Cache.DownloadCache.DownloadAsync (System.String url, System.Threading.CancellationToken token, System.Net.Http.HttpClient client, FFImageLoading.Work.TaskParameter parameters, FFImageLoading.DownloadInformation downloadInformation) [0x007c3] in C:\projects\ffimageloading\source\FFImageLoading.Common\Cache\DownloadCache.cs:195
09-03 10:52:24.650 I/mono-stdout( 7828): at FFImageLoading.Cache.DownloadCache+<>c__DisplayClass15_0.<DownloadAndCacheIfNeededAsync>b__0 () [0x00050] in C:\projects\ffimageloading\source\FFImageLoading.Common\Cache\DownloadCache.cs:58
09-03 10:52:24.651 I/mono-stdout( 7828): at FFImageLoading.Retry.DoAsync[T] (System.Func`1[TResult] action, System.TimeSpan retryInterval, System.Int32 retryCount, System.Action onRetry) [0x00047] in C:\projects\ffimageloading\source\FFImageLoading.Common\Helpers\Retry.cs:19 <---
09-03 10:52:24.651 I/mono-stdout( 7828):
**FFImageLoading.Exceptions.DownloadAggregateException:** 'One or more errors occurred. (Headers timeout)'
I am using the image in a CollectionView.
Expected Behavior
Images loading normaly.
Basic Information
- Version with issue: 2.4.11.982
- Platform: Xamarin.Forms
I keep getting this Exception as well, no idea what the cause is... works fine on iOS and UWP, but on Android it throws that exception... is it because the HttpClient implentation selected for the Android project is the native Android one and not System.Net.HttpClient?
For whatever reason, it can't load it up, so it does correctly display the ErrorPlaceholder as expected, but then the exception terminates the app, you'd think it'd get swallowed up so it can continue to run. Well, in this case I'd actually expect the desired source image to get loaded up like on the other platforms but you know what I mean.
This keeps happening on and off (can go for days without issue, and then out of nowhere, it's back, and has nothing to do with code changes)- zero clue why... @daniel-luberda any ideas?
Image loading failed: https://upload.wikimedia.org/wikipedia/commons/b/b0/PSM_V37_D105_English_tabby_cat.jpg FFImageLoading.Exceptions.DownloadAggregateException: One or more errors occurred. (Headers timeout) (Headers timeout) (Headers timeout) (Headers timeout) ---> FFImageLoading.Exceptions.DownloadHeadersTimeoutException: Headers timeout at FFImageLoading.Cache.DownloadCache.DownloadAsync (System.String url, System.Threading.CancellationToken token, System.Net.Http.HttpClient client, FFImageLoading.Work.TaskParameter parameters, FFImageLoading.DownloadInformation downloadInformation) [0x007c3] in C:\projects\ffimageloading\source\FFImageLoading.Common\Cache\DownloadCache.cs:195 at FFImageLoading.Cache.DownloadCache+<>c__DisplayClass15_0.<DownloadAndCacheIfNeededAsync>b__0 () [0x00050] in C:\projects\ffimageloading\source\FFImageLoading.Common\Cache\DownloadCache.cs:58 at FFImageLoading.Retry.DoAsync[T] (System.Func`1[TResult] action, System.TimeSpan retryInterval, System.Int32 retryCount, System.A09-23 14:14:45.658 I/mono-stdout(24184): Image loading failed: https://upload.wikimedia.org/wikipedia/commons/b/b0/PSM_V37_D105_English_tabby_cat.jpg
ction onRetry) [0x00047] in C:\projects\ffimageloading\source\FFImageLoading.Common\Helpers\Retry.cs:19 --- End of inner exception stack trace --- at FFImageLoading.Retry.DoAsync[T] (System.Func`1[TResult] action, System.TimeSpan retryInterval, System.Int32 retryCount, System.Action onRetry) [0x0023b] in C:\projects\ffimageloading\source\FFImageLoading.Common\Helpers\Retry.cs:65 at FFImageLoading.Cache.DownloadCache.DownloadAndCacheIfNeededAsync (System.String url, FFImageLoading.Work.TaskParameter parameters, FFImageLoading.Config.Configuration configuration, System.Threading.CancellationToken token) [0x00401] in C:\projects\ffimageloading\source\FFImageLoading.Common\Cache\DownloadCache.cs:57 at FFImageLoading.DataResolvers.UrlDataResolver.Resolve (System.String identifier, FFImageLoading.Work.TaskParameter parameters, System.Threading.CancellationToken token) [0x00045] in C:\projects\ffimageloading\source\FFImageLoading.Common\DataResolvers\UrlDataResolver.cs:22 at FFImageLoading.DataResolve09-23 14:14:45.658 I/mono-stdout(24184): FFImageLoading.Exceptions.DownloadAggregateException: One or more errors occurred. (Headers timeout) (Headers timeout) (Headers timeout) (Headers timeout) ---> FFImageLoading.Exceptions.DownloadHeadersTimeoutException: Headers timeout
rs.WrappedDataResolver.Resolve (System.String identifier, FFImageLoading.Work.TaskParameter parameters, System.Threading.CancellationToken token) [0x0004e] in C:\projects\ffimageloading\source\FFImageLoading.Common\DataResolvers\WrappedDataResolver.cs:21 at FFImageLoading.Work.ImageLoaderTask`3[TDecoderContainer,TImageContainer,TImageView].RunAsync () [0x00300] in C:\projects\ffimageloading\source\FFImageLoading.Common\Work\ImageLoaderTask.cs:618 ---> (Inner Exception #0) FFImageLoading.Exceptions.DownloadHeadersTimeoutException: Headers timeout at FFImageLoading.Cache.DownloadCache.DownloadAsync (System.String url, System.Threading.CancellationToken token, System.Net.Http.HttpClient client, FFImageLoading.Work.TaskParameter parameters, FFImageLoading.DownloadInformation downloadInformation) [0x007c3] in C:\projects\ffimageloading\source\FFImageLoading.Common\Cache\DownloadCache.cs:195 at FFImageLoading.Cache.DownloadCache+<>c__DisplayClass15_0.<DownloadAndCacheIfNeededAsync>b__0 () [0x00050] in C:\p09-23 14:14:45.658 I/mono-stdout(24184): at FFImageLoading.Cache.DownloadCache.DownloadAsync (System.String url, System.Threading.CancellationToken token, System.Net.Http.HttpClient client, FFImageLoading.Work.TaskParameter parameters, FFImageLoading.DownloadInformation downloadInformation) [0x007c3] in C:\projects\ffimageloading\source\FFImageLoading.Common\Cache\DownloadCache.cs:195
rojects\ffimageloading\source\FFImageLoading.Common\Cache\DownloadCache.cs:58 at FFImageLoading.Retry.DoAsync[T] (System.Func`1[TResult] action, System.TimeSpan retryInterval, System.Int32 retryCount, System.Action onRetry) [0x00047] in C:\projects\ffimageloading\source\FFImageLoading.Common\Helpers\Retry.cs:19 <---
---> (Inner Exception #1) FFImageLoading.Exceptions.DownloadHeadersTimeoutException: Headers timeout at FFImageLoading.Cache.DownloadCache.DownloadAsync (System.String url, System.Threading.CancellationToken token, System.Net.Http.HttpClient client, FFImageLoading.Work.TaskParameter parameters, FFImageLoading.DownloadInformation downloadInformation) [0x007c3] in C:\projects\ffimageloading\source\FFImageLoading.Common\Cache\DownloadCache.cs:195 at FFImageLoading.Cache.DownloadCache+<>c__DisplayClass15_0.<DownloadAndCacheIfNeededAsync>b__0 () [0x00050] in C:\projects\ffimageloading\source\FFImageLoading.Common\Cache\DownloadCache.cs:58 at FFImageLoading.Retry.DoAsync[T] (System.Func`1[TR09-23 14:14:45.659 I/mono-stdout(24184): at FFImageLoading.Cache.DownloadCache+<>c__DisplayClass15_0.<DownloadAndCacheIfNeededAsync>b__0 () [0x00050] in C:\projects\ffimageloading\source\FFImageLoading.Common\Cache\DownloadCache.cs:58
esult] action, System.TimeSpan retryInterval, System.Int32 retryCount, System.Action onRetry) [0x00047] in C:\projects\ffimageloading\source\FFImageLoading.Common\Helpers\Retry.cs:19 <---
---> (Inner Exception #2) FFImageLoading.Exceptions.DownloadHeadersTimeoutException: Headers timeout
at FFImageLoading.Cache.DownloadCache.DownloadAsync (System.String url, System.Threading.CancellationToken token, System.Net.Http.HttpClient client, FFImageLoading.Work.TaskParameter parameters, FFImageLoading.DownloadInformation downloadInformation) [0x007c3] in C:\projects\ffimageloading\source\FFImageLoading.Common\Cache\DownloadCache.cs:195
at FFImageLoading.Cache.DownloadCache+<>c__DisplayClass15_0.<DownloadAndCacheIfNeededAsync>b__0 () [0x00050] in C:\projects\ffimageloading\source\FFImageLoading.Common\Cache\DownloadCache.cs:58
at FFImageLoading.Retry.DoAsync[T] (System.Func1[TResult] action, System.TimeSpan retryInterval, System.Int32 retryCount, System.Action onRetry) [0x00047] in C:\projects\ffimageloading09-23 14:14:45.659 I/mono-stdout(24184): at FFImageLoading.Retry.DoAsync[T] (System.Func
1[TResult] action, System.TimeSpan retryInterval, System.Int32 retryCount, System.Action onRetry) [0x00047] in C:\projects\ffimageloading\source\FFImageLoading.Common\Helpers\Retry.cs:19
\source\FFImageLoading.Common\Helpers\Retry.cs:19 <---
---> (Inner Exception #3) FFImageLoading.Exceptions.DownloadHeadersTimeoutException: Headers timeout at FFImageLoading.Cache.DownloadCache.DownloadAsync (System.String url, System.Threading.CancellationToken token, System.Net.Http.HttpClient client, FFImageLoading.Work.TaskParameter parameters, FFImageLoading.DownloadInformation downloadInformation) [0x007c3] in C:\projects\ffimageloading\source\FFImageLoading.Common\Cache\DownloadCache.cs:195 at FFImageLoading.Cache.DownloadCache+<>c__DisplayClass15_0.<DownloadAndCacheIfNeededAsync>b__0 () [0x00050] in C:\projects\ffimageloading\source\FFImageLoading.Common\Cache\DownloadCache.cs:58 at FFImageLoading.Retry.DoAsync[T] (System.Func`1[TResult] action, System.TimeSpan retryInterval, System.Int32 retryCount, System.Action onRetry) [0x00047] in C:\projects\ffimageloading\source\FFImageLoading.Common\Helpers\Retry.cs:19 <---09-23 14:14:45.659 I/mono-stdout(24184): --- End of inner exception stack trace ---
09-23 14:14:45.659 I/mono-stdout(24184): at FFImageLoading.Retry.DoAsync[T] (System.Func1[TResult] action, System.TimeSpan retryInterval, System.Int32 retryCount, System.Action onRetry) [0x0023b] in C:\projects\ffimageloading\source\FFImageLoading.Common\Helpers\Retry.cs:65 09-23 14:14:45.659 I/mono-stdout(24184): at FFImageLoading.Cache.DownloadCache.DownloadAndCacheIfNeededAsync (System.String url, FFImageLoading.Work.TaskParameter parameters, FFImageLoading.Config.Configuration configuration, System.Threading.CancellationToken token) [0x00401] in C:\projects\ffimageloading\source\FFImageLoading.Common\Cache\DownloadCache.cs:57 09-23 14:14:45.659 I/mono-stdout(24184): at FFImageLoading.DataResolvers.UrlDataResolver.Resolve (System.String identifier, FFImageLoading.Work.TaskParameter parameters, System.Threading.CancellationToken token) [0x00045] in C:\projects\ffimageloading\source\FFImageLoading.Common\DataResolvers\UrlDataResolver.cs:22 09-23 14:14:45.659 I/mono-stdout(24184): at FFImageLoading.DataResolvers.WrappedDataResolver.Resolve (System.String identifier, FFImageLoading.Work.TaskParameter parameters, System.Threading.CancellationToken token) [0x0004e] in C:\projects\ffimageloading\source\FFImageLoading.Common\DataResolvers\WrappedDataResolver.cs:21 09-23 14:14:45.659 I/mono-stdout(24184): at FFImageLoading.Work.ImageLoaderTask
3[TDecoderContainer,TImageContainer,TImageView].RunAsync () [0x00300] in C:\projects\ffimageloading\source\FFImageLoading.Common\Work\ImageLoaderTask.cs:618
09-23 14:14:45.659 I/mono-stdout(24184): ---> (Inner Exception #0) FFImageLoading.Exceptions.DownloadHeadersTimeoutException: Headers timeout
09-23 14:14:45.659 I/mono-stdout(24184): at FFImageLoading.Cache.DownloadCache.DownloadAsync (System.String url, System.Threading.CancellationToken token, System.Net.Http.HttpClient client, FFImageLoading.Work.TaskParameter parameters, FFImageLoading.DownloadInformation downloadInformation) [0x007c3] in C:\projects\ffimageloading\source\FFImageLoading.Common\Cache\DownloadCache.cs:195
09-23 14:14:45.659 I/mono-stdout(24184): at FFImageLoading.Cache.DownloadCache+<>c__DisplayClass15_0.<DownloadAndCacheIfNeededAsync>b__0 () [0x00050] in C:\projects\ffimageloading\source\FFImageLoading.Common\Cache\DownloadCache.cs:58
09-23 14:14:45.659 I/mono-stdout(24184): at FFImageLoading.Retry.DoAsync[T] (System.Func1[TResult] action, System.TimeSpan retryInterval, System.Int32 retryCount, System.Action onRetry) [0x00047] in C:\projects\ffimageloading\source\FFImageLoading.Common\Helpers\Retry.cs:19 <--- 09-23 14:14:45.659 I/mono-stdout(24184): 09-23 14:14:45.659 I/mono-stdout(24184): ---> (Inner Exception #1) FFImageLoading.Exceptions.DownloadHeadersTimeoutException: Headers timeout 09-23 14:14:45.659 I/mono-stdout(24184): at FFImageLoading.Cache.DownloadCache.DownloadAsync (System.String url, System.Threading.CancellationToken token, System.Net.Http.HttpClient client, FFImageLoading.Work.TaskParameter parameters, FFImageLoading.DownloadInformation downloadInformation) [0x007c3] in C:\projects\ffimageloading\source\FFImageLoading.Common\Cache\DownloadCache.cs:195 09-23 14:14:45.659 I/mono-stdout(24184): at FFImageLoading.Cache.DownloadCache+<>c__DisplayClass15_0.<DownloadAndCacheIfNeededAsync>b__0 () [0x00050] in C:\projects\ffimageloading\source\FFImageLoading.Common\Cache\DownloadCache.cs:58 09-23 14:14:45.660 I/mono-stdout(24184): at FFImageLoading.Retry.DoAsync[T] (System.Func
1[TResult] action, System.TimeSpan retryInterval, System.Int32 retryCount, System.Action onRetry) [0x00047] in C:\projects\ffimageloading\source\FFImageLoading.Common\Helpers\Retry.cs:19 <---
09-23 14:14:45.660 I/mono-stdout(24184):
09-23 14:14:45.660 I/mono-stdout(24184): ---> (Inner Exception #2) FFImageLoading.Exceptions.DownloadHeadersTimeoutException: Headers timeout
09-23 14:14:45.660 I/mono-stdout(24184): at FFImageLoading.Cache.DownloadCache.DownloadAsync (System.String url, System.Threading.CancellationToken token, System.Net.Http.HttpClient client, FFImageLoading.Work.TaskParameter parameters, FFImageLoading.DownloadInformation downloadInformation) [0x007c3] in C:\projects\ffimageloading\source\FFImageLoading.Common\Cache\DownloadCache.cs:195
09-23 14:14:45.660 I/mono-stdout(24184): at FFImageLoading.Cache.DownloadCache+<>c__DisplayClass15_0.<DownloadAndCacheIfNeededAsync>b__0 () [0x00050] in C:\projects\ffimageloading\source\FFImageLoading.Common\Cache\DownloadCache.cs:58
09-23 14:14:45.660 I/mono-stdout(24184): at FFImageLoading.Retry.DoAsync[T] (System.Func1[TResult] action, System.TimeSpan retryInterval, System.Int32 retryCount, System.Action onRetry) [0x00047] in C:\projects\ffimageloading\source\FFImageLoading.Common\Helpers\Retry.cs:19 <--- 09-23 14:14:45.660 I/mono-stdout(24184): 09-23 14:14:45.660 I/mono-stdout(24184): ---> (Inner Exception #3) FFImageLoading.Exceptions.DownloadHeadersTimeoutException: Headers timeout 09-23 14:14:45.660 I/mono-stdout(24184): at FFImageLoading.Cache.DownloadCache.DownloadAsync (System.String url, System.Threading.CancellationToken token, System.Net.Http.HttpClient client, FFImageLoading.Work.TaskParameter parameters, FFImageLoading.DownloadInformation downloadInformation) [0x007c3] in C:\projects\ffimageloading\source\FFImageLoading.Common\Cache\DownloadCache.cs:195 09-23 14:14:45.660 I/mono-stdout(24184): at FFImageLoading.Cache.DownloadCache+<>c__DisplayClass15_0.<DownloadAndCacheIfNeededAsync>b__0 () [0x00050] in C:\projects\ffimageloading\source\FFImageLoading.Common\Cache\DownloadCache.cs:58 09-23 14:14:45.660 I/mono-stdout(24184): at FFImageLoading.Retry.DoAsync[T] (System.Func
1[TResult] action, System.TimeSpan retryInterval, System.Int32 retryCount, System.Action onRetry) [0x00047] in C:\projects\ffimageloading\source\FFImageLoading.Common\Helpers\Retry.cs:19 <---
I keep getting this Exception as well, no idea what the cause is... works fine on iOS and UWP, but on Android it throws that exception... is it because the HttpClient implentation selected for the Android project is the native Android one and not System.Net.HttpClient? ...
@mzhukovs I tried it with any combination of the Android HttpClient implementation. But I also getting a slightly different issue if I don’t use the FFImageLoading nuget. But happens also at the time the code tries to load a image.
https://github.com/xamarin/Xamarin.Forms/issues/7248
Is this probably related to our problem seems to be fixed in 4.2.0 SR2 from last week.
I also think that’s the error I got if I tried it without FFImageLoading
In described scenario DownloadCache.DownloadAsync(...)
method throws unhandled DownloadHeadersTimeoutException
.
The bug can be reproduced when HttpHeadersTimeout
configuration property has value 0
.
My workaround:
- Implement
CustomDownloadCache
public class CustomDownloadCache : DownloadCache
{
public CustomDownloadCache(Configuration configuration) : base(configuration)
{
}
protected override async Task<byte[]> DownloadAsync(string url, CancellationToken token,
HttpClient client, TaskParameter parameters, DownloadInformation downloadInformation)
{
try
{
return await base.DownloadAsync(url, token, client, parameters, downloadInformation);
}
catch (Exception e) when (e is DownloadHeadersTimeoutException ex)
{
throw new System.OperationCanceledException("Download headers timeout", ex);
}
}
}
- Initialize
ImageService
with custom configuration
var config = new Configuration();
config.DownloadCache = new CustomDownloadCache(config);
ImageService.Instance.Initialize(config);
I believe that this may have something to do with this mono issue https://github.com/mono/mono/issues/15462 I created a custom download cache with the code from this repo so I could step through it and this was the error that was being thrown and then converted to the other Header or Read Timeout error.
However the above error seems only to be triggered after a request is being cancelled which may explain why the ObjectDisposed error is being handled in this way. So I think there may still be some problem with the FFImageLoader code somewhere.
In described scenario
DownloadCache.DownloadAsync(...)
method throws unhandledDownloadHeadersTimeoutException
.The bug can be reproduced when
HttpHeadersTimeout
configuration property has value0
.My workaround:
- Implement
CustomDownloadCache
public class CustomDownloadCache : DownloadCache { public CustomDownloadCache(Configuration configuration) : base(configuration) { } protected override async Task<byte[]> DownloadAsync(string url, CancellationToken token, HttpClient client, TaskParameter parameters, DownloadInformation downloadInformation) { try { return await base.DownloadAsync(url, token, client, parameters, downloadInformation); } catch (Exception e) when (e is DownloadHeadersTimeoutException ex) { throw new System.OperationCanceledException("Download headers timeout", ex); } } }
- Initialize
ImageService
with custom configurationvar config = new Configuration(); config.DownloadCache = new CustomDownloadCache(config); ImageService.Instance.Initialize(config);
Thx for sharing