Skip to content

CollectionView with ObservableCollection ItemsSource, sporadic exception causing crash on iOS #34261

@jschneiderCDS

Description

@jschneiderCDS

Description

I've not experienced this during my testing on my iOS devices but I can see it occurring on iOS devices sporadically in Sentry.io (4 times over the last 6 days) but the sample size is low, about 15 active test users, though they are using the application heavily each day. All instances were on iOS 26.2.1.

The application has multiple pages with CollectionViews that have ObservableCollections as item sources. The most typical situation is users scanning barcodes for items they are delivering, and if the barcode matches an item or items, it adds a model per item to the ItemsSource. They are doing this hundreds and thousands of times a day without issue but 4 separate times over 6 days, this exception has occurred and I'm stumped at how to address it and am finding it impossible to replicate.

This must be occurring when the ObservableCollection is either having an item or items added or when the list is cleared simply based on the stack trace. I have verified there is no instance where a null item would be added to these ObservableCollections.

This is a .net 9 Maui app.

Here is the relevant stack trace:

System.ArgumentNullException: Value cannot be null. (Parameter 'key')
  at ref TemplatedCell Dictionary<object, TemplatedCell>.FindValue(object)()
  at bool Dictionary<object, TemplatedCell>.TryGetValue(object key, out TemplatedCell value)()
  at void ItemsViewController<ReorderableItemsView>.UpdateTemplatedCell(TemplatedCell cell, NSIndexPath indexPath)()
  at UICollectionViewCell ItemsViewController<ReorderableItemsView>.GetCell(UICollectionView collectionView, NSIndexPath indexPath)()
  at NativeHandle ItemsViewController<ReorderableItemsView>.__IRegistrarGenericTypeProxy__Microsoft_Maui_Controls_Handlers_Items_ItemsViewController_1___GetCell(IntPtr sel, IntPtr p0, IntPtr p1, IntPtr* exception_gchandle)()

Steps to Reproduce

Unfortunately, I have failed to replicate the issue, as it's incredibly sporadic but happening enough to be a concern as we have not done a full rollout of the app to all our users, yet.

Link to public reproduction project repository

No response

Version with bug

10.0.10

Is this a regression from previous behavior?

Not sure, did not test other versions

Last version that worked well

Unknown/Other

Affected platforms

iOS

Affected platform versions

so far I have only seen 4 instances all on iOS 26.2.1

Did you find any workaround?

No response

Relevant log output

Metadata

Metadata

Assignees

No one assigned

    Labels

    t/bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions