ios sfchat editer bug

When i click sfchat editor

sometimes throw null reference exception.




- $exception {System.NullReferenceException: Object reference not set to an instance of an object
  at Syncfusion.XForms.iOS.Chat.ChatEditorRenderer.GetChatControl () [0x00015] in <c63fbce0be11422c909e455801561f69>:0 
  at Syncfusion.XForms.iOS.Chat.ChatEditorRenderer.OnEditorFocused (System.Object sender, Xamarin.Forms.FocusEventArgs e) [0x00008] in <c63fbce0be11422c909e455801561f69>:0 
  at (wrapper delegate-invoke) System.EventHandler`1[Xamarin.Forms.FocusEventArgs].invoke_void_object_TEventArgs(object,Xamarin.Forms.FocusEventArgs)
  at Xamarin.Forms.VisualElement.OnFocused () [0x00000] in D:\a\1\s\Xamarin.Forms.Core\VisualElement.cs:990 
  at Xamarin.Forms.VisualElement.OnIsFocusedPropertyChanged (Xamarin.Forms.BindableObject bindable, System.Object oldvalue, System.Object newvalue) [0x00013] in D:\a\1\s\Xamarin.Forms.Core\VisualElement.cs:1060 
  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) [0x00120] in D:\a\1\s\Xamarin.Forms.Core\BindableObject.cs:512 
  at Xamarin.Forms.BindableObject.SetValueCore (Xamarin.Forms.BindableProperty property, System.Object value, Xamarin.Forms.Internals.SetValueFlags attributes, Xamarin.Forms.BindableObject+SetValuePrivateFlags privateAttributes) [0x00173] in D:\a\1\s\Xamarin.Forms.Core\BindableObject.cs:446 
  at Xamarin.Forms.BindableObject.SetValueCore (Xamarin.Forms.BindablePropertyKey propertyKey, System.Object value, Xamarin.Forms.Internals.SetValueFlags attributes) [0x00000] in D:\a\1\s\Xamarin.Forms.Core\BindableObject.cs:379 
  at Xamarin.Forms.Element.SetValueFromRenderer (Xamarin.Forms.BindablePropertyKey property, System.Object value) [0x00000] in D:\a\1\s\Xamarin.Forms.Core\Element.cs:254 
  at Xamarin.Forms.Platform.iOS.EditorRendererBase`1[TControl].OnStarted (System.Object sender, System.EventArgs eventArgs) [0x00006] in <c931dad88b3a4eb1a8b9d018a5818b8c>:0 
  at UIKit.UITextView+_UITextViewDelegate.EditingStarted (UIKit.UITextView textView) [0x0000a] in /Users/builder/azdo/_work/1/s/xamarin-macios/src/build/ios/native/UIKit/UITextView.g.cs:2757 
  at (wrapper managed-to-native) UIKit.UIApplication.UIApplicationMain(int,string[],intptr,intptr)
  at UIKit.UIApplication.Main (System.String[] args, System.IntPtr principal, System.IntPtr delegate) [0x00005] in /Users/builder/azdo/_work/1/s/xamarin-macios/src/UIKit/UIApplication.cs:86 
  at UIKit.UIApplication.Main (System.String[] args, System.String principalClassName, System.String delegateClassName) [0x0000e] in /Users/builder/azdo/_work/1/s/xamarin-macios/src/UIKit/UIApplication.cs:65 
  at EveryonePT.iOS.Application.Main (System.String[] args) [0x00001] in C:\Users\proware\source\repos\EveryonePT\EveryonePT\EveryonePT.iOS\Main.cs:17 } System.NullReferenceException


4 Replies 1 reply marked as answer

KK Karthikraja Kalaimani Syncfusion Team April 16, 2021 01:04 PM UTC

Hi Kss,

 
We have checked the reported issue “Null reference expection thrown when click on input view” in SfChat and we could not able to reproduce the issue in our end. We have checked in SfChat version 19.1.0.56 and Xamarin forms version 4.5.0.617. So, could you please let us the below details to proceed further and provide a better solution asap.

i) SfChat and Xamarin forms version
ii) video of the issue
iii) have you used navigation page or simple page, Tabbed page or master details page in your application ?
iv) Complete configuration of SfChat.

Regards,
Karthik Raja 



KS kss April 19, 2021 01:21 AM UTC

SfChat 19.1.0.56
XF 5.0.0.2012

I figure out when ios throw null ref exception.

public partial class MainPage : ContentPage
    {

        ChatPage page = new ChatPage
        {
            BindingContext = new ChatVM(),
        };

        public MainPage()
        {
            InitializeComponent();
        }

        private async void Button_Clicked(object sender, EventArgs e)
        {
            await Navigation.PushAsync(page);
        }
    }

I create chat page in ctor (Not in click method) for better perfomance.
It is android good work but ios sometime throw null exception when i click editor.
Thx


KK Karthikraja Kalaimani Syncfusion Team April 19, 2021 12:22 PM UTC

Hi Kss,

We could able to reproduce the reported crash issue. Currently, we are validating the issue. So, we will validate and update the details on or before 21th April 2021. We appreciate your patience until then.

Regards,
Karthik Raja

 



KK Karthikraja Kalaimani Syncfusion Team April 21, 2021 01:32 PM UTC

Hi Kss,

We have checked the reported issue “NullReference Exception thrown in SfChat” in our source. We saw that Editor’s is getting disposed automatically when navigate back to previous page. So, we suggest you to create a new SfChat page and create a new binding context.

Code snippet :

 
public partial class MainPage : ContentPage
{
ChatPage page;
public MainPage()
{
InitializeComponent();
}
 
protected override void OnAppearing()
{
base.OnAppearing();
 
page = new ChatPage();
page.BindingContext = new GettingStartedViewModel();
 
} 
protected override void OnDisappearing()
{
base.OnDisappearing();

}
 
void Button_Clicked(System.Object sender, System.EventArgs e)
{
Navigation.PushAsync(page);
}
}
 
 


Regards,
Karthik Raja 


Marked as answer
Loader.
Up arrow icon