Xamarin.Forms icon indicating copy to clipboard operation
Xamarin.Forms copied to clipboard

[Bug] [Android] System.ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection. Parameter name: index

Open govi2010 opened this issue 3 years ago • 35 comments

Description

System.ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index
  at System.Collections.Generic.List`1[T].get_Item (System.Int32 index) [0x00009] in <1cc14872b7b748718155dab8fb661b91>:0
  at System.Collections.Generic.List`1[T].System.Collections.IList.get_Item (System.Int32 index) [0x00000] in <1cc14872b7b748718155dab8fb661b91>:0
  at Xamarin.Forms.Platform.Android.ObservableItemsSource.ElementAt (System.Int32 index) [0x0000f] in <a62e492d2a9c482aa07a5a905a0d7044>:0
  at Xamarin.Forms.Platform.Android.ObservableItemsSource.GetItem (System.Int32 position) [0x00008] in <a62e492d2a9c482aa07a5a905a0d7044>:0
  at Xamarin.Forms.Platform.Android.UngroupedItemsSource.GetItem (System.Int32 position) [0x00000] in <a62e492d2a9c482aa07a5a905a0d7044>:0
  at Xamarin.Forms.Platform.Android.SelectableItemsViewAdapter`2[TItemsView,TItemsSource].UpdateFormsSelection (System.Int32 adapterPosition) [0x00025] in <a62e492d2a9c482aa07a5a905a0d7044>:0
  at Xamarin.Forms.Platform.Android.SelectableItemsViewAdapter`2[TItemsView,TItemsSource].SelectableClicked (System.Object sender, System.Int32 adapterPosition) [0x00000] in <a62e492d2a9c482aa07a5a905a0d7044>:0
  at Xamarin.Forms.Platform.Android.SelectableViewHolder.OnViewHolderClicked (System.Int32 adapterPosition) [0x0000a] in <a62e492d2a9c482aa07a5a905a0d7044>:0
  at Xamarin.Forms.Platform.Android.SelectableViewHolder.OnClick (Android.Views.View view) [0x0000f] in <a62e492d2a9c482aa07a5a905a0d7044>:0
  at Android.Views.View+IOnClickListenerInvoker.n_OnClick_Landroid_view_View_ (System.IntPtr jnienv, System.IntPtr native__this, System.IntPtr native_v) [0x0000f] in <616882d9d62c4d409fe71c90f889f536>:0
  at Android.Runtime.JNINativeWrapper.Wrap_JniMarshal_PPL_V (_JniMarshal_PPL_V callback, System.IntPtr jnienv, System.IntPtr klazz, System.IntPtr p0) [0x00005] in <616882d9d62c4d409fe71c90f889f536>:0

Steps to Reproduce

There are no steps. This crashes the system randomly. I have CollectionView on the screen which has a product list. CollectionView is having single selection option. I never got this crash on debug environment. But Crashes on production and I got these logs from AppCenter. CollectionView is having ReadOnlyObservableCollection as datasource.

Expected Behavior

The app should not crash.

Actual Behavior

The app crashes after 30+ min usage.

Basic Information

  • Version with issue: Xamarin.Forms version 5.0.0.2401
  • Android: Android 12 - SDK 31

govi2010 avatar Jun 22 '22 15:06 govi2010

I see the same Error on my production app as well. Without a repro.

Seuleuzeuh avatar Jun 22 '22 17:06 Seuleuzeuh

@Seuleuzeuh Do you have any specific case? do you have CollectionView on Screen ?

govi2010 avatar Jun 23 '22 08:06 govi2010

It might be a bit of a long shot, but does this still happen in the latest version being 5.0.0.2478?

jfversluis avatar Jun 23 '22 11:06 jfversluis

@jfversluis I have new tried with version 5.0.0.2478. But there are not many changes for collectionView in 5.0.0.2401 and '5.0.0.2478'

govi2010 avatar Jun 23 '22 11:06 govi2010

@govi2010 you mention "The app crashes after 30+ min usage." if you just keep the app running for 30 minutes without doing anything this happens or if you just use the app like regular? Is there 1 action that you could identify that triggers this?

@Seuleuzeuh do you have any information at all? Stack trace looks the same? Any indication on what actions users are taking that triggers this?

jfversluis avatar Jun 23 '22 11:06 jfversluis

@jfversluis 30+ mins usage means actively using it. This is a POS system which is having products in the collection view.

govi2010 avatar Jun 23 '22 11:06 govi2010

Looking at this code it seems to have to do with the CollectionView having a header. Could you maybe add more infomation and/or relevant code on what you CollectionView looks like?

jfversluis avatar Jun 23 '22 11:06 jfversluis

@jfversluis
Bindings are done from code behind using reactive-ui

   d(this.OneWayBind(ViewModel, vm => vm.ShowingMenu, v => v.MenuDisplay.IsVisible));
   d(this.OneWayBind(ViewModel, vm => vm.MenuProducts, v => v.MenuProducts.ItemsSource));

Below is the structure of my CollectionView

   <Grid
            x:Name="MenuDisplay"
            Grid.Row="1"
            Grid.RowSpan="2"
            Grid.Column="1"
            Padding="5,0">
            <Grid>
                <CollectionView
                    x:Name="MenuProducts"
                    ItemSizingStrategy="MeasureAllItems"
                    SelectionMode="Single"
                    VerticalOptions="StartAndExpand">
                    <CollectionView.ItemsLayout>
                        <GridItemsLayout
                            HorizontalItemSpacing="10"
                            Orientation="Vertical"
                            Span="4"
                            VerticalItemSpacing="20" />
                    </CollectionView.ItemsLayout>
                    <CollectionView.EmptyView>
                        <Grid>
                            <Label
                                x:Name="MenuLoadingText"
                                FontFamily="MontserratBold"
                                FontSize="32"
                                HorizontalTextAlignment="Center"
                                VerticalTextAlignment="Center" />
                        </Grid>
                    </CollectionView.EmptyView>
                    <CollectionView.ItemTemplate>
                        <DataTemplate>
                            <Frame
                                Padding="5"
                                BackgroundColor="Transparent"
                                CornerRadius="50"
                                IsClippedToBounds="True">
                                <Frame
                                    x:Name="MenuProducts_ProductBackground"
                                    Padding="0"
                                    InputTransparent="True"
                                    BackgroundColor="{Binding ProductGroupColor}"
                                    CornerRadius="40"
                                    HasShadow="False"
                                    HeightRequest="175"
                                    IsClippedToBounds="True">
                                    <Grid
                                        Padding="0"
                                        InputTransparent="True"
                                        ColumnDefinitions="*"
                                        RowDefinitions="Auto,*,Auto">
                                        <Label
                                            x:Name="MenuProducts_ProductName"
                                            Grid.Row="0"
                                            Padding="20,20,0,0"
                                            FontFamily="MontserratBold"
                                            FontSize="16"
                                            HorizontalOptions="Start"
                                            Text="{Binding ProductDescription}"
                                            TextColor="White"
                                            VerticalOptions="Start" />

                                        <CollectionView
                                            InputTransparent="True"
                                             x:Name="MenuProducts_ProductAllergens"
                                            Grid.Row="1"
                                            Margin="0,0,25,0"
                                            ItemsUpdatingScrollMode="KeepItemsInView"
                                            Rotation="180"
                                            ItemsSource="{Binding Allergens}">
                                            <CollectionView.ItemsLayout>
                                                <LinearItemsLayout ItemSpacing="10" Orientation="Horizontal" />
                                            </CollectionView.ItemsLayout>
                                            <CollectionView.ItemTemplate>
                                                <DataTemplate x:DataType="models:ProductAllergen">
                                                    <StackLayout
                                                                BackgroundColor="Transparent"
                                                                HorizontalOptions="Fill"
                                                                VerticalOptions="Fill">
                                                        <!--<StackLayout.GestureRecognizers>
                                                                <TapGestureRecognizer NumberOfTapsRequired="1" Tapped="TapGestureRecognizer_OnTapped" />
                                                            </StackLayout.GestureRecognizers>-->
                                                        <Image
                                                                Aspect="AspectFit"
                                                                HeightRequest="25"
                                                                Rotation="180"
                                                                Source="{Binding Thumbnail}"
                                                                VerticalOptions="StartAndExpand"
                                                                WidthRequest="25" />
                                                    </StackLayout>
                                                </DataTemplate>
                                            </CollectionView.ItemTemplate>
                                        </CollectionView>
                                        <Grid Grid.Row="1"/>
                                        <Label
                                            x:Name="MenuProducts_ProductPrice"
                                            Grid.Row="2"
                                            Padding="0,0,20,20"
                                            FontFamily="MontserratBold"
                                            FontSize="16"
                                            HorizontalOptions="End"
                                            Text="{Binding ProductPrice}"
                                            TextColor="White"
                                            VerticalOptions="End" />
                                    </Grid>
                                </Frame>
                                <VisualStateManager.VisualStateGroups>
                                    <VisualStateGroup Name="CommonStates">
                                        <VisualState Name="Selected">
                                            <VisualState.Setters>
                                                <Setter Property="Frame.BackgroundColor" Value="Transparent" />
                                            </VisualState.Setters>
                                        </VisualState>
                                    </VisualStateGroup>
                                </VisualStateManager.VisualStateGroups>
                            </Frame>
                        </DataTemplate>
                    </CollectionView.ItemTemplate>
                </CollectionView>
            </Grid>
        </Grid>

govi2010 avatar Jun 23 '22 11:06 govi2010

One thing is that it is having nested CollectionView

govi2010 avatar Jun 23 '22 11:06 govi2010

@Seuleuzeuh do you have any information at all? Stack trace looks the same? Any indication on what actions users are taking that triggers this?

Hi @jfversluis thanks for looking into this issue.
Same stack trace, with similar usage of collection of products, sometimes with more than 1000 lines. Also with an auto selection/scroll on product scanned (device with barcode reader), and also adding new product on scan.

Here is the stacktrace :

