Quantcast
Channel: Xamarin.Forms — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 89864

Annoying bug concerning ListView images, possibly network related

$
0
0

0, Dear Xamarin folks, please accept me in the community, despite the bunch of newbie questions I am going to ask in the time coming!

1, I have a Xamarin.Forms hobby project with the goal of experiencing a new .NET applied technology.

2, My Xamarin.Forms app targets Android (only) and provides means for searching among movies, related movies, movie lists, favorite movies etc. over a public WebAPI and displaying results on the Xamarin.Forms (Android) mobile client.
I use Xamarin.Forms 4.1.0.581479 with Target Framework: netstandard2.0

As such the app heavily builds on internet accessed JPEG images, HTTP based JSON transfer for downloading data and the ListView control to display the above elements to the user.

3, PROBLEM :
3.1 Not all images are loading, depending on the internet connection.
3.2 When having a ListView with enough elements for scrolling, the images in the bottom elements are not loading.
3.3 When scrolling a long ListView, even the elements on the top (which were initially loaded) disappear, and some elements on the bottom sporadically appear.

I_ do not have any noticeable problem with HTTP-JSON data_ transmission in either direction, only with image handling.

-a, When using my UPC(United Pan-Europe Communications) SOHO broadband with WiFi, NONE of the images are loading, NONE.
-b, When using my UPC broadband over cable (PC with Android emulator) all the images on the initially visible portion of the screen are displayed, but non on the non visible parts, when scrolled, the bottom images are not displayed, and the top (scrolled-out) images disappear.
-c,When using other, NON-UPC internet connection, most of the images are displayed, but some are sporadically not displayed.

Here is what I mean

4, I have tried to eliminate this bug without success and I think I have searched, red and tried a broad selection of things.

5, Here are some code and settings:

  • Advanced Android Options: HttpClient implementation: Android
  • SSL/TLS implementation:** Default (Native TLS 1.2+)**

HttpClient for JSON transfer (this has no noticeable problem), I have a static HttpClient instance which is created once, with the default HttpClient() constructor and gets reused:

public class TmdbNetworkClient : ITmdbNetworkClient
{
    private readonly ISettings _settings;
    private static Lazy<HttpClient> httpClient = new Lazy<HttpClient>( () => 
           {
                var client = new HttpClient();
                return client;
            });
     private HttpClient HttpClient => httpClient.Value;
....
}

example ListView (I have a few of them):

            <ListView   ItemsSource="{Binding TrendingMovies}"                
                        ItemTapped="TrendingMovies_ItemTapped"
                        IsPullToRefreshEnabled="True"            
                        IsRefreshing="{Binding IsRefreshing}"
                        RefreshCommand="{Binding RefreshCommand}" 
                        CachingStrategy="RecycleElement"
                        HasUnevenRows="True" >  

                <ListView.ItemTemplate>
                    <DataTemplate>
                        <ViewCell>

                            <StackLayout Orientation="Horizontal" Padding="5">

                                <Image>
                                    <Image.Source>
                                        <UriImageSource Uri="{Binding ImgSmSrc}"
                                                    CacheValidity="0"
                                                    CachingEnabled="False"                                                    
                                                    />
                                    </Image.Source>
                                </Image>

                                <StackLayout HorizontalOptions="StartAndExpand" Orientation="Vertical">
                                    <Label Text="{Binding Title}" TextColor="Black"/>
                                    <StackLayout Orientation="Horizontal">
                                        <Label TextColor="Gray" Text="{Binding Year}" FontSize="Micro"/>
                                        <Label TextColor="Gray" Text="{Binding Genre}" FontSize="Micro"/>
                                    </StackLayout>
                                </StackLayout>
                            </StackLayout>
                        </ViewCell>
                    </DataTemplate>
                </ListView.ItemTemplate>
            </ListView>

6, Please note that I have experimented with a few things, with no real success:

  • I have tried different CachingStrategy options, with noticeable difference, but even the best setting is very far from a success

  • I have tried different settings on the CacheValidity and CachingEnabled properties of UriImageSource.

-I have tried using FFImageLoading which when worked was noticeably better -like 90% perfect- then the default image loading solution, WHEN it worked. My problem with FFImageLoading was, that I was looking for a pure XAML controlled solution (without baking it into the C# code of the ViewModel).

When using FFImageLoading that way, when using it over my UPC SOHO WiFi, It sporadically (more often than not) throws HTTP Header timeout Exception, which was not compatible my aim to use it XAML only (as I would need to catch said exception to prevent App crash).

If nothing better, I might go back to FFImageloading in a ViewModel pre-load fashion, where I can make sure that exceptions are catched


Viewing all articles
Browse latest Browse all 89864

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>