[Xamarin.Forms Android] SfPicker internal code causing Android app crash

I recently added a new page with basic SfPicker functionality: a VM data-bound ItemsSource and VM data-bound SelectedIndex, both using the default binding modes. After setting the page BindingContext to the VM and calling InitializeComponent(), the app crashes with the following stack trace:


SelectionController.AssignSelectedItemFromSelectedIndex () SfPicker.set_SelectedIndex (System.Object value) SfPickerMapping.OnPickerPropertiesChanged (System.String propertyName, Syncfusion.SfPicker.XForms.SfPicker formsPicker, Com.Syncfusion.SfPicker.SfPicker nativePicker) SfPickerRenderer.OnElementPropertyChanged (System.Object sender, System.ComponentModel.PropertyChangedEventArgs e) (wrapper delegate-invoke) <Module>.invoke_void_object_PropertyChangedEventArgs(object,System.ComponentModel.PropertyChangedEventArgs) BindableObject.OnPropertyChanged (System.String propertyName) D:\a\1\s\Xamarin.Forms.Core\BindableObject.cs:266 Element.OnPropertyChanged (System.String propertyName) D:\a\1\s\Xamarin.Forms.Core\Element.cs:362 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) D:\a\1\s\Xamarin.Forms.Core\BindableObject.cs:510 BindableObject.SetValueCore (Xamarin.Forms.BindableProperty property, System.Object value, Xamarin.Forms.Internals.SetValueFlags attributes, Xamarin.Forms.BindableObject+SetValuePrivateFlags privateAttributes) D:\a\1\s\Xamarin.Forms.Core\BindableObject.cs:446 TypedBinding`2[TSource,TProperty].ApplyCore (System.Object sourceObject, Xamarin.Forms.BindableObject target, Xamarin.Forms.BindableProperty property, System.Boolean fromTarget) D:\a\1\s\Xamarin.Forms.Core\TypedBinding.cs:233 TypedBinding`2[TSource,TProperty].Apply (System.Object context, Xamarin.Forms.BindableObject bindObj, Xamarin.Forms.BindableProperty targetProperty, System.Boolean fromBindingContextChanged) D:\a\1\s\Xamarin.Forms.Core\TypedBinding.cs:142 BindableObject.ApplyBindings (System.Boolean skipBindingContext, System.Boolean fromBindingContextChanged) D:\a\1\s\Xamarin.Forms.Core\BindableObject.cs:530 BindableObject.SetInheritedBindingContext (Xamarin.Forms.BindableObject bindable, System.Object value) D:\a\1\s\Xamarin.Forms.Core\BindableObject.cs:246 Element.SetChildInheritedBindingContext (Xamarin.Forms.Element child, System.Object context) D:\a\1\s\Xamarin.Forms.Core\Element.cs:479 TemplatedView.SetChildInheritedBindingContext (Xamarin.Forms.Element child, System.Object context) D:\a\1\s\Xamarin.Forms.Core\TemplatedView.cs:69 Element.<OnBindingContextChanged>b__83_0 (Xamarin.Forms.BindableObject child, System.Object bc) D:\a\1\s\Xamarin.Forms.Core\Element.cs:310 BindableObjectExtensions.PropagateBindingContext[T] (Xamarin.Forms.BindableObject self, System.Collections.Generic.IList`1[T] children, System.Action`2[T1,T2] setChildBindingContext) D:\a\1\s\Xamarin.Forms.Core\BindableObjectExtensions.cs:28 Element.OnBindingContextChanged () D:\a\1\s\Xamarin.Forms.Core\Element.cs:308 VisualElement.OnBindingContextChanged () D:\a\1\s\Xamarin.Forms.Core\VisualElement.cs:827 View.OnBindingContextChanged () D:\a\1\s\Xamarin.Forms.Core\View.cs:158 ContentView.OnBindingContextChanged () D:\a\1\s\Xamarin.Forms.Core\ContentView.cs:16 PancakeView.OnBindingContextChanged () BindableObject.SetInheritedBindingContext (Xamarin.Forms.BindableObject bindable, System.Object value) D:\a\1\s\Xamarin.Forms.Core\BindableObject.cs:247 Element.SetChildInheritedBindingContext (Xamarin.Forms.Element child, System.Object context) D:\a\1\s\Xamarin.Forms.Core\Element.cs:479 Element.<OnBindingContextChanged>b__83_0 (Xamarin.Forms.BindableObject child, System.Object bc) D:\a\1\s\Xamarin.Forms.Core\Element.cs:310 BindableObjectExtensions.PropagateBindingContext[T] (Xamarin.Forms.BindableObject self, System.Collections.Generic.IList`1[T] children, System.Action`2[T1,T2] setChildBindingContext) D:\a\1\s\Xamarin.Forms.Core\BindableObjectExtensions.cs:28 Element.OnBindingContextChanged () D:\a\1\s\Xamarin.Forms.Core\Element.cs:308 VisualElement.OnBindingContextChanged () D:\a\1\s\Xamarin.Forms.Core\VisualElement.cs:827 View.OnBindingContextChanged () D:\a\1\s\Xamarin.Forms.Core\View.cs:158 BindableObject.SetInheritedBindingContext (Xamarin.Forms.BindableObject bindable, System.Object value) D:\a\1\s\Xamarin.Forms.Core\BindableObject.cs:247 Element.SetChildInheritedBindingContext (Xamarin.Forms.Element child, System.Object context) D:\a\1\s\Xamarin.Forms.Core\Element.cs:479 Element.<OnBindingContextChanged>b__83_0 (Xamarin.Forms.BindableObject child, System.Object bc) D:\a\1\s\Xamarin.Forms.Core\Element.cs:310 BindableObjectExtensions.PropagateBindingContext[T] (Xamarin.Forms.BindableObject self, System.Collections.Generic.IList`1[T] children, System.Action`2[T1,T2] setChildBindingContext) D:\a\1\s\Xamarin.Forms.Core\BindableObjectExtensions.cs:28 Element.OnBindingContextChanged () D:\a\1\s\Xamarin.Forms.Core\Element.cs:308 VisualElement.OnBindingContextChanged () D:\a\1\s\Xamarin.Forms.Core\VisualElement.cs:827 View.OnBindingContextChanged () D:\a\1\s\Xamarin.Forms.Core\View.cs:158 Grid.OnBindingContextChanged () D:\a\1\s\Xamarin.Forms.Core\Grid.cs:151 BindableObject.SetInheritedBindingContext (Xamarin.Forms.BindableObject bindable, System.Object value) D:\a\1\s\Xamarin.Forms.Core\BindableObject.cs:247 Element.set_Parent (Xamarin.Forms.Element value) D:\a\1\s\Xamarin.Forms.Core\Element.cs:201 Element.OnChildRemoved (Xamarin.Forms.Element child, System.Int32 oldLogicalIndex) D:\a\1\s\Xamarin.Forms.Core\Element.cs:342 VisualElement.OnChildRemoved (Xamarin.Forms.Element child, System.Int32 oldLogicalIndex) D:\a\1\s\Xamarin.Forms.Core\VisualElement.cs:843 Layout`1[T].OnChildRemoved (Xamarin.Forms.Element child, System.Int32 oldLogicalIndex) D:\a\1\s\Xamarin.Forms.Core\Layout.cs:33 Layout.OnInternalRemoved (Xamarin.Forms.View view, System.Int32 oldIndex) D:\a\1\s\Xamarin.Forms.Core\Layout.cs:455 Layout.InternalChildrenOnCollectionChanged (System.Object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e) D:\a\1\s\Xamarin.Forms.Core\Layout.cs:418 (wrapper delegate-invoke) <Module>.invoke_void_object_NotifyCollectionChangedEventArgs(object,System.Collections.Specialized.NotifyCollectionChangedEventArgs) ObservableCollection`1[T].OnCollectionChanged (System.Collections.Specialized.NotifyCollectionChangedEventArgs e) /Users/builder/jenkins/workspace/archive-mono/2020-02/android/release/external/corefx/src/System.ObjectModel/src/System/Collections/ObjectModel/ObservableCollection.cs:263 ObservableCollection`1[T].OnCollectionChanged (System.Collections.Specialized.NotifyCollectionChangedAction action, System.Object item, System.Int32 index) /Users/builder/jenkins/workspace/archive-mono/2020-02/android/release/external/corefx/src/System.ObjectModel/src/System/Collections/ObjectModel/ObservableCollection.cs:338 ObservableCollection`1[T].RemoveItem (System.Int32 index) /Users/builder/jenkins/workspace/archive-mono/2020-02/android/release/external/corefx/src/System.ObjectModel/src/System/Collections/ObjectModel/ObservableCollection.cs:182 Collection`1[T].Remove (T item) /Users/builder/jenkins/workspace/archive-mono/2020-02/android/release/external/corefx/src/Common/src/CoreLib/System/Collections/ObjectModel/Collection.cs:128 ObservableWrapper`2[TTrack,TRestrict].Clear () D:\a\1\s\Xamarin.Forms.Core\ObservableWrapper.cs:45 StateLayoutController.SwitchToTemplate (Xamarin.CommunityToolkit.UI.Views.LayoutState state, System.String customState, System.Boolean animate) AsyncMethodBuilderCore+<>c.<ThrowAsync>b__7_0 (System.Object state) /Users/builder/jenkins/workspace/archive-mono/2020-02/android/release/mcs/class/referencesource/mscorlib/system/runtime/compilerservices/AsyncMethodBuilder.cs:1021 SyncContext+<>c__DisplayClass2_0.<Post>b__0 () /Users/builder/azdo/_work/2/s/xamarin-android/src/Mono.Android/Android.App/SyncContext.cs:36 Thread+RunnableImplementor.Run () /Users/builder/azdo/_work/2/s/xamarin-android/src/Mono.Android/Java.Lang/Thread.cs:36 IRunnableInvoker.n_Run (System.IntPtr jnienv, System.IntPtr native__this) /Users/builder/azdo/_work/2/s/xamarin-android/src/Mono.Android/obj/Release/monoandroid10/android-29/mcw/Java.Lang.IRunnable.cs:84 (wrapper dynamic-method) Android.Runtime.DynamicMethodNameCounter.35(intptr,intptr)

