Bug 59412 - Xamarin.Forms iOS ListView crash System.ArgumentOutOfRangeExceptionSpecified argument was out of the range of valid values. Parameter name: index
Summary: Xamarin.Forms iOS ListView crash System.ArgumentOutOfRangeExceptionSpecified ...
Status: RESOLVED FIXED
Alias: None
Product: Forms
Classification: Xamarin
Component: Forms (show other bugs)
Version: 2.3.4
Hardware: PC Windows
: Normal major
Target Milestone: ---
Assignee: Bugzilla
URL:
: 59767 60458 (view as bug list)
Depends on:
Blocks:
 
Reported: 2017-09-12 09:45 UTC by y.vinee
Modified: 2018-05-04 18:56 UTC (History)
31 users (show)

Tags: listview, outofrange, hasunevenrows, ac, fr
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:
Status:
RESOLVED FIXED

Description y.vinee 2017-09-12 09:45:48 UTC
# Steps to reproduce
Create a NavigationPage
Push a ContentPage with a ListView with:
IsGroupingEnabled="True"
HasUnevenRows="true" 
Bind a Group with Items on the listview
Push a ContentPage with a button which removes an item of the ItemsSource on ItemTapped
Rotate the iPhone
Click to the button to remove the item
Crash System.ArgumentOutOfRangeExceptionSpecified argument was out of the range of valid values. Parameter name: index

Here is a project to reproduce the bug:
https://www.dropbox.com/sh/f6haevanl7xbd9i/AACd5uyCDKxB8MawTxBvz4iDa?dl=0


# Expected behavior
Remove the item without crash

# Actual behavior
Crash 

# Supplemental info (logs, images, videos)
if HasUnevenRows="false" then there is no crash

# Test environment (full version information)
Crash with Xamarin.Forms 2.3.4.270
Comment 1 Paul DiPietro [MSFT] 2017-09-14 00:30:01 UTC
Thank you for the reproduction. Also tested against 2.4.0-pre2.
Comment 2 Paul DiPietro [MSFT] 2017-09-26 18:44:55 UTC
*** Bug 59767 has been marked as a duplicate of this bug. ***
Comment 3 Wallace Santos 2017-09-26 19:10:10 UTC
In my app, even with HasUnevenRows="false" crashes.
Comment 4 Wallace Santos 2017-10-05 12:35:20 UTC
Hi Guys, 

Just to help, apparently using an ObservableColletion to fill list solves the problem. I did some tests here and worked fine. Please, evaluate there and if possible confirm to us.
Comment 5 Justin 2017-10-20 02:21:34 UTC
We're using ObservableCollections throughout our app and are still hitting this error intermittently.
Comment 6 Sümeyya Tuğçe Arar 2017-10-31 15:39:48 UTC
I don't know if it works for you but I resolved this bug by setting HasUnevenRows property to false for listview. 
Note: In this situation you should set RowHeight to proper value.
Comment 7 Paul DiPietro [MSFT] 2017-10-31 20:11:41 UTC
*** Bug 60458 has been marked as a duplicate of this bug. ***
Comment 8 Rein Vdst 2017-11-09 18:58:34 UTC
This might be related, I didn't want to create a new bug as I get the same kind of error.

I have a ListView with a DataTemplateSelector and UnevenRows set to true. Now in Xamarin.Forms.Android I get the same exception when the BindingContext changes.

Just scrolling through the listview sometimes crashes. With a emphasis on sometimes. Most of the time it does work, sometimes after initializing it crashes, sometimes you can play around with the listview for 10 minutes before this issue occurs.

Thus I cannot reliably reproduce this error, in my case it's using an Observable Collection but no items are ever added or removed.

However visually I can see the scrollbar jumping around (being 70% of the height -> 40% of the height -> 80% of the height). There are around 15 items in this list and 4 different templates.

The stacktrace:

Xamarin caused by: android.runtime.JavaProxyThrowable: System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index
  at System.ThrowHelper.ThrowArgumentOutOfRangeException (System.ExceptionArgument argument, System.ExceptionResource resource) <0x9e113f8c + 0x00064> in <3b2d7ef80dde4a2198898e4d883fdcb5>:0 
  at System.Collections.Generic.List`1[T].get_Item (System.Int32 index) <0x9e1389ec + 0x0002b> in <3b2d7ef80dde4a2198898e4d883fdcb5>:0 
  at (wrapper managed-to-native) System.Reflection.MonoMethod:InternalInvoke (System.Reflection.MonoMethod,object,object[],System.Exception&)
  at System.Reflection.MonoMethod.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00032] in <3b2d7ef80dde4a2198898e4d883fdcb5>:0 
   --- End of inner exception stack trace ---
  at System.Reflection.MonoMethod.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x0004b] in <3b2d7ef80dde4a2198898e4d883fdcb5>:0 
  at System.Reflection.MethodBase.Invoke (System.Object obj, System.Object[] parameters) <0x9e20fc4c + 0x00023> in <3b2d7ef80dde4a2198898e4d883fdcb5>:0 
  at Xamarin.Forms.BindingExpression+BindingExpressionPart.TryGetValue (System.Object source, System.Object& value) <0x9ddc99fc + 0x00120> in <e3c6df132acf467b8454c1ce7cb4c77d>:0 
  at Xamarin.Forms.BindingExpression.ApplyCore (System.Object sourceObject, Xamarin.Forms.BindableObject target, Xamarin.Forms.BindableProperty property, System.Boolean fromTarget) <0x9ddc86dc + 0x0029b> in <e3c6df132acf467b8454c1ce7cb4c77d>:0 
  at Xamarin.Forms.BindingExpression.Apply (System.Object sourceObject, Xamarin.Forms.BindableObject target, Xamarin.Forms.BindableProperty property) <0x9ddc8494 + 0x00143> in <e3c6df132acf467b8454c1ce7cb4c77d>:0 
  at Xamarin.Forms.Binding.Apply (System.Object newContext, Xamarin.Forms.BindableObject bindObj, Xamarin.Forms.BindableProperty targetProperty) <0x9ddc6f80 + 0x000a3> in <e3c6df132acf467b8454c1ce7cb4c77d>:0 
  at Xamarin.Forms.BindableObject.ApplyBindings (System.Boolean skipBindingContext) <0x9ddc3790 + 0x0013f> in <e3c6df132acf467b8454c1ce7cb4c77d>:0 
  at Xamarin.Forms.BindableObject.SetInheritedBindingContext (Xamarin.Forms.BindableObject bindable, System.Object value) <0x9ddc20c4 + 0x0011f> in <e3c6df132acf467b8454c1ce7cb4c77d>:0 
  at Xamarin.Forms.Element.SetChildInheritedBindingContext (Xamarin.Forms.Element child, System.Object context) <0x9de2ae54 + 0x0000f> in <e3c6df132acf467b8454c1ce7cb4c77d>:0 
  at Xamarin.Forms.Element.OnBindingContextChanged () <0x9de2a28c + 0x00093> in <e3c6df132acf467b8454c1ce7cb4c77d>:0 
  at Xamarin.Forms.View.OnBindingContextChanged () <0x9ddd2bc4 + 0x0011f> in <e3c6df132acf467b8454c1ce7cb4c77d>:0 
  at Xamarin.Forms.Grid.OnBindingContextChanged () <0x9de2199c + 0x00013> in <e3c6df132acf467b8454c1ce7cb4c77d>:0 
  at Xamarin.Forms.BindableObject.SetInheritedBindingContext (Xamarin.Forms.BindableObject bindable, System.Object value) <0x9ddc20c4 + 0x0012f> in <e3c6df132acf467b8454c1ce7cb4c77d>:0 
  at Xamarin.Forms.Element.SetChildInheritedBindingContext (Xamarin.Forms.Element child, System.Object context) <0x9de2ae54 + 0x0000f> in <e3c6df132acf467b8454c1ce7cb4c77d>:0 
  at Xamarin.Forms.Element.OnBindingContextChanged () <0x9de2a28c + 0x00093> in <e3c6df132acf467b8454c1ce7cb4c77d>:0 
  at Xamarin.Forms.Cell.OnBindingContextChanged () <0x9ddf1964 + 0x0000b> in <e3c6df132acf467b8454c1ce7cb4c77d>:0 
  at B2B.Views.Action.ActionViewCell.OnBindingContextChanged () <0x9df1f250 + 0x00013> in <f9625ea2fea2471bb354422d0feb9f22>:0 
  at B2B.Views.Action.SelectBooleanViewCell.OnBindingContextChanged () <0x9df1e118 + 0x0000f> in <f9625ea2fea2471bb354422d0feb9f22>:0 
  at Xamarin.Forms.BindableObject.BindingContextPropertyChanged (Xamarin.Forms.BindableObject bindable, System.Object oldvalue, System.Object newvalue) <0x9ddc39cc + 0x0002f> in <e3c6df132acf467b8454c1ce7cb4c77d>:0 
  at Xamarin.Forms.BindableObject.SetValueActual (Xamarin.Forms.BindableProperty property, Xamarin.Forms.BindableObject+BindablePropertyContext context, System.Object value, System.Boolean currentlyApplying, Xamarin.Forms.Internals.SetValueFlags attributes, System.Boolean silent) <0x9ddc4048 + 0x00227> in <e3c6df132acf467b8454c1ce7cb4c77d>:0 
  at Xamarin.Forms.BindableObject.SetValueCore (Xamarin.Forms.BindableProperty property, System.Object value, Xamarin.Forms.Internals.SetValueFlags attributes, Xamarin.Forms.BindableObject+SetValuePrivateFlags privateAttributes) <0x9ddc32ec + 0x00393> in <e3c6df132acf467b8454c1ce7cb4c77d>:0 
  at Xamarin.Forms.BindableObject.SetValue (Xamarin.Forms.BindableProperty property, System.Object value, System.Boolean fromStyle, System.Boolean checkAccess) <0x9ddc3ec4 + 0x000e7> in <e3c6df132acf467b8454c1ce7cb4c77d>:0 
  at Xamarin.Forms.BindableObject.set_BindingContext (System.Object value) <0x9ddc18a0 + 0x00033> in <e3c6df132acf467b8454c1ce7cb4c77d>:0 
  at Xamarin.Forms.Internals.TemplatedItemsList`2[TView,TItem].UpdateContent (TItem content, System.Int32 index, System.Object item) <0x9de561a8 + 0x00027> in <e3c6df132acf467b8454c1ce7cb4c77d>:0 
  at Xamarin.Forms.Internals.TemplatedItemsList`2[TView,TItem].UpdateContent (TItem content, System.Int32 index) <0x9de56270 + 0x00067> in <e3c6df132acf467b8454c1ce7cb4c77d>:0 
  at Xamarin.Forms.Internals.TemplatedItemsList`2[TView,TItem].Xamarin.Forms.ITemplatedItemsList<TItem>.UpdateContent (TItem content, System.Int32 index) <0x9de562e8 + 0x0000f> in <e3c6df132acf467b8454c1ce7cb4c77d>:0 
  at Xamarin.Forms.Platform.Android.ListViewAdapter.IsEnabled (System.Int32 position) <0x9d4f7e10 + 0x00137> in <8d6936257ac5419f8be9df07a9bb5129>:0 
  at Android.Widget.BaseAdapter.n_IsEnabled_I (System.IntPtr jnienv, System.IntPtr native__this, System.Int32 position) <0x9d5ba02c + 0x00047> in <7ed1f46b7c034db1841b4a24edd078f8>:0 
  at (wrapper dynamic-method) System.Object:1d9d9e54-f22a-43cc-b732-373773759957 (intptr,intptr,int)
	at md5b60ffeb829f638581ab2bb9b1a7f4f3f.ListViewAdapter.n_isEnabled(Native Method)
	at md5b60ffeb829f638581ab2bb9b1a7f4f3f.ListViewAdapter.isEnabled(ListViewAdapter.java:108)
	at android.widget.HeaderViewListAdapter.isEnabled(HeaderViewListAdapter.java:159)
	at android.widget.AbsListView.setItemViewLayoutParams(AbsListView.java:2398)
	at android.widget.AbsListView.obtainView(AbsListView.java:2367)
	at android.widget.ListView.makeAndAddView(ListView.java:1876)
	at android.widget.ListView.fillDown(ListView.java:702)
	at android.widget.ListView.fillFromTop(ListView.java:763)
	at android.widget.ListView.layoutChildren(ListView.java:1685)
	at android.widget.AbsListView.onLayout(AbsListView.java:2148)
	at android.view.View.layout(View.java:16651)
	at android.view.ViewGroup.layout(ViewGroup.java:5440)
	at android.support.v4.widget.SwipeRefreshLayout.onLayout(SwipeRefreshLayout.java:610)
	at android.view.View.layout(View.java:16651)
	at android.view.ViewGroup.layout(ViewGroup.java:5440)
	at md5b60ffeb829f638581ab2bb9b1a7f4f3f.ListViewRenderer.n_onLayout(Native Method)
	at md5b60ffeb829f638581ab2bb9b1a7f4f3f.ListViewRenderer.onLayout(ListViewRenderer.java:65)
	at android.view.View.layout(View.java:16651)
	at android.view.ViewGroup.layout(ViewGroup.java:5440)
	at com.xamarin.forms.platform.android.FormsViewGroup.measureAndLayout(FormsViewGroup.java:28)
	at md5b60ffeb829f638581ab2bb9b1a7f4f3f.VisualElementRenderer_1.n_onLayout(Native Method)
	at md5b60ffeb829f638581ab2bb9b1a7f4f3f.VisualElementRenderer_1.onLayout(VisualElementRenderer_1.java:72)
	at android.view.View.layout(View.java:16651)
	at android.view.ViewGroup.layout(ViewGroup.java:5440)
	at com.xamarin.forms.platform.android.FormsViewGroup.measureAndLayout(FormsViewGroup.java:28)
	at md5b60ffeb829f638581ab2bb9b1a7f4f3f.VisualElementRenderer_1.n_onLayout(Native Method)
	at md5b60ffeb829f638581ab2bb9b1a7f4f3f.VisualElementRenderer_1.onLayout(VisualElementRenderer_1.java:72)
	at android.view.View.layout(View.java:16651)
	at android.view.ViewGroup.layout(ViewGroup.java:5440)
	at com.xamarin.forms.platform.android.FormsViewGroup.measureAndLayout(FormsViewGroup.java:28)
	at md5b60ffeb829f638581ab2bb9b1a7f4f3f.PageContainer.n_onLayout(Native Method)
	at md5b60ffeb829f638581ab2bb9b1a7f4f3f.PageContainer.onLayout(PageContainer.java:46)
	at android.view.View.layout(View.java:16651)
	at android.view.ViewGroup.layout(ViewGroup.java:5440)
	at android.support.v4.view.ViewPager.onLayout(ViewPager.java:1767)
	at android.view.View.layout(View.java:16651)
	at android.view.ViewGroup.layout(ViewGroup.java:5440)
	at md5270abb39e60627f0f200893b490a1ade.CarouselPageRenderer.n_onLayout(Native Method)
	at md5270abb39e60627f0f200893b490a1ade.CarouselPageRenderer.onLayout(CarouselPageRenderer.java:67)
	at android.view.View.layout(View.java:16651)
	at android.view.ViewGroup.layout(ViewGroup.java:5440)
	at com.xamarin.forms.platform.android.FormsViewGroup.measureAndLayout(FormsViewGroup.java:28)
	at md5270abb39e60627f0f200893b490a1ade.NavigationPageRenderer.n_onLayout(Native Method)
	at md5270abb39e60627f0f200893b490a1ade.NavigationPageRenderer.onLayout(NavigationPageRenderer.java:65)
	at android.view.View.layout(View.java:16651)
	at android.view.ViewGroup.layout(ViewGroup.java:5440)
	at com.xamarin.forms.platform.android.FormsViewGroup.measureAndLayout(FormsViewGroup.java:28)
	at md5270abb39e60627f0f200893b490a1ade.Platform_ModalContainer.n_onLayout(Native Method)
	at md5270abb39e60627f0f200893b490a1ade.Platform_ModalContainer.onLayout(Platform_ModalContainer.java:45)
	at android.view.View.layout(View.java:16651)
	at android.view.ViewGroup.layout(ViewGroup.java:5440)
	at md5b60ffeb829f638581ab2bb9b1a7f4f3f.PlatformRenderer.n_onLayout(Native Method)
	at md5b60ffeb829f638581ab2bb9b1a7f4f3f.PlatformRenderer.onLayout(PlatformRenderer.java:55)
	at android.view.View.layout(View.java:16651)
	at android.view.ViewGroup.layout(ViewGroup.java:5440)
	at android.widget.RelativeLayout.onLayout(RelativeLayout.java:1079)
	at android.view.View.layout(View.java:16651)
	at android.view.ViewGroup.layout(ViewGroup.java:5440)
	at android.widget.FrameLayout.layoutChildren(FrameLayout.java:336)
	at android.widget.FrameLayout.onLayout(FrameLayout.java:273)
	at android.view.View.layout(View.java:16651)
	at android.view.ViewGroup.layout(ViewGroup.java:5440)
	at android.widget.FrameLayout.layoutChildren(FrameLayout.java:336)
	at android.widget.FrameLayout.onLayout(FrameLayout.java:273)
	at android.view.View.layout(View.java:16651)
	at android.view.ViewGroup.layout(ViewGroup.java:5440)
	at android.widget.FrameLayout.layoutChildren(FrameLayout.java:336)
	at android.widget.FrameLayout.onLayout(FrameLayout.java:273)
	at android.view.View.layout(View.java:16651)
	at android.view.ViewGroup.layout(ViewGroup.java:5440)
	at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1743)
	at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1586)
	at android.widget.LinearLayout.onLayout(LinearLayout.java:1495)
	at android.view.View.layout(View.java:16651)
	at android.view.ViewGroup.layout(ViewGroup.java:5440)
	at android.widget.FrameLayout.layoutChildren(FrameLayout.java:336)
	at android.widget.FrameLayout.onLayout(FrameLayout.java:273)
	at com.android.internal.policy.PhoneWindow$DecorView.onLayout(PhoneWindow.java:2678)
	at android.view.View.layout(View.java:16651)
	at android.view.ViewGroup.layout(ViewGroup.java:5440)
	at android.view.ViewRootImpl.performLayout(ViewRootImpl.java:2183)
	at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1943)
	at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1119)
	at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:6060)
	at android.view.Choreographer$CallbackRecord.run(Choreographer.java:858)
	at android.view.Choreographer.doCallbacks(Choreographer.java:670)
	at android.view.Choreographer.doFrame(Choreographer.java:606)
	at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:844)
	at android.os.Handler.handleCallback(Handler.java:746)
	at android.os.Handler.dispatchMessage(Handler.java:95)
	at android.os.Looper.loop(Looper.java:148)
	at android.app.ActivityThread.main(ActivityThread.java:5443)
	at java.lang.reflect.Method.invoke(Native Method)
	at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:728)
	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)
