Skip to content
This repository was archived by the owner on May 1, 2024. It is now read-only.
This repository was archived by the owner on May 1, 2024. It is now read-only.

[Bug] CarouselView DelegateWeakEventManager.RaiseEvent throws "System.NullReferenceException: Object reference not set to an instance of an object" #2005

@JosephHarvey-Xamarin

Description

@JosephHarvey-Xamarin

Description

Our users are experiencing a regular crash on both our Android and iOS deployment. From the log I can gather that they are navigating in and out of a page that has a CarouselView and after multiple navigations the app will eventually crash. I have suspicions on what could be causing this, perhaps the Carousel is lingering around too long, or taking too long to initialize.

Overall the Carousel is buggy, but i've managed to work around the other issues I've been having. Does anyone know what might be happening here and have some workaround that I can implement?  
``

Stack Trace

2024-03-05 00:40:04.47 - [ERROR] [UnhandledException] System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.NullReferenceException: Object reference not set to an instance of an object
at Xamarin.CommunityToolkit.Helpers.EventManagerService.HandleEvent (System.String& eventName, System.Object& sender, System.Object& eventArgs, System.Collections.Generic.Dictionary2[System.String,System.Collections.Generic.List1[Xamarin.CommunityToolkit.Helpers.Subscription]]& eventHandlers) <0x1029479b0 + 0x001a4> in <e29db44a5724499bb6d2544e250eefd7#fc71cca2391f6105c935773f46b91ae1>:0
at Xamarin.CommunityToolkit.Helpers.DelegateWeakEventManager.RaiseEvent (System.Object sender, System.Object eventArgs, System.String eventName) <0x102946620 + 0x0003b> in <e29db44a5724499bb6d2544e250eefd7#fc71cca2391f6105c935773f46b91ae1>:0
at Xamarin.CommunityToolkit.ObjectModel.ObservableObject.OnPropertyChanged (System.String propertyName) <0x1029462d0 + 0x0008b> in <e29db44a5724499bb6d2544e250eefd7#fc71cca2391f6105c935773f46b91ae1>:0
at Xamarin.CommunityToolkit.ObjectModel.ObservableObject.SetProperty[T] (T& backingStore, T value, System.String propertyName, System.Action onChanging, System.Action onChanged, System.F3[T1,T2,TResult] validateValue) <0x101b91080 + 0x000e7> in <e29db44a5724499bb6d2544e250eefd7#fc71cca2391f6105c935773f46b91ae1>:0 at OURAPP.ViewModels.PhotoDetailsViewModel.set_SelectedPosition (System.Int32 value) <0x1019fddd0 + 0x00057> in <a00928f8809641878d9b8b1ce36ed7f8#fc71cca2391f6105c935773f46b91ae1>:0 at (wrapper managed-to-native) System.Reflection.RuntimeMethodInfo.InternalInvoke(System.Reflection.RuntimeMethodInfo,object,object[],System.Exception&) at System.Reflection.RuntimeMethodInfo.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) <0x1006527d0 + 0x000ef> in <aae03b95719e488f8a163bae4d2b5dcb#fc71cca2391f6105c935773f46b91ae1>:0 --- End of inner exception stack trace --- at System.Reflection.RuntimeMethodInfo.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) <0x1006527d0 + 0x00144> in <aae03b95719e488f8a163bae4d2b5dcb#fc71cca2391f6105c935773f46b91ae1>:0 at System.Reflection.MethodBase.Invoke (System.Object obj, System.Object[] parameters) <0x100640630 + 0x0003b> in <aae03b95719e488f8a163bae4d2b5dcb#fc71cca2391f6105c935773f46b91ae1>:0 at Xamarin.Forms.BindingExpression.ApplyCore (System.Object sourceObject, Xamarin.Forms.BindableObject target, Xamarin.Forms.BindableProperty property, System.Boolean fromTarget) <0x10094e820 + 0x008f3> in <fdb98549974543d69e8151b63f809e44#fc71cca2391f6105c935773f46b91ae1>:0 at Xamarin.Forms.BindingExpression.Apply (System.Boolean fromTarget) <0x10094e4b0 + 0x0008f> in <fdb98549974543d69e8151b63f809e44#fc71cca2391f6105c935773f46b91ae1>:0 at Xamarin.Forms.Binding.Apply (System.Boolean fromTarget) <0x10094b3f0 + 0x000a3> in <fdb98549974543d69e8151b63f809e44#fc71cca2391f6105c935773f46b91ae1>:0 at Xamarin.Forms.BindableObject.SetValueActual (Xamarin.Forms.BindableProperty property, Xamarin.Forms.BindableObject+BindablePropertyContext context, System.Object value, System.Boolean currentlyApplying, Xamarin.Forms.Internals.SetValueFlags attributes, System.Boolean silent) <0x1009442d0 + 0x002c3> in <fdb98549974543d69e8151b63f809e44#fc71cca2391f6105c935773f46b91ae1>:0 at Xamarin.Forms.BindableObject.SetValueCore (Xamarin.Forms.BindableProperty property, System.Object value, Xamarin.Forms.Internals.SetValueFlags attributes, Xamarin.Forms.BindableObject+SetValuePrivateFlags privateAttributes) <0x100943ce0 + 0x004ef> in <fdb98549974543d69e8151b63f809e44#fc71cca2391f6105c935773f46b91ae1>:0 at Xamarin.Forms.BindableObject.SetValueCore (Xamarin.Forms.BindableProperty property, System.Object value, Xamarin.Forms.Internals.SetValueFlags attributes) <0x100943ad0 + 0x0002f> in <fdb98549974543d69e8151b63f809e44#fc71cca2391f6105c935773f46b91ae1>:0 at Xamarin.Forms.Element.SetValueFromRenderer (Xamarin.Forms.BindableProperty property, System.Object value) <0x1009970d0 + 0x00027> in <fdb98549974543d69e8151b63f809e44#fc71cca2391f6105c935773f46b91ae1>:0 at Xamarin.Forms.Platform.iOS.CarouselViewController.SetPosition (System.Int32 position) <0x1017d4500 + 0x000b7> in <03af6754ca4e406c857676d299e3ed7d#fc71cca2391f6105c935773f46b91ae1>:0 at Xamarin.Forms.Platform.iOS.CarouselViewController.CarouselViewScrolled (System.Object sender, Xamarin.Forms.ItemsViewScrolledEventArgs e) <0x1017d3a30 + 0x00037> in <03af6754ca4e406c857676d299e3ed7d#fc71cca2391f6105c935773f46b91ae1>:0 at Xamarin.Forms.ItemsView.SendScrolled (Xamarin.Forms.ItemsViewScrolledEventArgs e) <0x1009d0870 + 0x00037> in <fdb98549974543d69e8151b63f809e44#fc71cca2391f6105c935773f46b91ae1>:0 at Xamarin.Forms.Platform.iOS.ItemsViewDelegator2[TItemsView,TViewController].Scrolled (UIKit.UIScrollView scrollView) <0x101772060 + 0x00257> in <03af6754ca4e406c857676d299e3ed7d#fc71cca2391f6105c935773f46b91ae1>:0
at Xamarin.Forms.Platform.iOS.CarouselViewDelegator.Scrolled (UIKit.UIScrollView scrollView) <0x101766730 + 0x0001f> in <03af6754ca4e406c857676d299e3ed7d#fc71cca2391f6105c935773f46b91ae1>:0
at (wrapper managed-to-native) UIKit.UIApplication.xamarin_UIApplicationMain(int,intptr,intptr,intptr,intptr&)
at UIKit.UIApplication.UIApplicationMain (System.Int32 argc, System.String[] argv, System.IntPtr principalClassName, System.IntPtr delegateClassName) <0x1014f37f0 + 0x0004b> in <eb9faeca3234460baffcdf962a8d9526#fc71cca2391f6105c935773f46b91ae1>:0
at UIKit.UIApplication.Main (System.String[] args, System.Type principalClass, System.Type delegateClass) <0x1014f3900 + 0x000df> in <eb9faeca3234460baffcdf962a8d9526#fc71cca2391f6105c935773f46b91ae1>:0
at OURAPP.iOS.ApplicationMain.Main (System.String[] args) <0x10047c4f0 + 0x00023> in <11246e4e4cb74987bf811ef50442a205#fc71cca2391f6105c935773f46b91ae1>:0

Link to Reproduction Sample

Private Code, cant provide that here.

Steps to Reproduce

N/A

Expected Behavior

Actual Behavior

Basic Information

  • Version with issue:

  • Last known good version:

  • IDE: VS 17.8.6

  • Platform Target Frameworks:

    • iOS: 16.4.0.23
    • Android: 13.2.2.0
  • Android Support Library Version:

  • Nuget Packages: Xam Forms 5.0.0.2622

  • Affected Devices: Many

Workaround

I wish

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working. Breaky break.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions