Unplanned
Last Updated: 11 Jun 2025 10:46 by ADMIN
Nico
Created on: 04 Jun 2025 15:07
Category: CollectionView
Type: Bug Report
0
CollectionView: [iOS] [MacCatalyst] NullReferenceException in a custom scenario

I see iOS crashes in Sentry, seems like caused by clearing the RadCollectionView bound DataSource ObservableCollection, when an item was previously selected

Maui 9.0.70
Telerik 11.0

System.NullReferenceException: Arg_NullReferenceException
  ?, in void RadCollectionViewItemView.OnIsSelectedChanged()
  ?, in static RadCollectionViewItemView()+(BindableObject b, object o, object n) => { }
  ?, in void BindableObject.OnBindablePropertySet(BindableProperty property, object original, object value, bool didChange, bool willFirePropertyChanged)
  ?, in void Element.OnBindablePropertySet(BindableProperty property, object original, object value, bool changed, bool willFirePropertyChanged)
  ?, in void BindableObject.SetValueActual(BindableProperty property, BindablePropertyContext context, object value, bool currentlyApplying, SetValueFlags attributes, SetterSpecificity specificity, bool silent)
  ?, in void BindableObject.SetValueCore(BindableProperty property, object value, SetValueFlags attributes, SetValuePrivateFlags privateAttributes, SetterSpecificity specificity)
  ?, in void BindableObject.SetValue(BindableProperty property, object value)
  ?, in void RadCollectionViewItemView.set_IsSelected(bool value)
  ?, in void RadCollectionView.SelectContainers(IEnumerable items, bool select)
  ?, in void RadCollectionView.SelectionHelperSelectionChanged(object sender, RadSelectionChangedEventArgs e)
  ?, in void <>c__DisplayClass36_0.<SelectionChangerSelectionChanged>b__0(?)+() => { }
  ?, in void ActiveSelectionScope.Dispose()
  ?, in void SelectionHelper.ClearSelection()
  ?, in void RadCollectionView.Telerik.Maui.Controls.ICollectionView.ItemsChanged(NotifyCollectionChangedEventArgs e)
  ?, in void CollectionViewModel.OnDataProviderViewChanged(object sender, ViewChangedEventArgs e)
  ?, in void DataProviderBase.RaiseViewChanged(object sender, List<AddRemoveResult> changes, NotifyCollectionChangedEventArgs args, CollectionChange action, bool affectsAggregates)
  ?, in void LocalDataSourceProvider.ProcessCollectionChanged(NotifyCollectionChangedEventArgs e)
  ?, in void LocalDataSourceProvider.DataView_CollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
  ?, in void EnumerableDataSourceView.RaiseCollectionChanged(object sender, NotifyCollectionChangedEventArgs args)
  ?, in void EnumerableDataSourceView.ProcessCollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
  ?, in void EnumerableDataSourceView.ProcessCollectionChangedOverride(object sender, NotifyCollectionChangedEventArgs args)
  ?, in void EnumerableDataSourceView.ProcessPendingCollectionChange()
  ?, in void DataProviderBase.RaiseViewChanging(object sender, IList changedItems, CollectionChange action)
  ?, in void LocalDataSourceProvider.DataView_CollectionChanging(object sender, NotifyCollectionChangedEventArgs e)
  ?, in void EnumerableDataSourceView.HandleCollectionChangedOverride(object sender, NotifyCollectionChangedEventArgs e)
  ?, in void EnumerableDataSourceView.Telerik.Maui.IWeakEventListener.ReceiveEvent(object sender, object args)
  ?, in void WeakEventHandlerList<NotifyCollectionChangedEventArgs>.ProcessEvent(object sender, object args)
  ?, in void WeakEventHandlerList<NotifyCollectionChangedEventArgs>.OnCollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
  ?, in void ObservableCollection<ViewBundle>.OnCollectionChanged(NotifyCollectionChangedEventArgs)
  ?, in void ExtObservableCollection<ViewBundle>.OnCollectionChanged(NotifyCollectionChangedEventArgs e)
  ?, in void ObservableCollection<ViewBundle>.OnCollectionReset()
  ?, in void ObservableCollection<ViewBundle>.ClearItems()
  ?, in void ExtObservableCollection<ViewBundle>.ClearItems()
  ?, in void Collection<ViewBundle>.Clear()
  ?, in void SearchViewViewModel.Dispose(bool disposing)
  ?, in void PropertyChangedNotifyingBase.Dispose()
  ?, in async void ViewBundle.Dispose(bool disposing)
  ?, in void <>c.<ThrowAsync>b__128_0(?)+(object state) => { }
  ?, in void NSAsyncSynchronizationContextDispatcher.Apply()
  ?, in void __Registrar_Callbacks__.callback_3311_Foundation_NSAsyncSynchronizationContextDispatcher_Apply(IntPtr pobj, IntPtr sel, IntPtr* exception_gchandle)

