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 at Syncfusion.Data.TraversalHelper.GetPrevious

Hello,

I'm receiving crashes because of a NullReferenceException in my production app.
I managed to create a demo app that should crash, when you start it.

Steps to reproduce:
1. Debug the demo app.
2. App should crash.

Xamarin Forms version: 4.2.0.778463
SfDataGrid version: 17.2.0.51

Test device: Samsung Galaxy S10, Android 9.0.0

Stack trace:

System.NullReferenceException: Object reference not set to an instance of an object.
   at Syncfusion.Data.TraversalHelper.GetPrevious (Syncfusion.Data.NodeEntry entry) [0x000c0] in <2406d789b2e64470814c04162a45ff6e>:0 
   at Syncfusion.Data.GroupDisplayElements.GetItemAt (System.Int32 index) [0x00062] in <2406d789b2e64470814c04162a45ff6e>:0 
   at Syncfusion.Data.GroupDisplayElements.get_Item (System.Int32 index) [0x00000] in <2406d789b2e64470814c04162a45ff6e>:0 
   at Syncfusion.SfDataGrid.XForms.RowGenerator.UpdateDataRow (System.Collections.Generic.IEnumerable`1[T] rows, System.Int32 rowIndex, Syncfusion.SfDataGrid.XForms.RowRegion region) [0x002a6] in <727c0126a200480083f9ae64a03817a9>:0 
   at Syncfusion.SfDataGrid.XForms.RowGenerator.UpdateRow (System.Collections.Generic.IEnumerable`1[T] rows, System.Int32 rowIndex, Syncfusion.SfDataGrid.XForms.RowRegion region) [0x004c5] in <727c0126a200480083f9ae64a03817a9>:0 
   at Syncfusion.SfDataGrid.XForms.RowGenerator.EnsureRows (Syncfusion.GridCommon.ScrollAxis.VisibleLinesCollection visibleRows, Syncfusion.GridCommon.ScrollAxis.VisibleLinesCollection visibleColumns) [0x00188] in <727c0126a200480083f9ae64a03817a9>:0 
   at Syncfusion.SfDataGrid.XForms.VisualContainer.EnsureItems (System.Boolean needToRefresh) [0x00039] in <727c0126a200480083f9ae64a03817a9>:0 
   at Syncfusion.SfDataGrid.XForms.VisualContainer.OnSizeAllocated (System.Double width, System.Double height) [0x00260] in <727c0126a200480083f9ae64a03817a9>:0 
   at Xamarin.Forms.VisualElement.SizeAllocated (System.Double width, System.Double height) [0x00000] in D:\a\1\s\Xamarin.Forms.Core\VisualElement.cs:784 
   at Xamarin.Forms.Layout.ForceLayout () [0x00000] in D:\a\1\s\Xamarin.Forms.Core\Layout.cs:125 
   at Syncfusion.SfDataGrid.XForms.GridModel.RefreshDataRow () [0x0003a] in <727c0126a200480083f9ae64a03817a9>:0 
   at Syncfusion.SfDataGrid.XForms.GridModel.RefreshView () [0x0003c] in <727c0126a200480083f9ae64a03817a9>:0 
   at Syncfusion.SfDataGrid.XForms.GridModel.OnRecordCollectionChanged (System.Object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e) [0x001c6] in <727c0126a200480083f9ae64a03817a9>:0 
   at Syncfusion.Data.CollectionViewAdv.RaiseCollectionChangedEvent (System.Collections.Specialized.NotifyCollectionChangedEventArgs args) [0x00008] in <2406d789b2e64470814c04162a45ff6e>:0 
   at Syncfusion.Data.CollectionViewAdv.RefreshView (System.Collections.Specialized.NotifyCollectionChangedEventArgs args) [0x00000] in <2406d789b2e64470814c04162a45ff6e>:0 
   at Syncfusion.Data.CollectionViewAdv.Refresh (System.Boolean isProgrammatic) [0x0003f] in <2406d789b2e64470814c04162a45ff6e>:0 
   at Syncfusion.Data.QueryableCollectionView.RefreshFilter (System.Boolean isProgrammatic) [0x0004e] in <2406d789b2e64470814c04162a45ff6e>:0 
   at SfDataGridBugDemo.MainPage.RefreshFilter () [0x0002e] in C:\Source\SfDataGridBugDemo\SfDataGridBugDemo\SfDataGridBugDemo\MainPage.xaml.cs:93 
   at SfDataGridBugDemo.MainPage.PlaylistComboBox_OnSelectedIndexChanged (System.Object sender, System.EventArgs e) [0x000b2] in C:\Source\SfDataGridBugDemo\SfDataGridBugDemo\SfDataGridBugDemo\MainPage.xaml.cs:54 
   at (wrapper dynamic-method) Android.Runtime.DynamicMethodNameCounter.18(intptr,intptr)
   at (wrapper native-to-managed) Android.Runtime.DynamicMethodNameCounter.18(intptr,intptr)


