dotnet / maui

.NET MAUI is the .NET Multi-platform App UI, a framework for building native device applications spanning mobile, tablet, and desktop.
https://dot.net/maui
MIT License
21.83k stars 1.67k forks source link

[Android][CollectionView]Crash when quickly clicking to delete item #22674

Open BaY1251 opened 1 month ago

BaY1251 commented 1 month ago

Description

I test with the latest nightly build,still has this issue. This seems to be an exception caused by a BindingAdapterPosition of -1.

Steps to Reproduce

Download https://github.com/BaY1251/MauiDebug.git

  1. Open /BindingAdapterPositionException/BindingAdapterPositionException.sln
  2. deployment the project
  3. Quick click on CollectionView items
  4. Crash

Link to public reproduction project repository

https://github.com/BaY1251/MauiDebug.git

Version with bug

8.0.40 SR5

Is this a regression from previous behavior?

No, this is something new

Last version that worked well

Unknown/Other

Affected platforms

Android

Affected platform versions

Android7.1

Did you find any workaround?

No response

Relevant log output

System.ArgumentOutOfRangeException: 'Index was out of range. Must be non-negative and less than the size of the collection. (Parameter 'index')'

    0xFFFFFFFFFFFFFFFF in Android.Runtime.RuntimeNativeMethods.monodroid_debugger_unhandled_exception   C#
    0x1A in Android.Runtime.JNINativeWrapper._unhandled_exception at /Users/runner/work/1/s/xamarin-android/src/Mono.Android/Android.Runtime/JNINativeWrapper.g.cs:12,5 C#
    0x1E in Android.Runtime.JNINativeWrapper.Wrap_JniMarshal_PPL_V at /Users/runner/work/1/s/xamarin-android/src/Mono.Android/Android.Runtime/JNINativeWrapper.g.cs:122,26  C#
    0x8 in System.ThrowHelper.ThrowArgumentOutOfRange_IndexMustBeLessException  C#
    0x9 in System.Collections.Generic.List<object>.get_Item C#
    0x2 in System.Collections.Generic.List<object>.System.Collections.IList.get_Item    C#
    0x11 in Microsoft.Maui.Controls.Handlers.Items.ObservableItemsSource.ElementAt at /_/src/Controls/src/Core/Handlers/Items/Android/ItemsSources/ObservableItemsSource.cs:232,5   C#
    0x8 in Microsoft.Maui.Controls.Handlers.Items.ObservableItemsSource.GetItem at /_/src/Controls/src/Core/Handlers/Items/Android/ItemsSources/ObservableItemsSource.cs:71,4   C#
    0x7 in Microsoft.Maui.Controls.Handlers.Items.UngroupedItemsSource.GetItem at /_/src/Controls/src/Core/Handlers/Items/Android/ItemsSources/UngroupedItemsSource.cs:54,4 C#
    0x3D in Microsoft.Maui.Controls.Handlers.Items.SelectableItemsViewAdapter<Microsoft.Maui.Controls.ReorderableItemsView,Microsoft.Maui.Controls.Handlers.Items.IGroupableItemsViewSource>.UpdateMauiSelection at /_/src/Controls/src/Core/Handlers/Items/Android/Adapters/SelectableItemsViewAdapter.cs:139,6    C#
    0x2 in Microsoft.Maui.Controls.Handlers.Items.SelectableItemsViewAdapter<Microsoft.Maui.Controls.ReorderableItemsView,Microsoft.Maui.Controls.Handlers.Items.IGroupableItemsViewSource>.SelectableClicked at /_/src/Controls/src/Core/Handlers/Items/Android/Adapters/SelectableItemsViewAdapter.cs:126,4   C#
    0xD in Microsoft.Maui.Controls.Handlers.Items.SelectableViewHolder.OnViewHolderClicked at /_/src/Controls/src/Core/Handlers/Items/Android/SelectableViewHolder.cs:59,4  C#
    0xF in Microsoft.Maui.Controls.Handlers.Items.SelectableViewHolder.OnClick at /_/src/Controls/src/Core/Handlers/Items/Android/SelectableViewHolder.cs:47,5  C#
    0x11 in Android.Views.View.IOnClickListenerInvoker.n_OnClick_Landroid_view_View_ at /Users/runner/work/1/s/xamarin-android/src/Mono.Android/obj/Release/net8.0/android-34/mcw/Android.Views.View.cs:2374,5  C#
    0x9 in Android.Runtime.JNINativeWrapper.Wrap_JniMarshal_PPL_V at /Users/runner/work/1/s/xamarin-android/src/Mono.Android/Android.Runtime/JNINativeWrapper.g.cs:121,5    C#
github-actions[bot] commented 1 month ago

Hi I'm an AI powered bot that finds similar issues based off the issue title.

Please view the issues below to see if they solve your problem, and if the issue describes your problem please consider closing this one and thumbs upping the other issue to help us prioritize it. Thank you!

Open similar issues:

Closed similar issues:

Note: You can give me feedback by thumbs upping or thumbs downing this comment.

RoiChen001 commented 1 month ago

Can repro this issue at Android platform on the latest 17.11.0 Preview 1.0(8.0.21/8.0.40)