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

SfDataGrid crashes unexpectly

Hello,

SfDataGrid raises this exception:

09-19 18:09:14.802 I/MonoDroid(20350): Java.Lang.NullPointerException: Attempt to invoke virtual method 'long android.graphics.Paint.getNativeInstance()' on a null object reference
09-19 18:09:14.802 I/MonoDroid(20350):   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in /Users/builder/data/lanes/3511/501e63ce/source/mono/mcs/class/referencesource/mscorlib/system/runtime/exceptionservices/exceptionservicescommon.cs:143 
09-19 18:09:14.802 I/MonoDroid(20350):   at Java.Interop.JniEnvironment+InstanceMethods.CallNonvirtualVoidMethod (Java.Interop.JniObjectReference instance, Java.Interop.JniObjectReference type, Java.Interop.JniMethodInfo method, Java.Interop.JniArgumentValue* args) [0x000a7] in /Users/builder/data/lanes/3511/501e63ce/source/Java.Interop/src/Java.Interop/Java.Interop/JniEnvironment.g.cs:12083 
09-19 18:09:14.802 I/MonoDroid(20350):   at Java.Interop.JniPeerMembers+JniInstanceMethods.FinishCreateInstance (System.String constructorSignature, Java.Interop.IJavaPeerable self, Java.Interop.JniArgumentValue* parameters) [0x00060] in /Users/builder/data/lanes/3511/501e63ce/source/Java.Interop/src/Java.Interop/Java.Interop/JniPeerMembers.JniInstanceMethods.cs:148 
09-19 18:09:14.802 I/MonoDroid(20350):   at Android.Graphics.Paint..ctor (Android.Graphics.Paint paint) [0x00078] in /Users/builder/data/lanes/3511/501e63ce/source/monodroid/src/Mono.Android/platforms/android-24/src/generated/Android.Graphics.Paint.cs:730 
09-19 18:09:14.802 I/MonoDroid(20350):   at Syncfusion.SfDataGrid.CellElement.CalculateTopAndBottomPadding (Android.Views.GravityFlags alignment, Android.Widget.TextView view, System.String text, System.Int32 height, 


Following the source code and the stack trace, I can se that OnLayout is calling to calculatePaddingForAlignment and CalculateTopAndBottomPadding.

CalculateTopAndBottomPadding, implemented in CellElement is creating an instance of Paint object using the paintText property. It seems that NullPointerException is produced because paintText is sometimes null.


The unique point in the code where paintText could be null is calling to the Dispose method because it is always initialized:


         protected override void Dispose(bool disposing)
        {
            if (disposing)
            {
                this.paintText = null;
                this.paintBorder = null;
                this.GridColumn = null;
                this.GetDataColumn = null;
                this.gridModel = null;
            }
            base.Dispose(disposing);
        }


Perhaps, for some reason, sometimes OnLayout is called after Dispose and it generates a NullPointerException in GridHeaderCellControl.


I cannot be sure because I cannot debug but the exception could be produced in CellElement.CalculateTopAndBottomPadding executing the code:


     Paint paint = new Paint(paintText); <---- HERE BECAUSE paintText is NULL
        paint.SetTypeface(view.get_Typeface());
        paint.set_Flags(65);
        paint.set_TextSize(view.get_TextSize());


Regards!




3 Replies

AN Ashok N Syncfusion Team September 27, 2017 11:09 AM UTC

Hi Sandra,   
    
Thanks for contacting Syncfusion support. 
    
We have checked the reported issue by loading our SfDataGrid inside a fragment but we are not able to reproduce the issue. We have tested by navigating between two SfDataGrid’s but it was working properly. For your reference we have attached the working copy of the sample in the below location, please check it. Please do revert us by modifying our sample to replicate the issue or share your sample along with replication procedure, that would be more helpful for us to proceed further.    
 
    
Regards,    
Ashok 



SR Sandra Reunion October 2, 2017 02:48 PM UTC

I have updated the info in the direct-track. Please, review asap because we are in a very complex situation with our project... Thanks.



AN Ashok N Syncfusion Team October 3, 2017 10:07 AM UTC

Hi Sandra, 
 
Thanks for your update. We have provided the response in direct-track incident, please follow that incident for further updates. 
 
Regards, 
Ashok

Loader.
Live Chat Icon For mobile
Up arrow icon