Bug 38067 - ListView adding items while using IsGroupingEnabled crashes app
Summary: ListView adding items while using IsGroupingEnabled crashes app
Status: CONFIRMED
Alias: None
Product: Forms
Classification: Xamarin
Component: Forms ()
Version: 2.0.0
Hardware: PC Mac OS
: --- normal
Target Milestone: ---
Assignee: Bugzilla
URL:
: 33205 ()
Depends on:
Blocks:
 
Reported: 2016-01-26 19:09 UTC by alan.spires
Modified: 2016-04-13 19:23 UTC (History)
8 users (show)

Tags: AC ioS
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 for Bug 38067 on Developer Community or GitHub if you have new information to add and do not yet see a matching new report.

If the latest results still closely match this report, you can use the original description:

  • Export the original title and description: Developer Community HTML or GitHub Markdown
  • Copy the title and description into the new report. Adjust them to be up-to-date if needed.
  • Add your new information.

In special cases on GitHub you might also want the comments: GitHub Markdown with public comments

Related Links:
Status:
CONFIRMED

Description alan.spires 2016-01-26 19:09:21 UTC
Tested on Forms 2.0.1.6495 and latest pre-releases.

Recreation...

Download Repo: https://github.com/highplains/ListViewGroupBug
Run App.
Hit "Load More" button at top, sometimes you have to hit more than once but usually first hit will crash.

Notice Application Output showing of a crash from ListViewRenderer

2016-01-26 12:02:50.412 ListViewGroupBug.iOS[16660:7969584] critical:   at <unknown> <0xffffffff>
2016-01-26 12:02:50.413 ListViewGroupBug.iOS[16660:7969584] critical:   at (wrapper managed-to-native) ObjCRuntime.Messaging.void_objc_msgSend (intptr,intptr) <IL 0x00028, 0xffffffff>
2016-01-26 12:02:50.414 ListViewGroupBug.iOS[16660:7969584] critical:   at UIKit.UITableView.ReloadData () [0x00010] in /Users/builder/data/lanes/2377/73229919/source/maccore/src/build/ios/native/UIKit/UITableView.g.cs:663
2016-01-26 12:02:50.414 ListViewGroupBug.iOS[16660:7969584] critical:   at Xamarin.Forms.Platform.iOS.ListViewRenderer.UpdateItems (System.Collections.Specialized.NotifyCollectionChangedEventArgs,int,bool) <IL 0x00246, 0x00955>
2016-01-26 12:02:50.414 ListViewGroupBug.iOS[16660:7969584] critical:   at Xamarin.Forms.Platform.iOS.ListViewRenderer.OnCollectionChanged (object,System.Collections.Specialized.NotifyCollectionChangedEventArgs) <IL 0x00004, 0x00043>
2016-01-26 12:02:50.414 ListViewGroupBug.iOS[16660:7969584] critical:   at Xamarin.Forms.TemplatedItemsList`2<TKey_REF, TValue_REF>.OnCollectionChanged (System.Collections.Specialized.NotifyCollectionChangedEventArgs) <IL 0x0000d, 0x00051>
2016-01-26 12:02:50.415 ListViewGroupBug.iOS[16660:7969584] critical:   at Xamarin.Forms.TemplatedItemsList`2<TKey_REF, TValue_REF>.OnCollectionChangedGrouped (System.Collections.Specialized.NotifyCollectionChangedEventArgs) <IL 0x000e3, 0x005af>
2016-01-26 12:02:50.415 ListViewGroupBug.iOS[16660:7969584] critical:   at Xamarin.Forms.TemplatedItemsList`2<TKey_REF, TValue_REF>.OnProxyCollectionChanged (object,System.Collections.Specialized.NotifyCollectionChangedEventArgs,bool) <IL 0x0000a, 0x00097>
2016-01-26 12:02:50.415 ListViewGroupBug.iOS[16660:7969584] critical:   at Xamarin.Forms.TemplatedItemsList`2<TKey_REF, TValue_REF>.OnProxyCollectionChanged (object,System.Collections.Specialized.NotifyCollectionChangedEventArgs) <IL 0x00004, 0x00043>
2016-01-26 12:02:50.415 ListViewGroupBug.iOS[16660:7969584] critical:   at Xamarin.Forms.ListProxy.OnCollectionChanged (System.Collections.Specialized.NotifyCollectionChangedEventArgs) <IL 0x0000d, 0x00051>
2016-01-26 12:02:50.415 ListViewGroupBug.iOS[16660:7969584] critical:   at Xamarin.Forms.ListProxy/<>c__DisplayClass52_0.<OnCollectionChanged>b__0 () <IL 0x00024, 0x0004b>
2016-01-26 12:02:50.415 ListViewGroupBug.iOS[16660:7969584] critical:   at Xamarin.Forms.ListProxy.OnCollectionChanged (object,System.Collections.Specialized.NotifyCollectionChangedEventArgs) <IL 0x000a6, 0x00430>
2016-01-26 12:02:50.416 ListViewGroupBug.iOS[16660:7969584] critical:   at Xamarin.Forms.ListProxy/WeakNotifyProxy.OnCollectionChanged (object,System.Collections.Specialized.NotifyCollectionChangedEventArgs) <IL 0x00034, 0x00163>
2016-01-26 12:02:50.416 ListViewGroupBug.iOS[16660:7969584] critical:   at System.Collections.ObjectModel.ObservableCollection`1<T_REF>.OnCollectionChanged (System.Collections.Specialized.NotifyCollectionChangedEventArgs) [0x00012] in /Users/builder/data/lanes/2377/73229919/source/maccore/_build/Library/Frameworks/Xamarin.iOS.framework/Versions/git/src/mono/external/referencesource/System/compmod/system/collections/objectmodel/observablecollection.cs:286
2016-01-26 12:02:50.416 ListViewGroupBug.iOS[16660:7969584] critical:   at System.Collections.ObjectModel.ObservableCollection`1<T_REF>.OnCollectionChanged (System.Collections.Specialized.NotifyCollectionChangedAction,object,int) [0x00000] in /Users/builder/data/lanes/2377/73229919/source/maccore/_build/Library/Frameworks/Xamarin.iOS.framework/Versions/git/src/mono/external/referencesource/System/compmod/system/collections/objectmodel/observablecollection.cs:349
2016-01-26 12:02:50.416 ListViewGroupBug.iOS[16660:7969584] critical:   at System.Collections.ObjectModel.ObservableCollection`1<T_REF>.InsertItem (int,T_REF) [0x00024] in /Users/builder/data/lanes/2377/73229919/source/maccore/_build/Library/Frameworks/Xamarin.iOS.framework/Versions/git/src/mono/external/referencesource/System/compmod/system/collections/objectmodel/observablecollection.cs:217
2016-01-26 12:02:50.417 ListViewGroupBug.iOS[16660:7969584] critical:   at System.Collections.ObjectModel.Collection`1<T_REF>.Add (T_REF) [0x00023] in /Users/builder/data/lanes/2377/73229919/source/maccore/_build/Library/Frameworks/Xamarin.iOS.framework/Versions/git/src/mono/external/referencesource/mscorlib/system/collections/objectmodel/collection.cs:76
2016-01-26 12:02:50.417 ListViewGroupBug.iOS[16660:7969584] critical:   at ListViewGroupBug.ViewModels.TestViewModel.GenerateNewGroups () [0x001f5] in /Users/alan/Dropbox/Projects/ListViewGroupBug/ListViewGroupBug/ViewModels/TestViewModel.cs:57
2016-01-26 12:02:50.417 ListViewGroupBug.iOS[16660:7969584] critical:   at ListViewGroupBug.TestPage.LoadMore_Clicked (object,System.EventArgs) [0x00007] in /Users/alan/Dropbox/Projects/ListViewGroupBug/ListViewGroupBug/TestPage.xaml.cs:28
2016-01-26 12:02:50.418 ListViewGroupBug.iOS[16660:7969584] critical:   at Xamarin.Forms.Button.Xamarin.Forms.IButtonController.SendClicked () <IL 0x00027, 0x000ca>
2016-01-26 12:02:50.418 ListViewGroupBug.iOS[16660:7969584] critical:   at Xamarin.Forms.Platform.iOS.ButtonRenderer.OnButtonTouchUpInside (object,System.EventArgs) <IL 0x0000e, 0x0005b>
2016-01-26 12:02:50.419 ListViewGroupBug.iOS[16660:7969584] critical:   at UIKit.UIControlEventProxy.Activated () [0x00007] in /Users/builder/data/lanes/2377/73229919/source/maccore/src/UIKit/UIControl.cs:37
2016-01-26 12:02:50.419 ListViewGroupBug.iOS[16660:7969584] critical:   at (wrapper runtime-invoke) object.runtime_invoke_void__this__ (object,intptr,intptr,intptr) <IL 0x00056, 0xffffffff>
2016-01-26 12:02:50.419 ListViewGroupBug.iOS[16660:7969584] critical:   at <unknown> <0xffffffff>
2016-01-26 12:02:50.419 ListViewGroupBug.iOS[16660:7969584] critical:   at (wrapper managed-to-native) UIKit.UIApplication.UIApplicationMain (int,string[],intptr,intptr) <IL 0x000aa, 0xffffffff>
2016-01-26 12:02:50.419 ListViewGroupBug.iOS[16660:7969584] critical:   at UIKit.UIApplication.Main (string[],intptr,intptr) [0x00005] in /Users/builder/data/lanes/2377/73229919/source/maccore/src/UIKit/UIApplication.cs:77
2016-01-26 12:02:50.419 ListViewGroupBug.iOS[16660:7969584] critical:   at UIKit.UIApplication.Main (string[],string,string) [0x00038] in /Users/builder/data/lanes/2377/73229919/source/maccore/src/UIKit/UIApplication.cs:61
2016-01-26 12:02:50.419 ListViewGroupBug.iOS[16660:7969584] critical:   at ListViewGroupBug.iOS.Application.Main (string[]) [0x00008] in /Users/alan/Dropbox/Projects/ListViewGroupBug/iOS/Main.cs:17
2016-01-26 12:02:50.419 ListViewGroupBug.iOS[16660:7969584] critical:   at (wrapper runtime-invoke) <Module>.runtime_invoke_void_object (object,intptr,intptr,intptr) <IL 0x00058, 0xffffffff>
Comment 2 Jeremy Sinclair 2016-01-28 16:59:12 UTC
This is the exact issue I've been facing (also exact trace log). It actually starts occurring on 1.5.0.6446. The last version of XF that actually works with grouping is 1.4.4.6449.
Comment 3 Jeremy Sinclair 2016-01-28 16:59:50 UTC
It also seems to only affect iOS (in my testing). Android and WinPhone work perfectly.
Comment 4 Jeremy Sinclair 2016-01-28 18:37:21 UTC
I have a workaround for this issue at least.

@alan.spires@gmail.com:

iOS won't hop to the top of the list when you create a new instance of ObservableCollection, so what I'm doing to keep my app working is as follows:

              Device.OnPlatform(() =>
                    {
                        Items = new ObservableCollection<Grouping<string, Item>>(Items.Union(groupedcollection));
                    }, null, null, () =>
                    {
                        foreach (var grouping in groupedcollection)
                        {
                            NewsItems.Add(grouping);
                        }
                    });

This allows me to use the workaround for iOS, while just using ObservableCollection.Add for the other platforms that work.
Comment 5 Jeremy Sinclair 2016-01-28 18:42:34 UTC
Typo in the foreach I posted. It should just be Items and not NewsItems
Comment 6 alan.spires 2016-01-28 19:26:46 UTC
Appreciate that! Workaround is working for me as well.
Comment 7 Chris King 2016-04-13 19:22:18 UTC
When fixed see https://bugzilla.xamarin.com/show_bug.cgi?id=33205 and ensure actually is a duplicate.
Comment 8 Chris King 2016-04-13 19:23:07 UTC
*** Bug 33205 has been marked as a duplicate of this bug. ***