6 comments
ADMIN
Didi
Posted on: 11 Jun 2025 10:46

Hello Nico,

I confirm this is an issue on iOS and MacCatalyst when using 11.0.0 Telerik Maui version. On Android and WinUI no issues. The behavior seems provoked from the accessibility feature we introduced with 11.0.0 version.

I have changed the status to Unplanned and raised the priority of this issue.

Thank you for your time and great explanation on the case.

Case tested in which the exception happens:

 NullReferenceException occurs when the following steps are done 
1. The CollectionView is added inside ContentView and the visibility of this view is set to false 
2. The view (ContentView in the example) handlers are disconnected 
3. And the collection bound to the CollectionView ItemsSource is cleared using the Clear() method.

Regards,
Didi
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

Nico
Posted on: 10 Jun 2025 10:23

CollectionViewItemViewBorder collectionViewItemViewBorder = (CollectionViewItemViewBorder)((handler != null) ? ((IElementHandler)handler).PlatformView : null);
if (((UIView)collectionViewItemViewBorder).Subviews != null && ((UIView)collectionViewItemViewBorder).Subviews.Length != 0)

 

collectionViewItemViewBorder is missing a null check

            
Nico
Posted on: 10 Jun 2025 10:20

Hi Didi,

- it works with 10.1.0
- SelectedItem and ItemsSource are both bound to the ViewModel

ItemsSource="{Binding ListItems, Mode=OneWay}"
SelectedItem="{Binding SelectedListItem, Mode=TwoWay}"

In the crash case the
- Page is currently not visible
- The page containing the collectionview cleared with view.DisconnectHandlers() (maui/src/Core/src/ViewExtensions.cs at main · dotnet/maui) (
- After that the associated ViewModel is disposed, where the ListItems are cleared (ListItems.Clear();)

Meanwhile I found out that if view.DisconnectHandlers is commented out, the app does not crash

ADMIN
Didi
Posted on: 06 Jun 2025 16:24

Hi Nico,

Thank you for all details shared.

With Telerik MAUI 11.0.0 version, we have introduced the screen reader support on iOS and Android for CollectionView. Could you please share whether you have the selecteditem(s) properties set? Also how yo clear the items, setting a new collection or just call Clear method? Share more details on this. 

Could you please downgrade to Telerik MAUI 10.1.0 and test on your side whether the crash will occur.

Looking forward to your reply.

Regards,
Didi
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

Nico
Posted on: 06 Jun 2025 09:01
I can reproduce this in my production app. If there's a test build/build with logging, I'd be happy to test it.
Nico
Posted on: 05 Jun 2025 13:23

Revert "Add Accessibility Selected for iOS CollectionView (#29014)" by PureWeen · Pull Request #29827 · dotnet/maui

In MAUI there is code going to be reverted
I see you added similar code in OnIsSelectedChanged in 11.0