We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
close icon

Signature using SfImageEditor => System.NullReferenceException

Hi,

I try to use SfImageEditor. So I add a Shape with a Path.

First attempt :
            var signature = new SfImageEditor {
                Margin = 0,
                HorizontalOptions = LayoutOptions.FillAndExpand,
                VerticalOptions = LayoutOptions.FillAndExpand
            };
            signature.ToolbarSettings.IsVisible = false;
            signature.AddShape(ShapeType.Path, new PenSettings { Color = Color.Black, StrokeWidth = 2f });
            signatureBorder.Content = signature;
With this code it doesn't draw anything.

Second attempt :
            var signature = new SfImageEditor {
                Margin = 0,
                HorizontalOptions = LayoutOptions.FillAndExpand,
                VerticalOptions = LayoutOptions.FillAndExpand
            };
            signature.ToolbarSettings.IsVisible = false;
            Device.StartTimer(TimeSpan.FromMilliseconds(1000), () => {
                signature.AddShape(ShapeType.Path, new PenSettings { Color = Color.Black, StrokeWidth = 2f });
                return false;
            });
            signatureBorder.Content = signature;
With this code it does draw but I have some exception when I touch the element too fast :
12-31 10:36:40.416 I/MonoDroid( 1187): System.NullReferenceException: Object reference not set to an instance of an object.
12-31 10:36:40.417 I/MonoDroid( 1187):   at Syncfusion.SfImageEditor.Android.DrawShapeView.TouchMove (System.Single x, System.Single y) [0x00055] in <eadafab7c9844b21b2dadcb8abad79e4>:0 
12-31 10:36:40.417 I/MonoDroid( 1187):   at Syncfusion.SfImageEditor.Android.DrawShapeView.OnTouchMove (Android.Views.MotionEvent e) [0x00016] in <eadafab7c9844b21b2dadcb8abad79e4>:0 
12-31 10:36:40.417 I/MonoDroid( 1187):   at Syncfusion.SfImageEditor.Android.DrawShapeView.OnTouchEvent (Android.Views.MotionEvent e) [0x0002d] in <eadafab7c9844b21b2dadcb8abad79e4>:0 
12-31 10:36:40.417 I/MonoDroid( 1187):   at Syncfusion.SfImageEditor.Android.ZoomLayout.OnTouchEvent (Android.Views.MotionEvent e) [0x00389] in <eadafab7c9844b21b2dadcb8abad79e4>:0 
12-31 10:36:40.417 I/MonoDroid( 1187):   at Android.Views.View.n_OnTouchEvent_Landroid_view_MotionEvent_ (System.IntPtr jnienv, System.IntPtr native__this, System.IntPtr native_e) [0x00011] in <82e50ec67af648c3b9f43b3d70e21b96>:0 
12-31 10:36:40.417 I/MonoDroid( 1187):   at (wrapper dynamic-method) Android.Runtime.DynamicMethodNameCounter.39(intptr,intptr,intptr)

I need some help on this. Thanks.

Regards,
Benoît NELISSEN

4 Replies

RA Rachel A Syncfusion Team January 2, 2020 08:38 AM UTC

Hi Nelissen, 
 
Greetings from Syncfusion. 
 
Query 1: With first attempt code it doesn't draw anything. 
We have analyzed your query, you have added the Shape after the InitializeComponent call. If you added like this, the Shape not get added in ImageEditor. Because the ImageEditor will not be loaded completely and size is not getting calculated. So, we have suggested you add the Shape from the ImageLoaded event or loaded from Initialization phase with some delay (as like you mentioned as second attempt). 
 
Query 2: With second attempt code it does draw but I have some exception when I touch the element too fast 
We have created a simple SfImageEditor sample with the provided snippet and checked the reported crash by draw the path again and again too fast. We afraid we are not able to reproduce the reported crash. Also, we have checked in our source level with the provided Call Stack, but there is no possibility for the Null Reference exception occurs. Can you please check with the tested sample and video in the following location? 
 
 
 
If still you are facing the problem, please revert us by modifying the sample based on your application along with replication steps like short video and configuration details, etc. This would be helpful for us to give better solution in this. 
 
We have checked with the below configuration 
VS: Professional 2019, Version: 16.3.3 
Simulator: Nexus 5X with API 27 
Syncfusion Version: 17.4.0.40 
Xamarin Forms Version: 3.6.0.344457 
 
Regards, 
Rachel. 



NB Nelissen Benoît January 8, 2020 10:42 AM UTC

Hi,

Query 1:
Ok. I understand the delay. I can't use ImageLoaded event because I don't have any image. It is a signature pad.

Query 2:
I have modified your example with some of my code and update of nugets like Xamarin Forms. You have now the full example.
It cashes when I touch the ImageEditor too quickly (and multiple times ?).

Regards,
Benoît NELISSEN

Attachment: IESample1826714110_e59baa.zip


RS Ramya Soundar Rajan Syncfusion Team January 9, 2020 04:15 PM UTC

Hi Nilessen, 
 
We can reproduce the reported issue and currently we are validating the issue. We will update you the status on 10th January,2020.  
 
Regards, 
Ramya. 



RS Ramya Soundar Rajan Syncfusion Team January 10, 2020 02:34 PM UTC

Hi Nelissen 
 
Thanks for your patience.  
 
We can reproduce the reported issue and we confirmed [Android]NullReferenceException thrown when drawing path with time delay while continuously navigating pages” as an issue. We will provide the patch on 28th January 2020. We appreciate your patience until then.  
 
You can now track the status of your request, review the proposed resolution timeline, and contact us for any further inquiries through this link.   
 
 
Note: The provided feedback link is private, and you need to login to view this feedback.   
 
Regards,  
Ramya.  


Loader.
Live Chat Icon For mobile
Up arrow icon