Package: com.Isipharm.Leo.Mobile.Utilisateur.App
Version Code: 207
Version Name: 2.0.7
Android: 8.1.0
Android Build: OPM1.171019.019
Manufacturer: Honeywell
Model: EDA51
CrashReporter Key: 61acbefc-a762-4997-bc2c-9eb18ffe702a
Start Date: 2022-06-17T13:20:51.599Z
Date: 2022-06-17T16:49:29.682Z

Xamarin Exception Stack:
System.ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index
  at System.Collections.Generic.List`1[T].get_Item (System.Int32 index) [0x00009] in <e9322be6211b4cf1975a11da77cb5672>:0
  at System.Collections.Generic.List`1[T].System.Collections.IList.get_Item (System.Int32 index) [0x00000] in <e9322be6211b4cf1975a11da77cb5672>:0
  at Xamarin.Forms.Platform.Android.ObservableItemsSource.ElementAt (System.Int32 index) [0x0000f] in <744976dfeeb14f478d00a95d5a450b39>:0
  at Xamarin.Forms.Platform.Android.ObservableItemsSource.GetItem (System.Int32 position) [0x00008] in <744976dfeeb14f478d00a95d5a450b39>:0
  at Xamarin.Forms.Platform.Android.UngroupedItemsSource.GetItem (System.Int32 position) [0x00000] in <744976dfeeb14f478d00a95d5a450b39>:0
  at Xamarin.Forms.Platform.Android.SelectableItemsViewAdapter`2[TItemsView,TItemsSource].UpdateFormsSelection (System.Int32 adapterPosition) [0x00025] in <744976dfeeb14f478d00a95d5a450b39>:0
  at Xamarin.Forms.Platform.Android.SelectableItemsViewAdapter`2[TItemsView,TItemsSource].SelectableClicked (System.Object sender, System.Int32 adapterPosition) [0x00000] in <744976dfeeb14f478d00a95d5a450b39>:0
  at Xamarin.Forms.Platform.Android.SelectableViewHolder.OnViewHolderClicked (System.Int32 adapterPosition) [0x0000a] in <744976dfeeb14f478d00a95d5a450b39>:0
  at Xamarin.Forms.Platform.Android.SelectableViewHolder.OnClick (Android.Views.View view) [0x0000f] in <744976dfeeb14f478d00a95d5a450b39>:0
  at Android.Views.View+IOnClickListenerInvoker.n_OnClick_Landroid_view_View_ (System.IntPtr jnienv, System.IntPtr native__this, System.IntPtr native_v) [0x0000f] in <a46c67c91bf74862805083ceb709d165>:0
  at (wrapper dynamic-method) Android.Runtime.DynamicMethodNameCounter.61(intptr,intptr,intptr)

According to my local device log, it's coming after a line deletion (with a SwipeView) in the collection (CollectionView) binded to an ObservableCollection. I'm unable de reproduce the issue, with the same material and context/datas on release or debug mode.

This AppCenter log can perhaps be usefull :

