Bug 21890 - Xamarin.Forms not loading Remote Images from ListView
Summary: Xamarin.Forms not loading Remote Images from ListView
Alias: None
Product: Forms
Classification: Xamarin
Component: Forms ()
Version: 1.2.2
Hardware: PC Mac OS
: Normal normal
Target Milestone: ---
Assignee: Bugzilla
Depends on:
Reported: 2014-08-06 17:38 UTC by James
Modified: 2015-06-04 08:29 UTC (History)
11 users (show)

Is this bug a regression?: ---
Last known good build:

Sample project exhibiting the issue (5.82 MB, application/zip)
2014-08-06 17:38 UTC, James
Screenshot showing incorrect images in ListView (186.81 KB, image/png)
2014-09-30 02:31 UTC, PaulH

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and 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 Links.

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.

Related Links:

Description James 2014-08-06 17:38:04 UTC
Created attachment 7609 [details]
Sample project exhibiting the issue

Customer has reported an issue with loading remote images into a ListView on Android, specifically list items that disappear off the top or bottom of the list are recycled at the other end as the list is scrolled, but the recycled list items are often not being correctly recycled.  

There also seems to be a serious performance issue with scrolling larger lists. A sample project showing these issues has been attached. 

Lists with images loaded from resources don’t exhibit the same behavior. The above project has been tested on a Samsung Galaxy Tab3 and Nexus 7 (2012), as well as a Nokia 1320 Windows Phone for comparison.

Steps to reproduce:
1. Build the project and run on an Android device
2. Scroll up and down the list on screen – the faster you scroll, the easier it is to catch problems.

The scrolling experience with 20 items can be very sluggish.  100 items is even worse – and if it is doing list item recycling then it shouldn’t be so slow.

The same issue has been reproduced locally.
Comment 1 PaulH 2014-08-06 19:20:33 UTC
Build environment as requested:

Microsoft Visual Studio Professional 2013
Version 12.0.30501.00 Update 2
Microsoft .NET Framework
Version 4.5.51641

Installed Version: Professional

LightSwitch for Visual Studio 2013   06177-004-0444002-02230
Microsoft LightSwitch for Visual Studio 2013

Office Developer Tools - May 2014 Update ENU   06177-004-0444002-02230
Microsoft Office Developer Tools for Visual Studio 2013 - May 2014 Update ENU

Team Explorer for Visual Studio 2013   06177-004-0444002-02230
Microsoft Team Explorer for Visual Studio 2013

Visual Basic 2013   06177-004-0444002-02230
Microsoft Visual Basic 2013

Visual C# 2013   06177-004-0444002-02230
Microsoft Visual C# 2013

Visual C++ 2013   06177-004-0444002-02230
Microsoft Visual C++ 2013

Visual F# 2013   06177-004-0444002-02230
Microsoft Visual F# 2013

Visual Studio 2013 Code Analysis Spell Checker   06177-004-0444002-02230
Microsoft® Visual Studio® 2013 Code Analysis Spell Checker

Portions of International CorrectSpell™ spelling correction system © 1993 by Lernout & Hauspie Speech Products N.V. All rights reserved.

The American Heritage® Dictionary of the English Language, Third Edition Copyright © 1992 Houghton Mifflin Company. Electronic version licensed from Lernout & Hauspie Speech Products N.V. All rights reserved.

Windows Phone SDK 8.0 - ENU   06177-004-0444002-02230
Windows Phone SDK 8.0 - ENU

ASP.NET and Web Tools   2013.2.50425
Microsoft Web Developer Tools contains the following components:
Support for creating and opening ASP.NET web projects
Browser Link: A communication channel between Visual Studio and browsers
Editor extensions for HTML, CSS, and JavaScript
Page Inspector: Inspection tool for ASP.NET web projects
Scaffolding: A framework for building and running code generators
Server Explorer extensions for Windows Azure Web Sites
Web publishing: Extensions for publishing ASP.NET web projects to hosting providers, on-premises servers, or Windows Azure

ASP.NET Web Frameworks and Tools 2012.2   4.1.21001.0
For additional information, visit http://go.microsoft.com/fwlink/?LinkID=309563

ASP.NET Web Frameworks and Tools 2013   5.1.20409.0
For additional information, visit http://www.asp.net/

Common Azure Tools   1.1
Provides common services for use by Azure Mobile Services and Windows Azure Tools.

Microsoft Advertising SDK for Windows Phone   
Microsoft Advertising SDK for Windows Phone

NuGet Package Manager   2.8.50313.46
NuGet Package Manager in Visual Studio. For more information about NuGet, visit http://docs.nuget.org/.

PreEmptive Analytics Visualizer   1.2
Microsoft Visual Studio extension to visualize aggregated summaries from the PreEmptive Analytics product.

SQL Server Data Tools   12.0.30919.1
Microsoft SQL Server Data Tools

Windows Azure Mobile Services Tools   1.1
Windows Azure Mobile Services Tools

Windows Phone 8.1 SDK Integration   1.0
This package integrates the tools for the Windows Phone 8.1 SDK into the menus and controls of Visual Studio.

Workflow Manager Tools 1.0   1.0
This package contains the necessary Visual Studio integration components for Workflow Manager.

Xamarin (2349ba7b70529ea26ba842e1ec32d054bd6abb3b)
Visual Studio extension to enable development for Xamarin.iOS and Xamarin.Android
Comment 2 PaulH 2014-08-22 01:44:02 UTC
Additional information:

I have built and run @JamesMontemagno's fantastic Monkeys sample unmodified from this page: http://motzcod.es/post/88692272607/extending-xamarin-forms-monkeys-app-with-xaml-and

I have compiled both the XAML and code-based UI versions and they appear to have the same problem when run on physical devices. I have not tried it emulated yet, as I don't have Genymotion or anything set up and the Android emulator is too slow.

I am seeing the same issues with James' app, plus an :
 - Scrolling up and down the list is not very responsive
 - List image recycling is very visible when scrolling (old images slowly replaced by new images)
 - Occasionally I can reproduce instances of the images not loading
 - There is a fairly significant memory leak (or very slow resource release), because after a few up-and-down scrolls, the app closes with an OutOfMemoryError (side note: I can't copy text from the Android Device Logging window in VS... minor annoyance), stack trace here:


 - To amplify the effect, I added the following lines to MonkeysViewModel.cs, near the bottom, to give me lots more items:

      Monkeys.Add(new Monkey
      { ... });

      int c = Monkeys.Count;

      // Add 10 more copies of each monkey to the list, because we love monkeys
      for (int i = 0; i < c * 10; i++)
          Monkeys.Add(Monkeys[i % c]);

      var sorted = ...

Even scrolling *very* slowly from the top (giving enough time for the old resources to be released), I get to about "Emporer Tamarin" and it crashes.

Devices tested (same results):
- Samsung Galaxy Tab 3.0
- Lenovo IdeaTab S6000
- Samsung Galaxy Nexus (Harder to crash, but definitely seeing the other issues)

Also tested on 2x Windows Phone 8.0 devices for comparison, and while the experience was not flawless, it certainly didn't exhibit these same issues. FWIW, WP8.0 seems to have its own issue where Image fetching (or scaling) appears to block list items from redrawing (try the modified code from above).  But at least the images are drawn eventually and the list scrolling remains responsive.

** This is a serious issue for Android, please raise the priority of this ticket
Comment 3 Parmendra Kumar 2014-08-22 07:01:56 UTC
I have checked this issue and able to reproduce this, To reproduce this issue I have followed the steps mentioned in bug description

Application output: https://gist.github.com/saurabh360/9794a180ae63adc454cd

Ide Log :https://gist.github.com/saurabh360/9a2a82dff815c0458d9e


Environment info:

=== Xamarin Studio ===

Version 5.2.1 (build 1)
Installation UUID: 1a096c6f-0678-402e-89b2-a2c10f7e80e4
	Mono 3.6.0 ((no/f540f8a)
	GTK+ 2.24.23 (Raleigh theme)

	Package version: 306000039

=== Apple Developer Tools ===

Xcode 5.1 (5084)
Build 5B130a

=== Xamarin.iOS ===

Version: (Business Edition)
Hash: 606f31a
Build date: 2014-08-01 15:27:48-0400

=== Xamarin.Mac ===

Version: (Business Edition)

=== Xamarin.Android ===

Version: 4.14.0 (Business Edition)
Android SDK: /Users/360_macmini/Desktop/android-sdk-macosx
	Supported Android versions:
		2.1   (API level 7)
		2.2   (API level 8)
		2.3   (API level 10)
		3.1   (API level 12)
		3.2   (API level 13)
		4.0   (API level 14)
		4.0.3 (API level 15)
		4.1   (API level 16)
		4.2   (API level 17)
		4.3   (API level 18)
		4.4   (API level 19)
Java SDK: /usr
java version "1.6.0_65"
Java(TM) SE Runtime Environment (build 1.6.0_65-b14-462-11M4609)
Java HotSpot(TM) 64-Bit Server VM (build 20.65-b04-462, mixed mode)

=== Build Information ===

Release ID: 502010001
Git revision: d06832ce9807d6be24aca225457e8b37c7669f6f
Build date: 2014-08-07 12:10:47-04
Xamarin addins: 1de032531be4cecf2f39dbee3b87aac78204058c

=== Operating System ===

Mac OS X 10.9.4
Comment 4 PaulH 2014-09-30 02:25:48 UTC
Update on this bug after upgrading to 1.2.3-pre4:

1.  Scroll speed significantly better
2.  Less image recycling visible, however on a fast fling-and-catch recycled images can still be seen
3.  Recycled images or blank images still occasionally showing instead of the correct image (see screenshot).  This could be when a fresh replacement has failed to load due to network or other issues.
4.  Out Of Memory crashing still occurs when getting to Emperor Tamarin (if the image loads at all).
5.  Image aspect ratios now correct (they weren't before)

The Monkeys test case above still holds as a good test case.  Increase the count to 100 duplicates for some really good thrashing...
Comment 5 PaulH 2014-09-30 02:31:42 UTC
Created attachment 8251 [details]
Screenshot showing incorrect images in ListView

To reproduce:
1. Build and run the Monkeys sample with the changes noted in comment #2
2. Fling the list quickly and catch it
3. Repeat step 2 several times up and down the list.
Comment 6 Rui Marinho 2015-06-02 05:45:23 UTC
This is fixed in 1.4.2
Comment 7 Parmendra Kumar 2015-06-04 08:29:13 UTC
I have checked this issue wit Xamarin.Forms and its working fine at my end.

Hence closing this issue.