Attachment: SfDataGridBugDemo_44a03b03.zip

5 Replies

BS Balasubramani Sundaram Syncfusion Team September 16, 2019 01:51 PM UTC

Hi Halil, 
  
Thank you for contacting Syncfusion support. 
  
We have checked your sample and could able to replicate the issue “NullReferenceException occurs while refreshing the filter” at our end. We are currently validating the issue. We will validate and provide you further details on or before 18th September 2019. 
  
We appreciate your patience until then. 
  
Regards, 
Balasubramani Sundaram. 



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

Hi Halil,  
 
Thank you for your patience  
 
We have checked the issue “NullReferenceException occurs while refreshing the filter” in our source level but we couldn’t able to find the exact root cause for the issue. We are currently validating issue and we need some time to find the exact root cause of the  issue and we will provide you further details on September 20th, 2019. 
 
We appreciate your patience until then. 
 
Regards,  
Balasubramani Sundaram. 



BS Balasubramani Sundaram Syncfusion Team September 20, 2019 12:08 PM UTC

Hi Halil,    
   
Thanks for your patience.  
   
We have analyzed the issue “Exception throwing when refreshing the filter in data grid”, it is caused due to async refreshing. In your code you have used the Task.Run() method to execute the async timeline to refresh the filter, but it doesn’t wait until for the provided time. It will execute the below code and will in run separate Thread. So, after the thread end it will continue the below implemented code again and its cause the “Null Exception”.    
   
So, you must make a thread to wait until it completes the provide timeline and it avoid the lopping of below code twice in async.    
   
Please refer the below code snippet.  
  
   
[MainPage.Xaml.cs]   
private void PlaylistComboBox_OnSelectedIndexChanged(object sender, EventArgs e)   
{   
    MigrateSonglist(Context.Songs);   
    Task.Run(async () => await Task.Delay(2500)).Wait(); // ß- “Wait” method will helps to wait until the thread complete its task and based on the result it will execute the below code. So it will avoid the looping of below code twice   
    RefreshSelection();   
    RefreshFilter();   
}   
   
 
  
 
Please let us know, if you require further assistance from us.   
   
Regards,
Balasubramani Sundaram 
 



HG Halil Göcer September 20, 2019 12:44 PM UTC

Hello Balasubramani,

this may fix the problem on my sample demo. But it will also decrease the performance and responsiveness in a production app.
In my production app I'm getting crashes because of this NullReferenceException on various places and I don't think that you can fix these with simply waiting for a task. Something in your library goes wrong and it needs fixing. A library should never crash with a NullReferenceException.

Here are more stack traces that are related to this problem from my production app:

#1 Stack trace: System.NullReferenceException: Object reference not set to an instance of an object
  • TraversalHelper.GetPrevious (Syncfusion.Data.NodeEntry entry)
  • GroupDisplayElements.GetItemAt (System.Int32 index)
  • GroupDisplayElements.get_Item (System.Int32 index)
  • RowGenerator.UpdateDataRow (System.Collections.Generic.IEnumerable`1[T] rows, System.Int32 rowIndex, Syncfusion.SfDataGrid.XForms.RowRegion region)
  • RowGenerator.UpdateRow (System.Collections.Generic.IEnumerable`1[T] rows, System.Int32 rowIndex, Syncfusion.SfDataGrid.XForms.RowRegion region)
  • RowGenerator.EnsureRows (Syncfusion.GridCommon.ScrollAxis.VisibleLinesCollection visibleRows, Syncfusion.GridCommon.ScrollAxis.VisibleLinesCollection visibleColumns)
  • VisualContainer.EnsureItems (System.Boolean needToRefresh)
  • VisualContainer.OnSizeAllocated (System.Double width, System.Double height)
  • VisualElement.SizeAllocated (System.Double width, System.Double height)

  • VisualContainer.ExtendedScrollView_Scrolled (System.Object sender, Xamarin.Forms.ScrolledEventArgs e)
  • ExtScrollViewer.SetScrolledPosition (System.Double horizontalPosition, System.Double verticalPosition)
  • ScrollViewer.updateScrollPosition (System.Double x, System.Double y)
  • ScrollViewer.OnScrollChanged (System.Int32 l, System.Int32 t, System.Int32 oldl, System.Int32 oldt)
  • View.n_OnScrollChanged_IIII (System.IntPtr jnienv, System.IntPtr native__this, System.Int32 l, System.Int32 t, System.Int32 oldl, System.Int32 oldt)


  • #2 Stack trace: System.NullReferenceException: Object reference not set to an instance of an object
    • TraversalHelper.GetPrevious (Syncfusion.Data.NodeEntry entry)
    • GroupDisplayElements.GetItemAt (System.Int32 index)
    • GroupDisplayElements.get_Item (System.Int32 index)
    • RowGenerator.UpdateDataRow (System.Collections.Generic.IEnumerable`1[T] rows, System.Int32 rowIndex, Syncfusion.SfDataGrid.XForms.RowRegion region)
    • RowGenerator.UpdateRow (System.Collections.Generic.IEnumerable`1[T] rows, System.Int32 rowIndex, Syncfusion.SfDataGrid.XForms.RowRegion region)
    • RowGenerator.EnsureRows (Syncfusion.GridCommon.ScrollAxis.VisibleLinesCollection visibleRows, Syncfusion.GridCommon.ScrollAxis.VisibleLinesCollection visibleColumns)
    • VisualContainer.EnsureItems (System.Boolean needToRefresh)
    • VisualContainer.OnSizeAllocated (System.Double width, System.Double height)
    • VisualElement.SizeAllocated (System.Double width, System.Double height)

    • GridColumnSizer.OnColumnPropertyChanged (Syncfusion.SfDataGrid.XForms.GridColumn column, System.String propertyName)
    • GridColumn.OnIsHiddenChanged (Xamarin.Forms.BindableObject bindable, System.Object oldValue, System.Object newValue)
    • 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)

    • GridColumn.set_IsHidden (System.Boolean value)
    • MainView.RefreshLayout ()
    • MainView.ProcessSearch ()
    • MainView.SearchTextBox_TextChanged (System.Object sender, Xamarin.Forms.TextChangedEventArgs e)
    • AsyncMethodBuilderCore+<>c.<ThrowAsync>b__7_0 (System.Object state)

    • #3 Stack trace: System.NullReferenceException: Object reference not set to an instance of an object
      • TraversalHelper.GetPrevious (Syncfusion.Data.NodeEntry entry)
      • GroupDisplayElements.GetItemAt (System.Int32 index)
      • GroupDisplayElements.get_Item (System.Int32 index)
      • RowGenerator.UpdateDataRow (System.Collections.Generic.IEnumerable`1[T] rows, System.Int32 rowIndex, Syncfusion.SfDataGrid.XForms.RowRegion region)
      • RowGenerator.UpdateRow (System.Collections.Generic.IEnumerable`1[T] rows, System.Int32 rowIndex, Syncfusion.SfDataGrid.XForms.RowRegion region)
      • RowGenerator.EnsureRows (Syncfusion.GridCommon.ScrollAxis.VisibleLinesCollection visibleRows, Syncfusion.GridCommon.ScrollAxis.VisibleLinesCollection visibleColumns)
      • VisualContainer.EnsureItems (System.Boolean needToRefresh)
      • VisualContainer.OnSizeAllocated (System.Double width, System.Double height)
      • VisualElement.SizeAllocated (System.Double width, System.Double height)

      • GridColumnSizer.OnColumnPropertyChanged (Syncfusion.SfDataGrid.XForms.GridColumn column, System.String propertyName)
      • GridColumn.OnIsHiddenChanged (Xamarin.Forms.BindableObject bindable, System.Object oldValue, System.Object newValue)
      • 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)

      • GridColumn.set_IsHidden (System.Boolean value)
      • MainView.RefreshLayout ()
      • MainView.PlaylistComboBox_OnSelectedIndexChanged (System.Object sender, System.EventArgs e)
      • AsyncMethodBuilderCore+<>c.<ThrowAsync>b__7_0 (System.Object state)



BS Balasubramani Sundaram Syncfusion Team September 23, 2019 06:13 PM UTC

Hi Halil,  
 
Thanks for the update.    
 
We have created incident under your DT account to follow up with the query. Please log into your Direct trac account for more updates. Please use the below link to login. 
 
 
Regards,
Balasubramani Sundaram.
 


Loader.
Up arrow icon