Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[MAUI]I9_Scrolling_Scroll mode when adding items page throws' Java.Lang.IllegalArgumentException Message=Invalid target position' after setting UpdatingScrollMode #24272

Closed
ninachen03 opened this issue Aug 16, 2024 · 1 comment · Fixed by #24288
Assignees
Labels
csi-new fixed-in-8.0.90 fixed-in-9.0.0-rc.1.24453.9 i/regression This issue described a confirmed regression on a currently supported version p/0 Work that we can't release without platform/android 🤖 s/triaged Issue has been reviewed t/bug Something isn't working
Milestone

Comments

@ninachen03
Copy link

ninachen03 commented Aug 16, 2024

Description

I9_Scrolling
Affected case:
I9_Scrolling_Scroll mode when adding items for Items UpdatingScrollMode.

Steps to Reproduce

  1. Deploy https://devdiv.visualstudio.com/Pkgs/_git/VS.TestAssets.Xaml?path=/Assets/Projects/ManualMauiTests to Android.
  2. Navigate to 'I CollectionView' ->'I9_Scrolling ->I9_Scrolling_Scroll mode when adding items for Items UpdatingScrollMode
  3. Set UpdatingMode from KeepItemsinView to KeepLastItemView.
    Actual Behavior:
    image
    Detail:
    ◢ | $exception | {Java.Lang.IllegalArgumentException: Invalid target position at Java.Interop.JniEnvironment.InstanceMethods.CallNonvirtualVoidMethod(JniObjectReference instance, JniObjectReference type, JniMethodInfo method, JniArgumentValue* args) in /Users/runner/work/1/s/xamarin-android/external/Java.Interop/src/Java.Interop/obj/Release/net7.0/JniEnvironment.g.cs:line 20830 at Java.Interop.JniPeerMembers.JniInstanceMethods.InvokeVirtualVoidMethod(String encodedMember, IJavaPeerable self, JniArgumentValue* parameters) in /Users/runner/work/1/s/xamarin-android/external/Java.Interop/src/Java.Interop/Java.Interop/JniPeerMembers.JniInstanceMethods_Invoke.cs:line 75 at AndroidX.RecyclerView.Widget.RecyclerView.SmoothScrollToPosition(Int32 position) in C:\a_work\1\s\generated\androidx.recyclerview.recyclerview\obj\Release\net6.0-android\generated\src\AndroidX.RecyclerView.Widget.RecyclerView.cs:line 14818 at Microsoft.Maui.Controls.Handlers.Items.ScrollHelper.AnimateScrollToPosition(Int32 index, ScrollToPosition scrollToPosition) in //src/Controls/src/Core/Handlers/Items/Android/ScrollHelper.cs:line 52 at Microsoft.Maui.Controls.Handlers.Items.MauiRecyclerView3[[Microsoft.Maui.Controls.ReorderableItemsView, Microsoft.Maui.Controls, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null],[Microsoft.Maui.Controls.Handlers.Items.GroupableItemsViewAdapter2[[Microsoft.Maui.Controls.ReorderableItemsView, Microsoft.Maui.Controls, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null],[Microsoft.Maui.Controls.Handlers.Items.IGroupableItemsViewSource, Microsoft.Maui.Controls, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]], Microsoft.Maui.Controls, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null],[Microsoft.Maui.Controls.Handlers.Items.IGroupableItemsViewSource, Microsoft.Maui.Controls, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].ScrollTo(ScrollToRequestEventArgs args) in //src/Controls/src/Core/Handlers/Items/Android/MauiRecyclerView.cs:line 399 at Microsoft.Maui.Controls.Handlers.Items.MauiRecyclerView3[[Microsoft.Maui.Controls.ReorderableItemsView, Microsoft.Maui.Controls, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null],[Microsoft.Maui.Controls.Handlers.Items.GroupableItemsViewAdapter2[[Microsoft.Maui.Controls.ReorderableItemsView, Microsoft.Maui.Controls, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null],[Microsoft.Maui.Controls.Handlers.Items.IGroupableItemsViewSource, Microsoft.Maui.Controls, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]], Microsoft.Maui.Controls, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null],[Microsoft.Maui.Controls.Handlers.Items.IGroupableItemsViewSource, Microsoft.Maui.Controls, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].AdjustScrollForItemUpdate() in //src/Controls/src/Core/Handlers/Items/Android/MauiRecyclerView.cs:line 587 at Microsoft.Maui.Controls.Handlers.Items.DataChangeObserver.OnItemRangeInserted(Int32 positionStart, Int32 itemCount) in //src/Controls/src/Core/Handlers/Items/Android/DataChangeObserver.cs:line 54 at AndroidX.RecyclerView.Widget.RecyclerView.AdapterDataObserver.n_OnItemRangeInserted_II(IntPtr jnienv, IntPtr native__this, Int32 positionStart, Int32 itemCount) in C:\a_work\1\s\generated\androidx.recyclerview.recyclerview\obj\Release\net6.0-android\generated\src\AndroidX.RecyclerView.Widget.RecyclerView.cs:line 1124 at Android.Runtime.JNINativeWrapper.Wrap_JniMarshal_PPII_V(_JniMarshal_PPII_V callback, IntPtr jnienv, IntPtr klazz, Int32 p0, Int32 p1) in /Users/runner/work/1/s/xamarin-android/src/Mono.Android/Android.Runtime/JNINativeWrapper.g.cs:line 154 --- End of managed Java.Lang.IllegalArgumentException stack trace --- java.lang.IllegalArgumentException: Invalid target position at androidx.recyclerview.widget.RecyclerView$SmoothScroller.start(RecyclerView.java:12658) at androidx.recyclerview.widget.RecyclerView$LayoutManager.startSmoothScroll(RecyclerView.java:9208) at androidx.recyclerview.widget.LinearLayoutManager.smoothScrollToPosition(LinearLayoutManager.java:525) at androidx.recyclerview.widget.RecyclerView.smoothScrollToPosition(RecyclerView.java:1889) at crc645d80431ce5f73f11.DataChangeObserver.n_onItemRangeInserted(Native Method) at crc645d80431ce5f73f11.DataChangeObserver.onItemRangeInserted(DataChangeObserver.java:43) at androidx.recyclerview.widget.RecyclerView$AdapterDataObservable.notifyItemRangeInserted(RecyclerView.java:13138) at androidx.recyclerview.widget.RecyclerView$Adapter.notifyItemInserted(RecyclerView.java:8113) at mono.java.lang.RunnableImplementor.n_run(Native Method) at mono.java.lang.RunnableImplementor.run(RunnableImplementor.java:31) at android.os.Handler.handleCallback(Handler.java:958) at android.os.Handler.dispatchMessage(Handler.java:99) at android.os.Looper.loopOnce(Looper.java:205) at android.os.Looper.loop(Looper.java:294) at android.app.ActivityThread.main(ActivityThread.java:8177) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:552) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:971) --- End of managed Java.Lang.IllegalArgumentException stack trace --- java.lang.IllegalArgumentException: Invalid target position at androidx.recyclerview.widget.RecyclerView$SmoothScroller.start(RecyclerView.java:12658) at androidx.recyclerview.widget.RecyclerView$LayoutManager.startSmoothScroll(RecyclerView.java:9208) at androidx.recyclerview.widget.LinearLayoutManager.smoothScrollToPosition(LinearLayoutManager.java:525) at androidx.recyclerview.widget.RecyclerView.smoothScrollToPosition(RecyclerView.java:1889) at crc645d80431ce5f73f11.DataChangeObserver.n_onItemRangeInserted(Native Method) at crc645d80431ce5f73f11.DataChangeObserver.onItemRangeInserted(DataChangeObserver.java:43) at androidx.recyclerview.widget.RecyclerView$AdapterDataObservable.notifyItemRangeInserted(RecyclerView.java:13138) at androidx.recyclerview.widget.RecyclerView$Adapter.notifyItemInserted(RecyclerView.java:8113) at mono.java.lang.RunnableImplementor.n_run(Native Method) at mono.java.lang.RunnableImplementor.run(RunnableImplementor.java:31) at android.os.Handler.handleCallback(Handler.java:958) at android.os.Handler.dispatchMessage(Handler.java:99) at android.os.Looper.loopOnce(Looper.java:205) at android.os.Looper.loop(Looper.java:294) at android.app.ActivityThread.main(ActivityThread.java:8177) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:552) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:971) } | Java.Lang.IllegalArgumentException

Link to public reproduction project repository

https://devdiv.visualstudio.com/Pkgs/_git/VS.TestAssets.Xaml?path=/Assets/Projects/ManualMauiTests

Version with bug

8.0.90-ci.net8.24414.1

Is this a regression from previous behavior?

Yes, this used to work in .NET MAUI

Last version that worked well

8.0.90-ci.net8.24413.1 & 8.0.80 & 8.0.3

Affected platforms

Android

@ninachen03 ninachen03 added t/bug Something isn't working platform/android 🤖 s/triaged Issue has been reviewed csi-new labels Aug 16, 2024
Copy link
Contributor

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.

@ninachen03 ninachen03 added the i/regression This issue described a confirmed regression on a currently supported version label Aug 16, 2024
@PureWeen PureWeen added this to the .NET 8 SR9 milestone Aug 16, 2024
@PureWeen PureWeen added the p/0 Work that we can't release without label Aug 16, 2024
@github-project-automation github-project-automation bot moved this from Todo to Done in MAUI SDK Ongoing Aug 20, 2024
@github-actions github-actions bot locked and limited conversation to collaborators Sep 20, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
csi-new fixed-in-8.0.90 fixed-in-9.0.0-rc.1.24453.9 i/regression This issue described a confirmed regression on a currently supported version p/0 Work that we can't release without platform/android 🤖 s/triaged Issue has been reviewed t/bug Something isn't working
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

4 participants