Skip to content

[iOS/MacCatalyst] Setting SelectedItem Programmatically and Then Immediately Setting ItemsSource to Null Causes a Crash #29937

@bhavanesh2001

Description

@bhavanesh2001

Description

In an iOS and MacCatalyst, programmatically setting the SelectedItem property of a CollectionView to a valid item and then immediately setting theItemsSource property to null results in a crash (ObjCRuntime.ObjCException)

Steps to Reproduce

  1. Create a CollectionView in an iOS or MacCatalyst app with a valid ItemsSource.
  2. Programmatically set the SelectedItem to an item from the ItemsSource.
  3. Immediately set the ItemsSource to null.
  4. Observe the application crash.

Link to public reproduction project repository

https://github.com/bhavanesh2001/maui-bugs/tree/collectionview_crash_2

Version with bug

9.0.70 SR7

Is this a regression from previous behavior?

Not sure, did not test other versions

Last version that worked well

Unknown/Other

Affected platforms

iOS, macOS

Affected platform versions

No response

Did you find any workaround?

No response

Relevant log output

An unhandled exception of type 'ObjCRuntime.ObjCException' occurred in Microsoft.MacCatalyst.dll
   at ObjCRuntime.Messaging.void_objc_msgSendSuper_NativeHandle_bool_UIntPtr(IntPtr receiver, IntPtr selector, NativeHandle arg1, Byte arg2, UIntPtr arg3)
   at UIKit.UICollectionView.SelectItem(NSIndexPath indexPath, Boolean animated, UICollectionViewScrollPosition scrollPosition)
   at Microsoft.Maui.Controls.Handlers.Items.SelectableItemsViewController`1.<>c__DisplayClass4_0.<SelectItem>b__0(Boolean _) in

Metadata

Metadata

Assignees

Labels

area-controls-collectionviewCollectionView, CarouselView, IndicatorViewplatform/iosplatform/macosmacOS / Mac Catalysts/triagedIssue has been revieweds/verifiedVerified / Reproducible Issue ready for Engineering Triaget/bugSomething isn't working

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions