Backspace in a empty AutoComplete cause NullReferenceException

Hello, Im using Syncfusion.Xamarin.SfAutoComplete package version 20.2.0.39 and after type backspace set empty to collection binding to DataSource property  throws NullReferenceException.

On Android its ok, error only on iOS


My control is configured to: 

SuggestionMode = SuggestionMode.Custom

Filter += (_, _) => true;

After property "Text" changed I run a search and set DataSource with result, empty if none result.


###Trace

Syncfusion.SfAutoComplete.iOS

SfAutoComplete.set_DataSource (System.Collections.Generic.IEnumerable`1[T] value)

Syncfusion.SfAutoComplete.XForms.iOS

SfAutoCompleteMapping.OnAutoCompletePropertiesChanged (System.String propertyName, Syncfusion.SfAutoComplete.XForms.SfAutoComplete formsAutoComplete, Syncfusion.SfAutoComplete.iOS.SfAutoComplete nativeAutoComplete)

Syncfusion.SfAutoComplete.XForms.iOS

SfAutoCompleteRenderer.OnElementPropertyChanged (System.Object sender, System.ComponentModel.PropertyChangedEventArgs e)

(wrapper delegate-invoke) <Module>.invoke_void_object_PropertyChangedEventArgs(object,System.ComponentModel.PropertyChangedEventArgs)

Xamarin.Forms

BindableObject.OnPropertyChanged (System.String propertyName) D:\a\1\s\Xamarin.Forms.Core\BindableObject.cs:266

Xamarin.Forms

Element.OnPropertyChanged (System.String propertyName) D:\a\1\s\Xamarin.Forms.Core\Element.cs:362

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) D:\a\1\s\Xamarin.Forms.Core\BindableObject.cs:510

Xamarin.Forms

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

Xamarin.Forms

BindingExpression.ApplyCore (System.Object sourceObject, Xamarin.Forms.BindableObject target, Xamarin.Forms.BindableProperty property, System.Boolean fromTarget) D:\a\1\s\Xamarin.Forms.Core\BindingExpression.cs:160

Xamarin.Forms

BindingExpression.Apply (System.Boolean fromTarget) D:\a\1\s\Xamarin.Forms.Core\BindingExpression.cs:56

Xamarin.Forms

BindingExpression+BindingExpressionPart.<PropertyChanged>b__49_0 () D:\a\1\s\Xamarin.Forms.Core\BindingExpression.cs:767

Xamarin.Forms

BindingExpression+BindingExpressionPart.PropertyChanged (System.Object sender, System.ComponentModel.PropertyChangedEventArgs args) D:\a\1\s\Xamarin.Forms.Core\BindingExpression.cs:778

Xamarin.Forms

BindingExpression+WeakPropertyChangedProxy.OnPropertyChanged (System.Object sender, System.ComponentModel.PropertyChangedEventArgs e) D:\a\1\s\Xamarin.Forms.Core\BindingExpression.cs:671

(wrapper delegate-invoke) <Module>.invoke_void_object_PropertyChangedEventArgs(object,System.ComponentModel.PropertyChangedEventArgs)

CommunityToolkit.Mvvm.ComponentModel

ObservableObject.OnPropertyChanged (System.ComponentModel.PropertyChangedEventArgs e) /_/CommunityToolkit.Mvvm/ComponentModel/ObservableObject.cs:48

CommunityToolkit.Mvvm.ComponentModel

ObservableObject.OnPropertyChanged (System.String propertyName) /_/CommunityToolkit.Mvvm/ComponentModel/ObservableObject.cs:69

Nectar.Mobile.Framework.MVVM

NectarObservableObject.OnPropertyChanged (System.String propertyName) /Users/gabriel/Projects/Nectar.Mobile/Nectar.Mobile.Framework/MVVM/NectarObservableObject.cs:25

Nectar.Mobile.Pages.DevolucaoRequisicaoMaterial.Lista

ListaDevolucaoRequisicaoMaterialViewModel.set_RequisicaoMaterialDTO_List (System.Collections.Generic.List`1[T] value) /Users/gabriel/Projects/Nectar.Mobile/Nectar.Mobile/Pages/DevolucaoRequisicaoMaterial/Lista/ListaDevolucaoRequisicaoMaterialViewModel.cs:187

Nectar.Mobile.Pages.DevolucaoRequisicaoMaterial.Lista

ListaDevolucaoRequisicaoMaterialViewModel.BuscarRequisicaoMaterial () /Users/gabriel/Projects/Nectar.Mobile/Nectar.Mobile/Pages/DevolucaoRequisicaoMaterial/Lista/ListaDevolucaoRequisicaoMaterialViewModel.cs:268



14 Replies

RS Ruba Shanmugam Syncfusion Team July 26, 2022 09:41 AM UTC

Hi Gabriel,


We are unable to replicate the provided SfAutoComplete crash on our side. However, based on the stack trace we have added the null check and argument exception condition and please get the assemblies from the attachments.


Assembly Version: 20.2.0.39


Note: Please refer to the below link to apply the custom assembly 


https://www.syncfusion.com/kb/8279/how-to-apply-the-custom-assemblies-when-configured-the-project-with-syncfusion-nuget

  

Currently, we have patch support only for the main and service pack release version, not for the weekly NuGet releases. Could you please check this fix with your application and let us know, whether the issue is resolved or not.


Regards,

Ruba Shanmugam


Attachment: SfAutoComplete_Assembly_8169b559.zip


GD gabriel de sousa August 1, 2022 07:21 PM UTC

Hi, this fix solved the error on iOS.


Tank you.



RS Ruba Shanmugam Syncfusion Team August 2, 2022 12:08 PM UTC

Hi Gabriel,


Thanks for the update. The issue fix will be available on in our next weekly release. Which is expected to roll out on third week of August 2022. We will let you know once it’s published. We appreciate your patience until then.


Regards,

Ruba Shanmugam



MW Markus Wolff August 31, 2022 04:09 PM UTC

I have a similar issue. The application crashes on iOS regardless of the number of items found when I hit backspace.

{System.ArgumentNullException: Value cannot be null.Parameter name: source at System.Linq.Enumerable.Count[TSource] (System.Collections.Generic.IEnumerable`1[T] source) [0x00003] in /Library/Frameworks/Xamarin.iOS.framework/Versions/Current/src/Xamarin.iOS/external/corefx/src/System.Linq/src/System/Linq/Count.cs:16 at Syncfusion.SfAutoComplete.iOS.SfAutoComplete.Handle_BackPressed (System.Object sender, System.EventArgs e) [0x00000] in <08496432479548228fbca25a8708b6d2>:0 at Syncfusion.SfAutoComplete.iOS.CustomTextField.OnBackPressed (System.EventArgs args) [0x00008] in <08496432479548228fbca25a8708b6d2>:0 at Syncfusion.SfAutoComplete.iOS.CustomTextField.DeleteBackward () [0x0000d] in <08496432479548228fbca25a8708b6d2>:0 at (wrapper managed-to-native) UIKit.UIApplication.UIApplicationMain(int,string[],intptr,intptr) at UIKit.UIApplication.Main (System.String[] args, System.String principalClassName, System.String delegateClassName) [0x00013] in /Library/Frameworks/Xamarin.iOS.framework/Versions/15.12.0.2/src/Xamarin.iOS/UIKit/UIApplication.cs:75 at SpaManagerMobile.iOS.Application.Main (System.String[] args) [0x00001] in D:\Users\marku\Projekte\Spa Manager\spa-manager-app\src\SpaManagerMobile.iOS\Main.cs:17 }

The SfAutocomplete is bound to a typed ObservableCollection via XAML binding:

<syncfusion:SfAutoComplete

                    HorizontalOptions="FillAndExpand"

                    TextColor="{StaticResource SpaPurple}"

                    ClearButtonColor="{StaticResource SpaPurple}"

                    BorderColor="{StaticResource SpaPurple}"

                    TextSize="20"

                    NoResultsFoundText="Kunde/Kundin nicht gefunden"

                    NoResultsFoundTextColor="{StaticResource SpaPink}"

                    DataSource="{Binding Customers}"

                    DisplayMemberPath="Name"

                    Watermark="Kundenauswahl"

                    SelectedItem="{Binding Appointment.Customer}"

                    EnableSelectionIndicator="true">

                    <syncfusion:SfAutoComplete.Margin>

                        <OnPlatform x:TypeArguments="Thickness" Android="0,-10,0,0" iOS="0,0,0,0"/>

                    </syncfusion:SfAutoComplete.Margin>

                </syncfusion:SfAutoComplete>


Tested version is 20.2.0.46, iPhone 12 (iOS 15.5) Emulator, Visual Studio 2022 (17.3.2)




RS Ruba Shanmugam Syncfusion Team September 1, 2022 12:37 PM UTC

Hi Gabriel,


Query: The application crashes on iOS regardless of the number of items found when I hit backspace


We have prepared a sample based on the provided code snippet, but we were unable to replicate the reported issue in iOS when hitting the backspace using the Keyboard. We have recorded a video for your reference; could you please obtain the video and sample from the attachment?


We ask you to try our sample and if your requirement is different, please explain to us briefly and share the replication steps with the sample. It will help us to provide the proper solution at the easiest.  Please let us know if you need any other details.


Regards,

Ruba Shanmugam


Attachment: SfAutoCompleteSample_Video_2b2930af.zip


MW Markus Wolff replied to Ruba Shanmugam September 7, 2022 07:05 PM UTC

Thank you for the fast reply and your work. The sample works for me also. Still the issue remains in my own application, even if I fill the collection with static data like in your ViewModel. I will investigate further and come back to you, if I find a solution or any issue that might be checked by you.




RS Ruba Shanmugam Syncfusion Team September 8, 2022 07:13 AM UTC

Hi Markus,


Thanks for the update. We will wait until hearing from you for the next process.


Regards,

Ruba Shanmugam



MW Markus Wolff September 8, 2022 09:48 AM UTC

I'm still struggling on finding the cause. The Error seems to appear in SfAutoComplete.Handle_BackPressed when running System.Link.Enumerable.Count<Syncfuston.SfAutoComplete.iOS.Token> which collection seems to be null.

Can you tell me what's happening in this routine and how it might be affected by my ViewModel or how I could dig deeper into the code? The VS Debugger halts at UIApplication.Main where I cannot see any furthter than into the stack trace i posted above.

The same application works fine on Android though...



RS Ruba Shanmugam Syncfusion Team September 12, 2022 04:36 AM UTC

Hi Markus,


We are unable to replicate the provided SfAutoComplete crash on our side. However, based on the stack trace we have added the null check condition and please get the assemblies from the attachments.


Assembly Version: 20.2.0.46


Note: Please refer to the below link to apply the custom assembly 


https://www.syncfusion.com/kb/8279/how-to-apply-the-custom-assemblies-when-configured-the-project-with-syncfusion-nuget

  

Currently, we have patch support only for the main and service pack release version, not for the weekly NuGet releases. Could you please check this fix with your application and let us know, whether the issue is resolved or not?


Regards,

Ruba Shanmugam


Attachment: SfAutoComplete_Assembly_db53f825.zip


GA Gary September 28, 2022 05:27 AM UTC

I had the same issue on iOS only, Android worked fine.

I was using 20.2.0.48, but have since updated to 20.2.0.50 and it's now working on iOS.




RS Ruba Shanmugam Syncfusion Team September 29, 2022 07:30 AM UTC

Hi Gary,


Thanks for the information.


Already moved the fix into our latest weekly release. So it's working properly on your side. Please let us know if you need any other details.


Regards,

Ruba Shanmugam



DE Desmond October 10, 2022 08:58 AM UTC

This fix works in 20.2.0.50 but fix isn't in 20.3.0.48 



RS Ruba Shanmugam Syncfusion Team October 11, 2022 04:55 AM UTC

Hi Gary,

Sorry for the inconvenience. We will include the issue fix in our upcoming weekly release. Which will be rolled out on October 18, 2022. We appreciate your patience until then.

Regards,

Ruba Shanmugam



RS Ruba Shanmugam Syncfusion Team October 19, 2022 04:00 AM UTC

Hi Gary,


Thanks for your patience.

We have included the fix in our latest Weekly NuGet release v20.3.0.50 which is available for download (
https://www.nuget.org/ ). We thank you for your support and appreciate your patience in waiting for this update. Please get in touch with us if you would require any further assistance.


Regards,

Ruba Shanmugam


Loader.
Up arrow icon