Thread 2:
0   dalvik.system.VMStack.getThreadStackTrace(VMStack.java:-2)
1   java.lang.Thread.getStackTrace(Thread.java:1538)
2   java.lang.Thread.getAllStackTraces(Thread.java:1588)
3   com.microsoft.appcenter.crashes.Crashes.saveUncaughtException(Crashes.java:1146)
4   com.microsoft.appcenter.crashes.WrapperSdkExceptionManager.saveWrapperException(WrapperSdkExceptionManager.java:58)
5   crc643f46942d9dd1fff9.SelectableViewHolder.n_onClick(SelectableViewHolder.java:-2)
6   crc643f46942d9dd1fff9.SelectableViewHolder.onClick(SelectableViewHolder.java:30)
7   android.view.View.callOnClick(View.java:6318)
8   crc643f46942d9dd1fff9.SwipeViewRenderer.n_dispatchTouchEvent(SwipeViewRenderer.java:-2)
9   crc643f46942d9dd1fff9.SwipeViewRenderer.dispatchTouchEvent(SwipeViewRenderer.java:72)
10  android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2968)
11  android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2657)
12  crc643f46942d9dd1fff9.Platform_DefaultRenderer.n_dispatchTouchEvent(Platform_DefaultRenderer.java:-2)
13  crc643f46942d9dd1fff9.Platform_DefaultRenderer.dispatchTouchEvent(Platform_DefaultRenderer.java:56)
14  android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2968)
15  android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2657)
16  android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2968)
17  android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2657)
18  android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2968)
19  android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2657)
20  crc643f46942d9dd1fff9.Platform_DefaultRenderer.n_dispatchTouchEvent(Platform_DefaultRenderer.java:-2)
21  crc643f46942d9dd1fff9.Platform_DefaultRenderer.dispatchTouchEvent(Platform_DefaultRenderer.java:56)
22  android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2968)
23  android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2657)
24  crc643f46942d9dd1fff9.Platform_DefaultRenderer.n_dispatchTouchEvent(Platform_DefaultRenderer.java:-2)
25  crc643f46942d9dd1fff9.Platform_DefaultRenderer.dispatchTouchEvent(Platform_DefaultRenderer.java:56)
26  android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2968)
27  android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2657)
28  crc643f46942d9dd1fff9.Platform_DefaultRenderer.n_dispatchTouchEvent(Platform_DefaultRenderer.java:-2)
29  crc643f46942d9dd1fff9.Platform_DefaultRenderer.dispatchTouchEvent(Platform_DefaultRenderer.java:56)
30  android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2968)
31  android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2657)
32  crc643f46942d9dd1fff9.Platform_DefaultRenderer.n_dispatchTouchEvent(Platform_DefaultRenderer.java:-2)
33  crc643f46942d9dd1fff9.Platform_DefaultRenderer.dispatchTouchEvent(Platform_DefaultRenderer.java:56)
34  android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2968)
35  android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2657)
36  crc643f46942d9dd1fff9.Platform_DefaultRenderer.n_dispatchTouchEvent(Platform_DefaultRenderer.java:-2)
37  crc643f46942d9dd1fff9.Platform_DefaultRenderer.dispatchTouchEvent(Platform_DefaultRenderer.java:56)
38  android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2968)
39  android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2657)
40  crc643f46942d9dd1fff9.Platform_DefaultRenderer.n_dispatchTouchEvent(Platform_DefaultRenderer.java:-2)
41  crc643f46942d9dd1fff9.Platform_DefaultRenderer.dispatchTouchEvent(Platform_DefaultRenderer.java:56)
42  android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2968)
43  android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2657)
44  crc643f46942d9dd1fff9.Platform_DefaultRenderer.n_dispatchTouchEvent(Platform_DefaultRenderer.java:-2)
45  crc643f46942d9dd1fff9.Platform_DefaultRenderer.dispatchTouchEvent(Platform_DefaultRenderer.java:56)
46  android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2968)
47  android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2657)
48  crc643f46942d9dd1fff9.VisualElementRenderer_1.n_dispatchTouchEvent(VisualElementRenderer_1.java:-2)
49  crc643f46942d9dd1fff9.VisualElementRenderer_1.dispatchTouchEvent(VisualElementRenderer_1.java:68)
50  android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2968)
51  android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2657)
52  android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2968)
53  android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2657)
54  android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2968)
55  android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2657)
56  android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2968)
57  android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2657)
58  android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2968)
59  android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2657)
60  android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2968)
61  android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2657)
62  android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2968)
63  android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2657)
64  crc643f46942d9dd1fff9.PlatformRenderer.n_dispatchTouchEvent(PlatformRenderer.java:-2)
65  crc643f46942d9dd1fff9.PlatformRenderer.dispatchTouchEvent(PlatformRenderer.java:47)
66  android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2968)
67  android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2657)
68  android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2968)
69  android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2657)
70  android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2968)
71  android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2657)
72  android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2968)
73  android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2657)
74  android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2968)
75  android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2657)
76  android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2968)
77  android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2657)
78  com.android.internal.policy.DecorView.superDispatchTouchEvent(DecorView.java:465)
79  com.android.internal.policy.PhoneWindow.superDispatchTouchEvent(PhoneWindow.java:1829)
80  android.app.Activity.dispatchTouchEvent(Activity.java:3321)
81  androidx.appcompat.view.WindowCallbackWrapper.dispatchTouchEvent(WindowCallbackWrapper.java:69)
82  androidx.appcompat.view.WindowCallbackWrapper.dispatchTouchEvent(WindowCallbackWrapper.java:69)
83  com.android.internal.policy.DecorView.dispatchTouchEvent(DecorView.java:427)
84  android.view.View.dispatchPointerEvent(View.java:12016)
85  android.view.ViewRootImpl$ViewPostImeInputStage.processPointerEvent(ViewRootImpl.java:4806)
86  android.view.ViewRootImpl$ViewPostImeInputStage.onProcess(ViewRootImpl.java:4620)
87  android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:4158)
88  android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:4211)
89  android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:4177)
90  android.view.ViewRootImpl$AsyncInputStage.forward(ViewRootImpl.java:4304)
91  android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:4185)
92  android.view.ViewRootImpl$AsyncInputStage.apply(ViewRootImpl.java:4361)
93  android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:4158)
94  android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:4211)
95  android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:4177)
96  android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:4185)
97  android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:4158)
98  android.view.ViewRootImpl.deliverInputEvent(ViewRootImpl.java:6679)
99  android.view.ViewRootImpl.doProcessInputEvents(ViewRootImpl.java:6653)
100 android.view.ViewRootImpl.enqueueInputEvent(ViewRootImpl.java:6614)
101 android.view.ViewRootImpl$WindowInputEventReceiver.onInputEvent(ViewRootImpl.java:6782)
102 android.view.InputEventReceiver.dispatchInputEvent(InputEventReceiver.java:187)
103 android.os.MessageQueue.nativePollOnce(MessageQueue.java:-2)
104 android.os.MessageQueue.next(MessageQueue.java:325)
105 android.os.Looper.loop(Looper.java:142)
106 android.app.ActivityThread.main(ActivityThread.java:6530)
107 java.lang.reflect.Method.invoke(Method.java:-2)
108 com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)
109 com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)

It might be a bit of a long shot, but does this still happen in the latest version being 5.0.0.2478?

I've push an update with this version 2 days ago, we need time to collect usage data (we have an average of 5 crash by month for ~= 600 users).

Seuleuzeuh avatar Jun 23 '22 13:06 Seuleuzeuh

@jfversluis Any workaround you can suggest? or any idea where exactly the issue is?

govi2010 avatar Jun 24 '22 11:06 govi2010

@govi2010 unfortunately not at the moment yet! When did you start seeing this? When upgrading to 2401 or earlier or don't know?

jfversluis avatar Jun 24 '22 11:06 jfversluis

@jfversluis First instance of this Crash report was on May 25, 8:34 PM as per my App center logs. On May 12 we updated Xamarin.Forms Version="5.0.0.2012" To Xamarin.Forms Version="5.0.0.2401". I think this is something with 5.0.0.2401 release.

govi2010 avatar Jun 24 '22 11:06 govi2010

I guess this seems like a potential culprit then: https://github.com/xamarin/Xamarin.Forms/pull/15236

jfversluis avatar Jun 24 '22 11:06 jfversluis

@jfversluis I also was following #15236 But I was not sure if that can cause the issue. Is this fixed in 5.0.0.2478? Will upgrade fix the issue ?

govi2010 avatar Jun 24 '22 11:06 govi2010

@jfversluis #15236 is part of 5.0.0.2401. I think a downgrade to 5.0.0.2337 Should stop this crash for now. Correct me If I am wrong.

govi2010 avatar Jun 24 '22 12:06 govi2010

I realize that you have mentioned that it's hard to reproduce the bug, but a PR (#15442) for this is open now, it would be awesome if you could grab the NuGet as described here and let us know if this fixes this issue.

I do not recommend using this NuGet in production, so that's where this gets a bit hard I guess 😅 but if you are somehow able to test if this fixes the issue that would be great! Please let me know.

Besides verifying if this particular issue is fixed also be sure to check other scenarios in the same area to make sure that this fix doesn't accidentally has side-effects 🙂

Thanks!

jfversluis avatar Jun 27 '22 09:06 jfversluis

@jfversluis Sorry for the late reply . . . . . I will get these changes tested by my QA and also one of my production clients later. I really appreciate for quick code changes and quick replies on that issues. I also thank you for the media content you post on youtube and blog articles.

govi2010 avatar Jun 29 '22 08:06 govi2010

@jfversluis Till now we have not gotten any crash reports on the App center in the last 10 days. I think these changes fixed our crash issue.

govi2010 avatar Jul 11 '22 08:07 govi2010

Thanks for checking! Unfortunately this PR does reintroduce this initial bug. So the work is not complete on this one yet 😅

jfversluis avatar Jul 11 '22 20:07 jfversluis

@jfversluis I just got app crashes again. You are right. The issue is not fixed. yesterday I got 6 crash reports.

List`1[T].get_Item (System.Int32 index)
System.ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection. Parameter name: index

List`1[T].get_Item (System.Int32 index)
IList.get_Item (System.Int32 index)
ObservableItemsSource.ElementAt (System.Int32 index)
ObservableItemsSource.GetItem (System.Int32 position)
UngroupedItemsSource.GetItem (System.Int32 position)
SelectableItemsViewAdapter`2[TItemsView,TItemsSource].UpdateFormsSelection (System.Int32 adapterPosition)
SelectableItemsViewAdapter`2[TItemsView,TItemsSource].SelectableClicked (System.Object sender, System.Int32 adapterPosition)
SelectableViewHolder.OnViewHolderClicked (System.Int32 adapterPosition)
SelectableViewHolder.OnClick (Android.Views.View view)
View+IOnClickListenerInvoker.n_OnClick_Landroid_view_View_ (System.IntPtr jnienv, System.IntPtr native__this, System.IntPtr native_v)
JNINativeWrapper.Wrap_JniMarshal_PPL_V (_JniMarshal_PPL_V callback, System.IntPtr jnienv, System.IntPtr klazz, System.IntPtr p0)

govi2010 avatar Jul 20 '22 11:07 govi2010

@jfversluis any thoughts on crash?

govi2010 avatar Jul 25 '22 05:07 govi2010

Still getting the crash reports on the App center. Can anyone have some idea what the issue could be?

govi2010 avatar Jul 26 '22 12:07 govi2010

I also got this problem. Does anyone have any ideas?

dimonovdd avatar Aug 03 '22 21:08 dimonovdd

I am also seeing this issue

jared-morley avatar Aug 04 '22 00:08 jared-morley

@jared-morley and @dimonovdd
I am still waiting for a reply from the Xamarin team.

Today also I got the same crash. I am totally stuck because I don't know what to do about this crash as it is not pointing me to any specific conclusion.

Start Date: 2022-09-05T10:20:34.476Z
Date: 2022-09-05T10:35:21.587Z

Xamarin Exception Stack:
System.ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index
  at System.Collections.Generic.List`1[T].get_Item (System.Int32 index) [0x00009] in <2805893ac818440b82a3ddec1fa4b041>:0
  at System.Collections.Generic.List`1[T].System.Collections.IList.get_Item (System.Int32 index) [0x00000] in <2805893ac818440b82a3ddec1fa4b041>:0
  at Xamarin.Forms.Platform.Android.ObservableItemsSource.ElementAt (System.Int32 index) [0x00015] in <f490006649234f2ab9855ff2df074b99>:0
  at Xamarin.Forms.Platform.Android.ObservableItemsSource.GetItem (System.Int32 position) [0x00009] in <f490006649234f2ab9855ff2df074b99>:0
  at Xamarin.Forms.Platform.Android.UngroupedItemsSource.GetItem (System.Int32 position) [0x00001] in <f490006649234f2ab9855ff2df074b99>:0
  at Xamarin.Forms.Platform.Android.SelectableItemsViewAdapter`2[TItemsView,TItemsSource].UpdateFormsSelection (System.Int32 adapterPosition) [0x0002e] in <f490006649234f2ab9855ff2df074b99>:0
  at Xamarin.Forms.Platform.Android.SelectableItemsViewAdapter`2[TItemsView,TItemsSource].SelectableClicked (System.Object sender, System.Int32 adapterPosition) [0x00001] in <f490006649234f2ab9855ff2df074b99>:0
  at Xamarin.Forms.Platform.Android.SelectableViewHolder.OnViewHolderClicked (System.Int32 adapterPosition) [0x0000b] in <f490006649234f2ab9855ff2df074b99>:0
  at Xamarin.Forms.Platform.Android.SelectableViewHolder.OnClick (Android.Views.View view) [0x00013] in <f490006649234f2ab9855ff2df074b99>:0
  at Android.Views.View+IOnClickListenerInvoker.n_OnClick_Landroid_view_View_ (System.IntPtr jnienv, System.IntPtr native__this, System.IntPtr native_v) [0x0000f] in <3390f20663814350832f6386478f3289>:0
  at Android.Runtime.JNINativeWrapper.Wrap_JniMarshal_PPL_V (_JniMarshal_PPL_V callback, System.IntPtr jnienv, System.IntPtr klazz, System.IntPtr p0) [0x00005] in <3390f20663814350832f6386478f3289>:0

Thread 2:
0   dalvik.system.VMStack.getThreadStackTrace(VMStack.java:-2)
1   java.lang.Thread.getStackTrace(Thread.java:1720)
2   java.lang.Thread.getAllStackTraces(Thread.java:1796)
3   com.microsoft.appcenter.crashes.Crashes.saveUncaughtException(Crashes.java:1146)
4   com.microsoft.appcenter.crashes.WrapperSdkExceptionManager.saveWrapperException(WrapperSdkExceptionManager.java:58)
5   crc643f46942d9dd1fff9.SelectableViewHolder.n_onClick(SelectableViewHolder.java:-2)
6   crc643f46942d9dd1fff9.SelectableViewHolder.onClick(SelectableViewHolder.java:31)
7   android.view.View.performClick(View.java:7147)
8   android.view.View.performClickInternal(View.java:7120)
9   android.view.View.access$3500(View.java:804)
10  android.view.View$PerformClick.run(View.java:27538)
11  android.os.Handler.handleCallback(Handler.java:883)
12  android.os.Handler.dispatchMessage(Handler.java:100)
13  android.os.Looper.loop(Looper.java:214)
14  android.app.ActivityThread.main(ActivityThread.java:7399)
15  java.lang.reflect.Method.invoke(Method.java:-2)
16  com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:502)
17  com.android.internal.os.ZygoteInit.main(ZygoteInit.java:980)

Thread 2617:
0   java.lang.Object.wait(Object.java:-2)
1   java.lang.Object.wait(Object.java:442)
2   java.lang.Object.wait(Object.java:568)
3   java.lang.Daemons$ReferenceQueueDaemon.runInternal(Daemons.java:215)
4   java.lang.Daemons$Daemon.run(Daemons.java:137)
5   java.lang.Thread.run(Thread.java:919)

Thread 2618:
0   java.lang.Object.wait(Object.java:-2)
1   java.lang.Object.wait(Object.java:442)
2   java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:190)
3   java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:211)
4   java.lang.Daemons$FinalizerDaemon.runInternal(Daemons.java:271)
5   java.lang.Daemons$Daemon.run(Daemons.java:137)
6   java.lang.Thread.run(Thread.java:919)

Thread 2619:
0   java.lang.Thread.sleep(Thread.java:-2)
1   java.lang.Thread.sleep(Thread.java:440)
2   java.lang.Thread.sleep(Thread.java:356)
3   java.lang.Daemons$FinalizerWatchdogDaemon.sleepForMillis(Daemons.java:383)
4   java.lang.Daemons$FinalizerWatchdogDaemon.waitForFinalization(Daemons.java:411)
5   java.lang.Daemons$FinalizerWatchdogDaemon.runInternal(Daemons.java:323)
6   java.lang.Daemons$Daemon.run(Daemons.java:137)
7   java.lang.Thread.run(Thread.java:919)

