Bug 36164 - Constantly crashing on Listview interaction (wp)
Summary: Constantly crashing on Listview interaction (wp)
Alias: None
Product: Forms
Classification: Xamarin
Component: Windows ()
Version: 2.0.0
Hardware: Other Windows
: --- normal
Target Milestone: ---
Assignee: Rui Marinho
Depends on:
Reported: 2015-11-23 14:37 UTC by Jorrit
Modified: 2015-12-01 14:23 UTC (History)
1 user (show)

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

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 Jorrit 2015-11-23 14:37:08 UTC
When scrolling listview, or selecting item, the app is constantly crashing without any debug info.

Tested on wp 8.1, xf

Note: with Xf 1.5, listview interaction was much more stable.
Comment 1 Rui Marinho 2015-11-24 12:21:47 UTC
Thank you for taking the time to submit the bug. We tried to reproduce the issue you reported but were unable given the description. If you could please attach a reproduction to the bug by starting with a clean Xamarin.Forms project and adding just the code necessary to demonstrate the issue we would very much appreciate it.

Warm regards,
Xamarin Forms Team
Comment 2 Jorrit 2015-11-27 03:45:56 UTC
Hi Rui, I found some more details about this issue. To summarize: the primary issue here is that the app crashed when the items are bound to URI (online) images in Xaml. 

When you bind an Image to each row, the app crashes when scrolling down (I have 50 items with one image per item).

I looked at the image binding and tried to bind it to a specific Uri instance (ImageSource = new Uri("[url]")). But this way the app crashes immediately with a stream exception (this is also a bug I think?).

Ultimately, I bypassed it all this way:

- Derive a CustomImage class from Image and use this in Xaml. Bind it to the uri string
- Create a CustomImageRenderer class derived from ImageRenderer
- In here, check if the source is bound to a URI type source, if so, reference the source to a specific BitmapImage instance, like this:

Control.Source = new BitmapImage((Element.Source as UriImageSource).Uri);

This way all my Images load fine and I can scroll the list without crashing.

So I found a workaround but the whole ListView/Image binding stuff still needs a big fix on WP.
Comment 3 Rui Marinho 2015-11-27 05:17:46 UTC
Hi @Jorrit i found out a problem with UriImageSource and the way it get's the image "stream" for the internet. I have a fix but i m now trying to understand why it stopped working. 

So the crashes you referral seem not really related with the listview but more with image from a uri.
Comment 4 Jorrit 2015-11-27 05:43:37 UTC
That's great Rui! Your UriImageSource fix will tackle a very common and hard-to-debug issue with the ListView (and probably other controls as well).

By the way, the app crashes with the infamous "nullreference exception", so this tells exactly nothing. We now know this is probably caused by the image stream (not being created/opened etcetera). So while this is probably a UriImageSource error as you stated, maybe the ListView should handle an error in the Image loading better so it won't crash but throw something with more explicit information. I haven't tested this, but I am wondering what happens with the ListView if the URI resource is not available, times out, raises a 500, etc etc.

So I vote for the image fix ánd a ListView improvement ;).

Thanks for following up on this!
Comment 5 Rui Marinho 2015-12-01 14:23:09 UTC
Should be fixed in the latest XF Service release XF