NuGet Packages:

  • SF packages: 19.2.0.47
  • Xamarin.Android.Support.v7.AppCompat: 28.0.0.3
  • Xamarin.AndroidX.AppCompat.AppCompatResources: 1.3.0
  • Xamarin.AndroidX.Core: 1.5.0
  • Xamarin.AndroidX.Legacy.Support.V4: 1.0.07
  • Xamarin.AndroidX.Lifecycle.LiveData: 2.3.1
  • Xamarin.AndroidX.MediaRouter: 1.2.4
  • Xamarin.AndroidX.Palette: 1.0.0.7
  • Xamarin.AndroidX.RecyclerView: 1.2.1
  • Xamarin.Forms: 5.0.0.2083
  • Xamarin.Forms.PancakeView: 2.3.0.759
  • Xamarin.Google.Android.Material: 1.3.0.1
  • Xamarin.Google.Dagger: 2.37.0
  • Xamarin.GooglePlayServices.Base: 117.6.0
AndroidManifest:
  • Min SDK: API 21
  • Target SDK: API 29

Device:
  • Emulated Pixel 3 XL, Android 9.0 (API 28)
  • Intel x86 Atom System Image
Build:
  • Android SDK Platform-Tools: 31.0.2
  • Android SK Build-Tools: 30.0.2, 29.0.2
  • Android Emulator: 30.7.5
  • Android SDK Tools: 26.1.1

3 Replies

JK Jeya Kasipandi Syncfusion Team July 29, 2021 12:11 PM UTC

Hi Andrew, 

We have checked the reported issue based on the provided information, but we are unable to reproduce the reported issue. Please find the sample from below link

Sample Link:

Could you please check the issue with the above sample and let us know whether it is reproduced or not ?. If the issue was not reproduced in this sample, please revert us by modifying the sample based on your application scenario or provide the sample. This will be helpful for us to provide better solution at the earliest.

Regards,
Jeya K 



AH Andrew Hoke July 29, 2021 07:19 PM UTC

I've played with the sample for about an hour mirroring my project setup and code, and I can't reproduce it either. Very disappointing. Guess I have to live with OneWayToSource binding unless it magically fixes itself.



JK Jeya Kasipandi Syncfusion Team July 30, 2021 11:21 AM UTC

Hi Andrew,

Thanks for the update.

Since we are not able to replicate the issue in our side and your side as well, we will keep this open and if you come across the issue and able to replicate, we will fix the issue with the details you share.

Regards,
Jeya K

Loader.
Up arrow icon