Thread 2625:
0   sun.misc.Unsafe.park(Unsafe.java:-2)
1   java.util.concurrent.locks.LockSupport.park(LockSupport.java:190)
2   java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await(AbstractQueuedSynchronizer.java:2067)
3   java.util.concurrent.LinkedBlockingQueue.take(LinkedBlockingQueue.java:442)
4   java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:1092)
5   java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1152)
6   java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
7   java.lang.Thread.run(Thread.java:919)

Thread 2627:
0   sun.misc.Unsafe.park(Unsafe.java:-2)
1   java.util.concurrent.locks.LockSupport.park(LockSupport.java:190)
2   java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await(AbstractQueuedSynchronizer.java:2067)
3   java.util.concurrent.LinkedBlockingQueue.take(LinkedBlockingQueue.java:442)
4   java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:1092)
5   java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1152)
6   java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
7   java.lang.Thread.run(Thread.java:919)

Thread 2630:
0   android.os.MessageQueue.nativePollOnce(MessageQueue.java:-2)
1   android.os.MessageQueue.next(MessageQueue.java:336)
2   android.os.Looper.loop(Looper.java:174)
3   android.os.HandlerThread.run(HandlerThread.java:67)

Thread 2632:
0   android.os.MessageQueue.nativePollOnce(MessageQueue.java:-2)
1   android.os.MessageQueue.next(MessageQueue.java:336)
2   android.os.Looper.loop(Looper.java:174)
3   android.os.HandlerThread.run(HandlerThread.java:67)

Thread 2633:
0   android.os.MessageQueue.nativePollOnce(MessageQueue.java:-2)
1   android.os.MessageQueue.next(MessageQueue.java:336)
2   android.os.Looper.loop(Looper.java:174)
3   android.os.HandlerThread.run(HandlerThread.java:67)

Thread 2647:
0   java.lang.Object.wait(Object.java:-2)
1   com.android.okhttp.ConnectionPool$1.run(ConnectionPool.java:106)
2   java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
3   java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
4   java.lang.Thread.run(Thread.java:919)

Thread 2648:
0   java.lang.Object.wait(Object.java:-2)
1   com.android.okhttp.okio.AsyncTimeout.awaitTimeout(AsyncTimeout.java:325)
2   com.android.okhttp.okio.AsyncTimeout.access$000(AsyncTimeout.java:42)
3   com.android.okhttp.okio.AsyncTimeout$Watchdog.run(AsyncTimeout.java:288)

Thread 2649:
0   android.renderscript.RenderScript.nContextPeekMessage(RenderScript.java:-2)
1   android.renderscript.RenderScript$MessageThread.run(RenderScript.java:1295)

Thread 2667:
0   android.os.MessageQueue.nativePollOnce(MessageQueue.java:-2)
1   android.os.MessageQueue.next(MessageQueue.java:336)
2   android.os.Looper.loop(Looper.java:174)
3   android.os.HandlerThread.run(HandlerThread.java:67)

Thread 2668:
0   sun.misc.Unsafe.park(Unsafe.java:-2)
1   java.util.concurrent.locks.LockSupport.park(LockSupport.java:190)
2   java.util.concurrent.SynchronousQueue$TransferStack.awaitFulfill(SynchronousQueue.java:459)
3   java.util.concurrent.SynchronousQueue$TransferStack.transfer(SynchronousQueue.java:362)
4   java.util.concurrent.SynchronousQueue.take(SynchronousQueue.java:920)
5   java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:1092)
6   java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1152)
7   java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
8   java.lang.Thread.run(Thread.java:919)

govi2010 avatar Sep 05 '22 11:09 govi2010

I am having similar issue, when an Emoji(not all types, but major ones) is present in a Label control inside a ViewCell my App crashes, but if I remove the Emojis using this line of code //Remove Emojis that cuases App to Crash. newValue = Regex.Replace(newValue as string, @"\p{Cs}", ""); it will not crash except for Android 8.0.

