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

[iOS] CarouselView with CarouselViewHandler2 make app crash when Loop="False" and user scroll to the last position #26863

Open
vitalbit opened this issue Dec 30, 2024 · 1 comment · May be fixed by #26868
Labels
collectionview-cv2 platform/iOS 🍎 s/verified Verified / Reproducible Issue ready for Engineering Triage t/bug Something isn't working

Comments

@vitalbit
Copy link

Description

CarouselView with Loop="False" attribute and configuring new CarouselViewHandler2 makes application crash, when reaching last item position.

Steps to Reproduce

  1. Configure CarouselViewHandler2 in MauiProgram.cs for CarouselView
  2. Use CarouselView with Loop="False" attribute and ItemsSource with 2-3 objects.
  3. Scroll carousel view to the last position.

Actual result: application is crashed during navigation to the last item.
Expected result: we should be able to see last item.

Please see reproduction project repository with CarouselView on MainPage.xaml sample.

Link to public reproduction project repository

https://github.com/vitalbit/CarouselViewHandler2_LastIndex

Version with bug

9.0.21 SR2.1

Is this a regression from previous behavior?

No, this is something new

Last version that worked well

Unknown/Other

Affected platforms

iOS

Affected platform versions

No response

Did you find any workaround?

For now only Loop="True" can help to avoid this issue.

Relevant log output

Index was out of range. Must be non-negative and less than the size of the collection. (Parameter 'index')
    at at System.Collections.Generic.List`1[[System.String, System.Private.CoreLib, Version=9.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].get_Item(Int32 index)
    at at System.Collections.ObjectModel.Collection`1[[System.String, System.Private.CoreLib, Version=9.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].System.Collections.IList.get_Item(Int32 index)
    at at Microsoft.Maui.Controls.Handlers.Items.ObservableItemsSource.ElementAt(Int32 index)
    at at Microsoft.Maui.Controls.Handlers.Items.ObservableItemsSource.get_Item(Int32 index)
    at at Microsoft.Maui.Controls.Handlers.Items.ObservableItemsSource.get_Item(NSIndexPath indexPath)
    at at Microsoft.Maui.Controls.Handlers.Items2.ItemsViewController2`1[[Microsoft.Maui.Controls.CarouselView, Microsoft.Maui.Controls, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].DetermineCellReuseId(NSIndexPath indexPath)
    at at Microsoft.Maui.Controls.Handlers.Items2.CarouselViewController2.DetermineCellReuseId(NSIndexPath indexPath)
    at at Microsoft.Maui.Controls.Handlers.Items2.ItemsViewController2`1[[Microsoft.Maui.Controls.CarouselView, Microsoft.Maui.Controls, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].GetCell(UICollectionView collectionView, NSIndexPath indexPath)
    at at Microsoft.Maui.Controls.Handlers.Items2.CarouselViewController2.GetCell(UICollectionView collectionView, NSIndexPath indexPath)
    at UIKit.UIApplication.UIApplicationMain(Int32 argc, String[] argv, IntPtr principalClassName, IntPtr delegateClassName) in /Users/builder/azdo/_work/9/s/xamarin-macios/src/UIKit/UIApplication.cs:61
    at UIKit.UIApplication.Main(String[] args, Type principalClass, Type delegateClass) in /Users/builder/azdo/_work/9/s/xamarin-macios/src/UIKit/UIApplication.cs:96
    at CarouselViewHandler2_LastIndex_Sample.Program.Main(String[] args) in /Users/vitalipantsialei/VSProjects/CarouselViewHandler2_LastIndex_Sample/CarouselViewHandler2_LastIndex_Sample/Platforms/iOS/Program.cs:13
@vitalbit vitalbit added the t/bug Something isn't working label Dec 30, 2024
@kubaflo kubaflo added the s/verified Verified / Reproducible Issue ready for Engineering Triage label Dec 30, 2024
@kubaflo
Copy link
Contributor

kubaflo commented Dec 30, 2024

I can replicate it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
collectionview-cv2 platform/iOS 🍎 s/verified Verified / Reproducible Issue ready for Engineering Triage t/bug Something isn't working
Projects
None yet
2 participants