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

NullReferenceException in GridCellBaseRenderer.OnTapped

Hi, my users have been experiencing an intermittent crash when tapping on a row on the SFDataGrid. The stack trace is the following:

SIGABRT: Object reference not set to an instance of an object
GridCellBaseRenderer.OnTapped (UIKit.UITapGestureRecognizer gesture)
GridCellBaseRenderer.<OnElementChanged>b__6_0 ()
UIGestureRecognizer+ParameterlessDispatch.Activated ()
(wrapper managed-to-native) UIKit.UIApplication.UIApplicationMain(int,string[],intptr,intptr)
UIApplication.Main (System.String[] args, System.String principalClassName, System.String delegateClassName)
Application.Main (System.String[] args)

The first time I saw this issue was while using version 17.1, but it also happens in 17.2 and 17.3. I noticed it likely started when my app moved to Xamarin Forms 4.0, and still exists as a problem when I test with the Xamarin Forms 4.3 preview.

I have tried removing my handler for GridTapped, and using the SelectionChanged event instead, but the crash still occurs (intermittently, just as before)

Any ideas what else I could try?

11 Replies

BS Balasubramani Sundaram Syncfusion Team September 30, 2019 07:31 PM UTC

Hi Ken,    
Thank you for contacting Syncfusion support.    
Based on your provided stack trace, we have checked the issue “Exception throwing when tap the grid cell” in SfDataGrid, but we are unable to replicate the issue in our end. When have tested in all three platforms and also checked the stack trace in iOS platform with hoked selection changed as well grid tapped event and tapped the grid cell but we didn’t face any exception and its working fine as we expected. 
Please refer to the below sample and video.   
Note: Issue has been checked with Xamarin. Forms version and Syncfusion NuGet version beta   
Please check the sample and let us know if you still facing the same issue? If not, please modify the sample based on your scenario and revert us with the more details, so that it will be helpful for us to check on it and provide you the solution at the earliest.      
Balasubramani Sundaram   

KP Ken Pespisa September 30, 2019 08:58 PM UTC

Thanks. I have a sample project that runs into the same issue as my main project. Since my project is complex, I've pulled in some freely available data on breakfast cereals to populate the grid, and copied relevant code from my main project to this sample. Forgive the sloppiness :)

If you load this app on a device (it *may* also happen in the simulator), it will display a searchbar and the datagrid when it opens. Follow these steps to crash the app:

  1. Type "al" in the search bar.
  2. Tap the first item in the datagrid, which opens a details page
  3. Navigate back to the datagrid using the back button in the upper left corner.
  4. Clear the search bar by tapping the X in the right-side of the search bar.
  5. Type "br" in the search bar.
  6. Tap the first item in the datagrid.
  7. --Crash--
This problem seems to be intermittent, so you may need to follow steps 1-4 repeatedly, up to a dozen times, with different two-letter searches to hit the crash. I've attached a video demonstrating the crash.

Attachment: RPReplay_Final1569876891.mov_347410d2.zip

KP Ken Pespisa September 30, 2019 08:58 PM UTC

Here is the sample project

Attachment: SFDataGridCrash_7e9ebadb.zip

BS Balasubramani Sundaram Syncfusion Team October 2, 2019 03:58 AM UTC

Hi Ken, 
Thank you for the update.  
Based on the provided sample, we have checked the issue the “DataGrid crash when grid tapped” but we unable able to reproduce on our end. We followed a step as you mentioned in the response then also, we unable to reproduce the issue. We have checked issue in Mi A1 device with android version 7.1.2. We suspect that it causes in the specific device and please provide the device configuration and model it will help us do analysis and provide the solution earlier. 
Please refer the below video,  
Balasubramani Sundaram. 

KP Ken Pespisa October 2, 2019 10:53 AM UTC

Thank you. Please try with an iOS device running iOS 13 or later. 

I have seen crashes on iPhone X, XS Max, 11 Pro, but it should happen on any iPhone. 


