Bug 31730 - ListView doesn't update properly and crashes after scrolling
Summary: ListView doesn't update properly and crashes after scrolling
Status: RESOLVED ANSWERED
Alias: None
Product: Forms
Classification: Xamarin
Component: Forms ()
Version: 1.4.3
Hardware: Macintosh Mac OS
: High normal
Target Milestone: ---
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2015-07-08 00:07 UTC by roger.schmidlin
Modified: 2015-07-10 10:48 UTC (History)
5 users (show)

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


Attachments
Sample Code to show bug (180.41 KB, application/zip)
2015-07-08 00:08 UTC, roger.schmidlin
Details


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:
Status:
RESOLVED ANSWERED

Description roger.schmidlin 2015-07-08 00:07:54 UTC
Run example as supplied. 
Expected: empty list displayed
Happened: list is still full and app crashes after scrolling the view

Uncomment method to delete items in constructor and comment out delete items in OnToggle
Now everything works as expected and the ListView updates correctly
Comment 1 roger.schmidlin 2015-07-08 00:08:52 UTC
Created attachment 11923 [details]
Sample Code to show bug
Comment 2 Tajinder Singh 2015-07-08 02:39:09 UTC
I have tried to reproduce this issue and unable to reproduce this given by description and attach sample. User is able to scrolling without app crashes. Please refer to screencast: http://www.screencast.com/t/kogyn7cicuzh

Could you please provide us the test steps you followed.  if possible can you please add the logs and screencast.

Environment Info:
=== Xamarin Studio ===

Version 5.9.5 (build 3)
Installation UUID: 642986ef-b668-4108-b6e5-f58c62d668b6
Runtime:
	Mono 4.0.2 ((detached/5f447f9)
	GTK+ 2.24.23 (Raleigh theme)

	Package version: 400020016

=== Xamarin.Android ===

Version: 5.1.4.21 (Enterprise Edition)
Android SDK: /Users/360logica/Library/Developer/Xamarin/android-sdk-macosx
	Supported Android versions:
		2.3    (API level 10)
		4.0.3  (API level 15)
		4.4    (API level 19)
		4.4.87 (API level 20)
		5.0    (API level 21)
Java SDK: /usr
java version "1.8.0_25"
Java(TM) SE Runtime Environment (build 1.8.0_25-b17)
Java HotSpot(TM) 64-Bit Server VM (build 25.25-b02, mixed mode)

=== Xamarin Android Player ===

Version: Unknown version
Location: /Applications/Xamarin Android Player.app

=== Apple Developer Tools ===

Xcode 6.4 (7720)
Build 6E35b

=== Xamarin.iOS ===

Version: 8.10.4.3 (Enterprise Edition)
Hash: e4cb14c
Branch: master
Build date: 2015-07-03 04:03:14-0400

=== Xamarin.Mac ===

Version: 2.0.2.78 (Enterprise Edition)

=== Build Information ===

Release ID: 509050003
Git revision: 5716b0c7ef341fff65ce7bd750be2b9ae64a1807
Build date: 2015-06-30 15:34:42-04
Xamarin addins: 8adf470161f63b54bcfea78416e4541f6d55d7bb

=== Operating System ===

Mac OS X 10.10.0
Darwin 360Logicas-MacBook-Pro.local 14.0.0 Darwin Kernel Version 14.0.0
    Fri Sep 19 00:26:44 PDT 2014
    root:xnu-2782.1.97~2/RELEASE_X86_64 x86_64
Comment 3 roger.schmidlin 2015-07-08 03:10:18 UTC
You have to use one of the switches in order to delete the list items
Comment 4 roger.schmidlin 2015-07-08 03:12:21 UTC
Test procedure:
- Start up demo
- turn on of the switches off -> list should display no items anymore but still does
- try to scroll the list -> crashes on android and ios
Comment 6 roger.schmidlin 2015-07-08 04:29:09 UTC
Please increase the priority. I am not just unable to scroll, the app crashes because the ListView doesn't get updated properly.
Comment 8 Rui Marinho 2015-07-10 06:04:18 UTC
Hello, the problem is that you are using a List and not a ObservableCollection, so when you remove items in a List it doesn't reflect the changes on the UI (ListView),  you need an ObservableCollection if you want to manipulate your items. 

Thanks
Comment 9 roger.schmidlin 2015-07-10 07:19:08 UTC
Great, thanks. That wasn't obvious to me. Why did it work in the constructor though?
Comment 10 Rui Marinho 2015-07-10 10:48:56 UTC
Because when the ListViewRenderer was creating the Cells the Item/Source/IList was already empty.