question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

ffimageloading DownloadException: Zero length stream with Xamarin Hot Restart on iPhone

See original GitHub issue

🐛 Bug Report

When using the latest Visual Studio 16.5 on Windows 10 with Xamarin’s Hot Restart enabled, ffimageloading throws FFImageLoading.Exceptions.DownloadException: Zero length stream error while trying to load an image.

Full exception log:

2020-03-21 00:40:45.532 Xamarin.PreBuilt.iOS[1184:451651] Image loading failed: https://s3-us-west-2.amazonaws.com/grial-images/v3.0/article_04.jpg
FFImageLoading.Exceptions.DownloadException: Zero length stream
  at FFImageLoading.Cache.DownloadCache.DownloadAsync (System.String url, System.Threading.CancellationToken token, System.Net.Http.HttpClient client, FFImageLoading.Work.TaskParameter parameters, FFImageLoading.DownloadInformation downloadInformation) [0x006bd] in C:\projects\ffimageloading\source\FFImageLoading.Common\Cache\DownloadCache.cs:174 
  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) [0x000b2] in C:\projects\ffimageloading\source\FFImageLoading.Common\Helpers\Retry.cs:24 
  at FFImageLoading.Cache.D
ng.Common\Work\ImageLoaderTask.cs:618 
ownloadCache.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.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 
  at FFImageLoading.Work.ImageLoaderTask`3[TDecoderContainer,TImageContainer,TImageView].RunAsync () [0x00300] in C:\projects\ffimageloading\source\FFImageLoadi

Expected behavior

To load an image without the error.

Reproduction steps

Try using ffimageloading in any form or way on Windows 10 with Visual Studio 16.5 and Xamarin Hot Restart enabled while debugging on iPhone connected with USB.

Configuration

Version: 2.4.11.982

Platform:

  • 📱 iOS
  • 🤖 Android
  • 🏁 WPF
  • 🌎 UWP
  • 🍎 MacOS
  • 📺 tvOS
  • 🐒 Xamarin.Forms

Issue Analytics

  • State:open
  • Created 4 years ago
  • Reactions:1
  • Comments:31

github_iconTop GitHub Comments

4reactions
PieEatingNinjascommented, Aug 26, 2020

I’m seeing the exact same issue. I’m using version 2.4.11.982, Xamarin Forms version 4.8.0.1269 on iOS 13.6.1 (Hot Reload). On Android everything is working well.

Currently have a rather naive ‘solution’:

public class SourceConverter : IValueConverter
{
    public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
    {
        if (Device.RuntimePlatform == Device.Android)
            return value;

        if(value != null)
            return ImageSource.FromStream(() => new MemoryStream(new WebClient().DownloadData(value.ToString())));

        return null;
    }

    public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
    {
        throw new NotImplementedException();
    }
}

Source="{Binding DetailViewModel.HeaderImage, Converter={StaticResource sourceConverter}}"

Not proud of it, but it works. Hopefully someone can find the source of this issue, so we can leave out dirty hacks like this 😉

3reactions
rredureiscommented, Apr 7, 2020

same error here, debugging from a mac, no image is showed

Read more comments on GitHub >

github_iconTop Results From Across the Web

Zero length stream with Xamarin Hot Restart on iPhone
FFImageLoading.Exceptions.DownloadException: Zero length stream error while trying to load an image. Full exception log: 2020-03-21 00:40:45.532 ...
Read more >
After installing FFImageLoading images don't show at all
So far, all I'm seeing is that FFImageLoading has made it even slower than before to load images on Android. On iOS, nothing...
Read more >
Xamarin Hot Restart not working
I'm trying to check how hot restart works, and when I try to run the app in my iphone connected to my windows...
Read more >
Xamarin Hot Restart
This document describes how to setup and use Xamarin Hot Restart to debug an iOS app.
Read more >
App Crash using Hot Restart Xamarin Forms on iOS
The app launches and runs fine without the Initialize method on my iPhone. It feels like I'm missing a dependency. This is the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found