Comment 9 Rein Vdst 2017-11-09 19:06:01 UTC
In case screenshots help

https://ibb.co/jFWfJG
https://ibb.co/jXUBQw
https://ibb.co/mih9Cb
Comment 10 ken 2017-11-22 05:41:08 UTC
I can confirm that no matter what HasUnevenRows is it crashes.
Comment 11 ken 2017-11-22 05:42:27 UTC
I ran into this issue when i tried to populate a ObservableCollection (asynchronously) that is databinded to a list view that has groups enabled.
Comment 12 Matteo Bortolu 2017-11-22 05:47:22 UTC
I've solved this downgrading Xamarin Forms to 2.4.0.38779 version
Comment 13 ken 2017-11-22 23:58:31 UTC
Matteo what version of Xamarin Forms were you running before?
Comment 14 Matteo Bortolu 2017-11-23 05:33:55 UTC
I had the issue after updating to the latest available stable version 2.5.0.91635 and was in same way related when pushing to a page containing a ListView with IsGroupingEnabled set as true.
Another workaround setting the IsGroupingEnabled as false. 
I decided to downgrade one by one the Xamarin Forms version until I found that 2.4.0.38779 was working as expected
Comment 15 Taylor Buchanan 2017-12-06 20:28:37 UTC
Same issue on 2.5.0.121934. Changing HasUnevenRows to False gets rid of the error for me, but this is not an acceptable workaround. Every new release of Xamarin seems to break something.
Comment 16 Ken Pespisa 2017-12-13 19:57:17 UTC
One more clue, potentially.