Here is the stack trace: Fatal Exception: android.runtime.JavaProxyThrowable System.ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection. Parameter name: index at System.Collections.Generic.List1[T].get_Item (System.Int32 index) [0x00009] in <02432465956f42cebcacad2804482ab1>:0 at System.Collections.ObjectModel.Collection1[T].get_Item (System.Int32 index) [0x00000] in <02432465956f42cebcacad2804482ab1>:0 at Xamarin.Forms.Platform.Android.TextViewExtensions.RecalculateSpanPositions (Android.Widget.TextView textView, Xamarin.Forms.Label element, Android.Text.SpannableString spannableString, Xamarin.Forms.SizeRequest finalSize) [0x000d4] in <d44af6b8e39d430ab4f7200fe9236d74>:0 at Xamarin.Forms.Platform.Android.FastRenderers.LabelAppCompatRenderer.OnLayout (System.Boolean changed, System.Int32 left, System.Int32 top, System.Int32 right, System.Int32 bottom) [0x0002e] in <d44af6b8e39d430ab4f7200fe9236d74>:0 at Android.Views.View.n_OnLayout_ZIIII (System.IntPtr jnienv, System.IntPtr native__this, System.Boolean changed, System.Int32 left, System.Int32 top, System.Int32 right, System.Int32 bottom) [0x00008] in <bc2d50452a6d44b19b23f115b54a5b89>:0 at Android.Runtime.JNINativeWrapper.Wrap_JniMarshal_PPZIIII_V (_JniMarshal_PPZIIII_V callback, System.IntPtr jnienv, System.IntPtr klazz, System.Boolean p0, System.Int32 p1, System.Int32 p2, System.Int32 p3, System.Int32 p4) [0x00005] in <bc2d50452a6d44b19b23f115b54a5b89>:0 --- End of stack trace from previous location where exception was thrown --- at Java.Interop.JniEnvironment+InstanceMethods.CallNonvirtualVoidMethod (Java.Interop.JniObjectReference instance, Java.Interop.JniObjectReference type, Java.Interop.JniMethodInfo method, Java.Interop.JniArgumentValue* args) [0x0008e] in <7e03103f89a04cb0a4ba149e2c0c72ff>:0 at Java.Interop.JniPeerMembers+JniInstanceMethods.InvokeVirtualVoidMethod (System.String encodedMember, Java.Interop.IJavaPeerable self, Java.Interop.JniArgumentValue* parameters) [0x00076] in <7e03103f89a04cb0a4ba149e2c0c72ff>:0 at Android.Views.Vi<truncated: 9778 chars>

It is happening here: crc643f46942d9dd1fff9.ViewCellRenderer_ViewCellContainer.n_onLayout And I'm on Xamarin.Forms build 5.0.0.2515

johnifegwu avatar Oct 18 '22 16:10 johnifegwu

This is really interesting because I get this type of crashes on iOS and the same as others its random, impossible to reproduce.

Stacktrace: Xamarin Exception Stack: System.ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection. Parameter name: index at System.Collections.Generic.List1[T].get_Item (System.Int32 index) <0x100be3570 + 0x00063> in <25bf495f7d6b4944aa395b3ab5293479#9a1d60584182f10a46e79ea061bda477>:0 at System.Collections.ObjectModel.Collection1[T].System.Collections.IList.get_Item (System.Int32 index) <0x100bd7c20 + 0x0004b> in <25bf495f7d6b4944aa395b3ab5293479#9a1d60584182f10a46e79ea061bda477>:0 at Xamarin.Forms.Platform.iOS.ObservableItemsSource.ElementAt (System.Int32 index) <0x101c11200 + 0x000b7> in <af9d9248af534e36a80f2d0e9c9d81cf#9a1d60584182f10a46e79ea061bda477>:0 at Xamarin.Forms.Platform.iOS.ObservableItemsSource.get_Item (System.Int32 index) <0x101c0fd80 + 0x0001b> in <af9d9248af534e36a80f2d0e9c9d81cf#9a1d60584182f10a46e79ea061bda477>:0 at Xamarin.Forms.Platform.iOS.ObservableItemsSource.get_Item (Foundation.NSIndexPath indexPath) <0x101c10120 + 0x0004b> in <af9d9248af534e36a80f2d0e9c9d81cf#9a1d60584182f10a46e79ea061bda477>:0 at Xamarin.Forms.Platform.iOS.ItemsViewController1[TItemsView].GetSizeForItem (Foundation.NSIndexPath indexPath) <0x101c04480 + 0x000d7> in <af9d9248af534e36a80f2d0e9c9d81cf#9a1d60584182f10a46e79ea061bda477>:0 at Xamarin.Forms.Platform.iOS.ItemsViewDelegator2[TItemsView,TViewController].GetSizeForItem (UIKit.UICollectionView collectionView, UIKit.UICollectionViewLayout layout, Foundation.NSIndexPath indexPath) <0x101c08ce0 + 0x00037> in <af9d9248af534e36a80f2d0e9c9d81cf#9a1d60584182f10a46e79ea061bda477>:0 at (wrapper managed-to-native) UIKit.UIApplication.UIApplicationMain(int,string[],intptr,intptr) at UIKit.UIApplication.Main (System.String[] args, System.String principalClassName, System.String delegateClassName) <0x1019548e0 + 0x0005f> in <5b08e01cb6df409eb2fea153e6177e5d#9a1d60584182f10a46e79ea061bda477>:0 at WattsHome.iOS.Application.Main (System.String[] args) <0x10097c0b0 + 0x00023> in <77771b61acdd49359e342c9c670ff3ce#9a1d60584182f10a46e79ea061bda477>:0

Pastajello avatar Jan 13 '23 15:01 Pastajello

I found a workaround: we don't use Xamarin anymore.Forms for drawing lists, we have written our own renderers for each lists.

dimonovdd avatar Jan 19 '23 20:01 dimonovdd

I found a workaround: we don't use Xamarin anymore.Forms for drawing lists, we have written our own renderers for each lists.

@dimonovdd By change could you share the renderers?

Jakar510 avatar Oct 05 '23 21:10 Jakar510