BS Balasubramani Sundaram Syncfusion Team October 4, 2019 02:00 AM UTC

Hi Ken,

Thanks for the update.

We can able to reproduce the issue “Null reference exception throwing on-grid tap” on the further analysis we found it cause due to the reason of auto-correction when we type the “Br” to “Be” at the time of tapping grid.

When we are typing the Br it auto corrected and show in tip tool “Be” below the search bar If we didn’t cancel the autocorrect and we tap the grid then the focus changed to data grid at the time of focus change the auto-corrected spell check has done in search bar and text changed event get fired before tap event call, in the text changed event your again changing the collection to data grid. When you're changing the collection at run time in our source-level we will reset the current view by disposing of all the view elements of the old stack and created a new view element for current filtered collection in the data grid. After the time of disposing the old stack view in grid then tapped event get fired for the before old stack view element and null exception throwing. If we cancel the autosuggestion or accept the auto-suggestion means the collection gets filtered correctly and then we tap the grid means its working fine without any crash.

We are currently validating the issue and we need some time to find the exact point of issue and we will provide you further details on October 7th, 2019.

We appreciate your patience until then.

Balasubramani Sundaram.

BS Balasubramani Sundaram Syncfusion Team October 8, 2019 03:52 AM UTC

Hi Ken,

Thank you for your patience,

As we had explained in a previous response, auto-correction was happing when focus changes from the search text box to the data grid while tapping the data grid. Suggestion text gets applied and item source of data grid were rested this is an exact cause of the issue, As, per our flow isn’t a valid case of item source changing at the time of focus changing with tap action. If we disable the SpellChecked property in the search box it's working fine as we expected otherwise please let us know to include the null check in our source level.

Balasubramani Sundaram. 

KP Ken Pespisa October 8, 2019 12:53 PM UTC

Thank you. You are correct that disabling autocorrect on the search bar fixes the issue. As I am using Xamarin Forms, I was required to add an effect to the control to disable autocorrect in iOS. For others that hit this issue, the code is below.

My personal opinion is that Syncfusion should add the null check to prevent this behavior in the future, though. But regarding this ticket, I'm happy to move forward with the workaround, and I greatly appreciate your help finding the root cause. I doubt I would have discovered this on my own.

public class SearchBarEffect : PlatformEffect
        protected override void OnAttached()
            var searchBar = (UISearchBar)this.Control;
            searchBar.SearchBarStyle = UISearchBarStyle.Minimal;   // this is most likely not needed. It was part of another fix in my app.
            searchBar.AutocorrectionType = UITextAutocorrectionType.No;
            searchBar.AutocapitalizationType = UITextAutocapitalizationType.None;

        protected override void OnDetached()


BS Balasubramani Sundaram Syncfusion Team October 9, 2019 07:05 PM UTC

Hi Ken,  
Thanks for the update,  
The reported issue of “Null reference exception thrown when tapping the data grid” has been confirmed and We had logged a defect report for the same and we will fix this issue and include the issue fix in our upcoming weekly NuGet which is estimated to be available on October 22nd, 2019. We appreciate your patience until then. 
We will provide the feedback link on October 10th, 2019 from that you can track the status of this issue report. 
Balasubramani Sundaram. 

BS Balasubramani Sundaram Syncfusion Team October 10, 2019 05:36 AM UTC

Hi Ken,   
Thank you for your patience 
You can track the status of this report through the following feedback link,    
Note: The provided feedback link is private, and you need to login to view this feedback. 
Balasubramani Sundaram. 

FP Farjana Parveen Ayubb Syncfusion Team October 22, 2019 10:23 AM UTC

Hi Ken, 
We have fixed the mentioned issue “Null reference exception thrown when tapping the data grid” and included the issue fix in our weekly NuGet update version which is available for download (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. 
Farjana Parveen A 

Live Chat Icon For mobile
Up arrow icon