I noticed this was happening when my grouped list view had no elements in the first group. It was working fine when there were items in the first group. 

I'm not sure whether the fact the *first* group was empty matters or just any group.
Comment 17 halilgoecer 2017-12-15 01:06:47 UTC
I also have the same problem and it also does not happen if I set HasUnevenRows to false.

Stack trace:

  at Xamarin.Forms.ListProxy.get_Item (System.Int32 index) [0x0000b] in D:\agent\_work\1\s\Xamarin.Forms.Core\ListProxy.cs:127 
  at Xamarin.Forms.ListProxy.System.Collections.IList.get_Item (System.Int32 index) [0x00000] in D:\agent\_work\1\s\Xamarin.Forms.Core\ListProxy.cs:441 
  at Xamarin.Forms.Platform.iOS.ListViewRenderer+UnevenListViewDataSource.GetEstimatedRowHeight (UIKit.UITableView table) [0x00040] in D:\agent\_work\1\s\Xamarin.Forms.Platform.iOS\Renderers\ListViewRenderer.cs:673 
  at Xamarin.Forms.Platform.iOS.ListViewRenderer.UpdateEstimatedRowHeight () [0x0005f] in D:\agent\_work\1\s\Xamarin.Forms.Platform.iOS\Renderers\ListViewRenderer.cs:399 
  at Xamarin.Forms.Platform.iOS.ListViewRenderer.OnElementChanged (Xamarin.Forms.Platform.iOS.ElementChangedEventArgs`1[TElement] e) [0x001ab] in D:\agent\_work\1\s\Xamarin.Forms.Platform.iOS\Renderers\ListViewRenderer.cs:227 
  at Xamarin.Forms.Platform.iOS.VisualElementRenderer`1[TElement].SetElement (TElement element) [0x00110] in D:\agent\_work\1\s\Xamarin.Forms.Platform.iOS\VisualElementRenderer.cs:189 
  at Xamarin.Forms.Platform.iOS.VisualElementRenderer`1[TElement].Xamarin.Forms.Platform.iOS.IVisualElementRenderer.SetElement (Xamarin.Forms.VisualElement element) [0x00000] in D:\agent\_work\1\s\Xamarin.Forms.Platform.iOS\VisualElementRenderer.cs:140 
  at Xamarin.Forms.Platform.iOS.Platform.CreateRenderer (Xamarin.Forms.VisualElement element) [0x00014] in D:\agent\_work\1\s\Xamarin.Forms.Platform.iOS\Platform.cs:193 
  at Xamarin.Forms.Platform.iOS.VisualElementPackager.OnChildAdded (Xamarin.Forms.VisualElement view) [0x0002a] in D:\agent\_work\1\s\Xamarin.Forms.Platform.iOS\VisualElementPackager.cs:77 
  at Xamarin.Forms.Platform.iOS.VisualElementPackager.Load () [0x0001e] in D:\agent\_work\1\s\Xamarin.Forms.Platform.iOS\VisualElementPackager.cs:45 
  at Xamarin.Forms.Platform.iOS.VisualElementPackager.OnChildAdded (Xamarin.Forms.VisualElement view) [0x00024] in D:\agent\_work\1\s\Xamarin.Forms.Platform.iOS\VisualElementPackager.cs:75 
  at Xamarin.Forms.Platform.iOS.VisualElementPackager.Load () [0x0001e] in D:\agent\_work\1\s\Xamarin.Forms.Platform.iOS\VisualElementPackager.cs:45 
  at Xamarin.Forms.Platform.iOS.VisualElementRenderer`1[TElement].SetElement (TElement element) [0x000cc] in D:\agent\_work\1\s\Xamarin.Forms.Platform.iOS\VisualElementRenderer.cs:176 
  at Xamarin.Forms.Platform.iOS.VisualElementRenderer`1[TElement].Xamarin.Forms.Platform.iOS.IVisualElementRenderer.SetElement (Xamarin.Forms.VisualElement element) [0x00000] in D:\agent\_work\1\s\Xamarin.Forms.Platform.iOS\VisualElementRenderer.cs:140 
  at Xamarin.Forms.Platform.iOS.Platform.CreateRenderer (Xamarin.Forms.VisualElement element) [0x00014] in D:\agent\_work\1\s\Xamarin.Forms.Platform.iOS\Platform.cs:193 
  at Xamarin.Forms.Platform.iOS.VisualElementPackager.OnChildAdded (Xamarin.Forms.VisualElement view) [0x0002a] in D:\agent\_work\1\s\Xamarin.Forms.Platform.iOS\VisualElementPackager.cs:77 
  at Xamarin.Forms.Platform.iOS.VisualElementPackager.Load () [0x0001e] in D:\agent\_work\1\s\Xamarin.Forms.Platform.iOS\VisualElementPackager.cs:45 
  at Xamarin.Forms.Platform.iOS.PageRenderer.ViewDidLoad () [0x00086] in D:\agent\_work\1\s\Xamarin.Forms.Platform.iOS\Renderers\PageRenderer.cs:123 
  at (wrapper managed-to-native) ObjCRuntime.Messaging:IntPtr_objc_msgSendSuper (intptr,intptr)
  at UIKit.UIViewController.get_View () [0x00030] in /Users/builder/data/lanes/5665/6857dfcc/source/xamarin-macios/src/build/ios/native/UIKit/UIViewController.g.cs:2983 
  at Xamarin.Forms.Platform.iOS.PageRenderer.get_NativeView () [0x00000] in D:\agent\_work\1\s\Xamarin.Forms.Platform.iOS\Renderers\PageRenderer.cs:41 
  at Xamarin.Forms.Platform.iOS.PageRenderer.SetElement (Xamarin.Forms.VisualElement element) [0x0004f] in D:\agent\_work\1\s\Xamarin.Forms.Platform.iOS\Renderers\PageRenderer.cs:56 
  at Xamarin.Forms.Platform.iOS.Platform.CreateRenderer (Xamarin.Forms.VisualElement element) [0x00014] in D:\agent\_work\1\s\Xamarin.Forms.Platform.iOS\Platform.cs:193 
  at Xamarin.Forms.Platform.iOS.Platform.AddChild (Xamarin.Forms.VisualElement view) [0x00027] in D:\agent\_work\1\s\Xamarin.Forms.Platform.iOS\Platform.cs:327 
  at Xamarin.Forms.Platform.iOS.Platform.WillAppear () [0x0003c] in D:\agent\_work\1\s\Xamarin.Forms.Platform.iOS\Platform.cs:313 
  at Xamarin.Forms.Platform.iOS.PlatformRenderer.ViewWillAppear (System.Boolean animated) [0x00010] in D:\agent\_work\1\s\Xamarin.Forms.Platform.iOS\PlatformRenderer.cs:167 
  at (wrapper managed-to-native) ObjCRuntime.Messaging:void_objc_msgSend (intptr,intptr)
  at UIKit.UIWindow.MakeKeyAndVisible () [0x00010] in /Users/builder/data/lanes/5665/6857dfcc/source/xamarin-macios/src/build/ios/native/UIKit/UIWindow.g.cs:259 
  at Xamarin.Forms.Platform.iOS.FormsApplicationDelegate.SetMainPage () [0x00006] in D:\agent\_work\1\s\Xamarin.Forms.Platform.iOS\FormsApplicationDelegate.cs:159 
  at Xamarin.Forms.Platform.iOS.FormsApplicationDelegate.FinishedLaunching (UIKit.UIApplication uiApplication, Foundation.NSDictionary launchOptions) [0x00028] in D:\agent\_work\1\s\Xamarin.Forms.Platform.iOS\FormsApplicationDelegate.cs:45 
  at REAL_Shuffle_Player_Forms.iOS.AppDelegate.FinishedLaunching (UIKit.UIApplication app, Foundation.NSDictionary options) [0x0004e] in C:\Source\RSP\REAL Shuffle Player Forms\REAL_Shuffle_Player_Forms.iOS\AppDelegate.cs:35 
  at (wrapper managed-to-native) UIKit.UIApplication:UIApplicationMain (int,string[],intptr,intptr)
  at UIKit.UIApplication.Main (System.String[] args, System.IntPtr principal, System.IntPtr delegate) [0x00005] in /Users/builder/data/lanes/5665/6857dfcc/source/xamarin-macios/src/UIKit/UIApplication.cs:79 
  at UIKit.UIApplication.Main (System.String[] args, System.String principalClassName, System.String delegateClassName) [0x00038] in /Users/builder/data/lanes/5665/6857dfcc/source/xamarin-macios/src/UIKit/UIApplication.cs:63 
  at REAL_Shuffle_Player_Forms.iOS.Application.Main (System.String[] args) [0x00001] in C:\Source\RSP\REAL Shuffle Player Forms\REAL_Shuffle_Player_Forms.iOS\Main.cs:17
Comment 18 Rui Marinho 2018-01-02 10:59:35 UTC
Should be fixed on 2.6.0-pre1
Comment 19 Samantha Houts [MSFT] 2018-01-04 19:04:48 UTC
https://github.com/xamarin/Xamarin.Forms/pull/1463
Comment 20 Mat 2018-01-05 22:00:31 UTC
@Rui, when will 2.6.0-pre1 be available ?
Comment 21 Greg Cadmes 2018-01-16 20:17:24 UTC
I need to give a date to my CIO for when this will be fixed. 

The only work-a-round is unacceptable, which would be to set the 'HasUnevenRows = false'. Setting the property 'HasUnevenRows' to false doesn't work well when 'IsGropingEnabled'; that is, the grouped row get's the same size as all rows in the listview.

PLEASE HURRY and release the fix!
Comment 22 Nino Padrutt 2018-03-12 08:24:52 UTC
I have the same issue. Even with HasUnevenRows=False and height set it doesn't work. Any ETA till this fix does roll out?
Comment 23 Aleksandr Smyk 2018-03-17 09:23:22 UTC
I have the same issue even with 2.4.0.38779. When this issue will be fixed?
Comment 24 Andrew Hoefling 2018-04-12 02:47:55 UTC
After updating to 2.5.1.444934 the problem was resolved. I was running version 2.5.0.122203 which had this issue.
Comment 25 matteo 2018-04-12 09:06:14 UTC
Hello,
In XF 2.5.0.28.0555 I had no problem
With the last XF 2.5.1.444934 now I have this issue.

The problem is here even with HasUnevenRows=False.
My Listview is Grouped.

I think the problem is related to grouped listview.
Comment 26 David 2018-04-12 09:22:26 UTC
I can Confirm, the Bug exists in XF 2.5.1.444934 with grouped ListViews.
Comment 27 matteo 2018-04-12 09:25:10 UTC
One more info, maybe useful...

to create grouped listview I use this guide:
https://www.thewissen.io/xamarin-forms-listview-grouping/

that use MvvmHelpers with his ObservableRangeCollection:

-----
private readonly ObservableRangeCollection<Grouping<string, MyItem>> _myItems = new ObservableRangeCollection<Grouping<string, MyItem>>();
public ObservableCollection<Grouping<string, MyItem>> MyItems => _myItems;

...

var sorted = from item in myItems
             orderby item.Name
             group item by item.Name[0].ToString().ToUpperInvariant() into itemGroup
             select new Grouping<string, MyItem>(itemGroup.Key, itemGroup);

_myItems.ReplaceRange(sorted);

...

<ListView ItemsSource="{Binding MyItems}" GroupDisplayBinding="{Binding Key}" GroupShortNameBinding="{Binding Key}">
    ....
</ListView>
-----


hope it helps
Comment 28 Pravin Carvalho 2018-04-12 09:42:53 UTC
I see this issue too in XF 2.5.1.444934. Which version is this fixed in?
Comment 29 matteo 2018-04-12 09:54:10 UTC
Maybe I found a solution (for my case)

I have a grouped listview, with different templates and a UISegmentedControl
On 'segmentControl.ValueChanged' the viewmodel should re-populate the listview but when the 'MyItems.Clear();' is called, the error pop up. 

I made the following trick:

in my page behind code, on segmentControl.ValueChanged:

1) disable the grouping

                    listView.IsGroupingEnabled = false;
                    listView.GroupDisplayBinding = null;

2) clear the observablecollection

                    ViewModel.MyItems.Clear();

3) re-enable grouping
                    listView.IsGroupingEnabled = true;
                    listView.GroupDisplayBinding = new Binding("Key");

4) call the viewmodel command that will populate the listview..
                   ViewModel.LoadItemsCommand.Execute(null);

nb. ofc I remove the 'Clear()'from the viewmodel command

maybe my solution can be applied to your cases
Comment 30 scott 2018-04-13 19:39:00 UTC
Likewise - seeing this crash when removing the last item from a grouped list view with an ObservableCollection (even last item in a section).   New behavior as of XF 2.5.1.444934
Comment 31 scott 2018-04-13 19:48:14 UTC
Can confirm that turning off IsGroupEnabled prior to manipulating the observable collection seems to prevent the ArgumentOutOfRange exception in XF 2.5.1.444934
Comment 32 Nino Padrutt 2018-04-16 16:21:08 UTC
Same here. The solution of @matteo works so far for me.
Comment 33 me 2018-04-19 19:14:10 UTC
Same issue. I postponed upgrading from 2.3.4.270 because of closely related bug 59896. Today I finally had the chance to upgrade everything to most recent version and - dropping everything again because of more or less the same bug than 6 months ago.
Comment 34 Paulo Ortins 2018-04-25 14:26:27 UTC
Adding more info to this thread.

Tested with the version 2.5.0.280555 and it worked correctly.
2.5.1.444934 is crashing.
Comment 35 Dimitris Tavlikos 2018-04-26 12:48:55 UTC
I also confirm this issue with XF v2.5.1.444934. Matteo's solution works for me.
Comment 36 Aleksandr Smyk 2018-04-26 13:27:35 UTC
I also confirm this issue with XF v2.5.1.444934. I downgraded to 2.5.0.280555
Comment 37 Behrang 2018-05-02 05:45:09 UTC
After updating the XF, I got the same issue, put lots of efforts to fix it but didn't work.
Finally, downgraded to 2.5.0.280555 and almost fixed the issue.
iOS simulator after downgrade -> Works fine.
iOS device after downgrade -> thrown the exception.
Comment 38 Paulo Ortins 2018-05-04 18:56:20 UTC
Looks like it's fixed on the 2.5.1.527436.