SfListView crashes on Navigation page, when back then go forward again

 Hi,

We have 2 pages on Navigation Page. 
Page 1 has a button that goes to Page 2. on Page 2, i have SfListView that gets items from REST api on the backend. 

Going from Page 1 to Page 2 is fine, and it creates the nice looking list view with ItemTemplate we want. 
then go back to Page 1.
then go back to Page 2, it tries to add few more items to collection, which causes null exception.

We use ObserveableCollection of custom object as ItemSource
we set AutoFitMode to Auto.

Ive read on couple of other thread here that you guys concluding AutoFitMode is causing this exception, so I set the autofitmode to None, and sure enough, it does not throw exception.  However, I do need AutoFitMode to be auto, otherwise, why are we paying money for your controls, right? if that is not there, for our purpose, i could just use the out of box ListView. 

Please advice.
Thanks. 

this is stacktrace from where NullReferenceException occurs
  • MeasureSize.Convert (Xamarin.Forms.View view, Xamarin.Forms.VisualElement valid)
  • 2
    MeasureSize.CalculateSize (Syncfusion.ListView.XForms.SfListView listview, Xamarin.Forms.View content, Xamarin.Forms.Size viewSize)
  • 3
    LayoutBase.GetAutoFitItemSize (Syncfusion.ListView.XForms.ListViewItemInfoBase itemInfo, System.Double& itemSize, System.Double itemSpacing, System.Int32 spanCount)
  • 4
    LinearLayout.GetAutoFitItemSize (Syncfusion.ListView.XForms.ListViewItemInfoBase itemInfo, System.Double& itemSize, System.Double itemSpacing)
  • 5
    LinearLayout.SetRowHeight (Syncfusion.ListView.XForms.ListViewItemInfo itemInfo, System.Int32 index, System.Double& size, System.Double itemSpacing)
  • 6
    LinearLayout.SetRowHeight (Syncfusion.ListView.XForms.ListViewItemInfo itemInfo, System.Double itemSpacing)
  • 7
    LinearLayout.EnsureItems (Syncfusion.GridCommon.ScrollAxis.VisibleLinesCollection visibleLines)
  • 8
    VisualContainer.EnsureItems ()
  • 9
    VisualContainer.OnSizeAllocated (System.Double width, System.Double height)
  • 10
    VisualElement.SizeAllocated (System.Double width, System.Double heightC:\BuildAgent3\work\ca3766cfc22354a1\Xamarin.Forms.Core\VisualElement.cs:637
  • 11
    Layout.ForceLayout () C:\BuildAgent3\work\ca3766cfc22354a1\Xamarin.Forms.Core\Layout.cs:115
  • 12
    LinearLayout.OnItemsCollectionChanged (System.Collections.Specialized.NotifyCollectionChangedEventArgs e)
  • 13
    SfListView.DisplayItems_CollectionChanged (System.Object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e)
  • 14
    DisplayItems.RaiseCollectionChanged (System.Collections.Specialized.NotifyCollectionChangedEventArgs args)
  • 15
    DataSource.UpdateCollectionView (System.Object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e)
  • 16
    DataSource.OnSourceCollectionChanged (System.Object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e)
  • 17
    (wrapper delegate-invoke) :invoke_void_object_NotifyCollectionChangedEventArgs (object,System.Collections.Specialized.NotifyCollectionChangedEventArgs)
  • 18
    ObservableCollection`1[T].OnCollectionChanged (System.Collections.Specialized.NotifyCollectionChangedEventArgs e/Library/Frameworks/Xamarin.iOS.framework/Versions/11.2.1.0/src/mono/mcs/class/referencesource/System/compmod/system/collections/objectmodel/observablecollection.cs:288
  • 19
    ObservableCollection`1[T].OnCollectionChanged (System.Collections.Specialized.NotifyCollectionChangedAction action, System.Object item, System.Int32 index/Library/Frameworks/Xamarin.iOS.framework/Versions/11.2.1.0/src/mono/mcs/class/referencesource/System/compmod/system/collections/objectmodel/observablecollection.cs:351
  • 20
    ObservableCollection`1[T].InsertItem (System.Int32 index, T item/Library/Frameworks/Xamarin.iOS.framework/Versions/11.2.1.0/src/mono/mcs/class/referencesource/System/compmod/system/collections/objectmodel/observablecollection.cs:219
  • 21
    Collection`1[T].Add (T item/Library/Frameworks/Xamarin.iOS.framework/Versions/11.2.1.0/src/mono/mcs/class/referencesource/mscorlib/system/collections/objectmodel/collection.cs:67



6 Replies

MK Muthu Kumaran Gnanavinayagam Syncfusion Team November 9, 2017 11:08 AM UTC

Hi Yasufumi, 
 
Sorry for the inconvenience. 
 
We have resolved the reported issue and it will be included in our upcoming 2017 Volume 4 release which is scheduled to be rolled out by the mid of November. We appreciate your patience until then. 
 
Please let us know if you require further assistance. 
 
Regards, 
G.Muthu Kumaran. 



MK Muthu Kumaran Gnanavinayagam Syncfusion Team December 1, 2017 06:09 AM UTC

Hi Yasufumi,  
  
We are glad to announce that our Essential Studio Volume 4, 2017 (Version 15.4.0.17) is rolled out and is available for download under the following link.  
  
                               
The reported issue “NullReferenceException throws from Convert method ” has been included in this release. We thank you for your support and appreciate your patience in waiting for this release. Please get in touch with us if you would require any further assistance.  
  
Regards,  
G. Muthu Kumaran.


TR Temístocles Roa December 4, 2017 06:09 PM UTC

Hi,

I'm sorry to report that even with version 15.4.0.17 the exception is still thrown when using Autofitmode = "Height"

Now the stack trace is:

at Syncfusion.ListView.XForms.LayoutBase.GetAutoFitItemSize (Syncfusion.ListView.XForms.ListViewItemInfoBase itemInfo, System.Double& itemSize, System.Double itemSpacing, System.Int32 spanCount) [0x000c1] in <3db3fff058cc40c88bab504c4db2a7cf>:0 
  at Syncfusion.ListView.XForms.LinearLayout.GetAutoFitItemSize (Syncfusion.ListView.XForms.ListViewItemInfoBase itemInfo, System.Double& itemSize, System.Double itemSpacing) [0x00000] in <3db3fff058cc40c88bab504c4db2a7cf>:0 
  at Syncfusion.ListView.XForms.LinearLayout.SetRowHeight (Syncfusion.ListView.XForms.ListViewItemInfo itemInfo, System.Int32 index, System.Double& size, System.Double itemSpacing) [0x00011] in <3db3fff058cc40c88bab504c4db2a7cf>:0 
  at Syncfusion.ListView.XForms.LinearLayout.SetRowHeight (Syncfusion.ListView.XForms.ListViewItemInfo itemInfo, System.Double itemSpacing) [0x0008d] in <3db3fff058cc40c88bab504c4db2a7cf>:0 
  at Syncfusion.ListView.XForms.LinearLayout.EnsureItems (Syncfusion.GridCommon.ScrollAxis.VisibleLinesCollection visibleLines) [0x00391] in <3db3fff058cc40c88bab504c4db2a7cf>:0 
  at Syncfusion.ListView.XForms.VisualContainer.EnsureItems () [0x0002c] in <3db3fff058cc40c88bab504c4db2a7cf>:0 
  at Syncfusion.ListView.XForms.VisualContainer.OnSizeAllocated (System.Double width, System.Double height) [0x00046] in <3db3fff058cc40c88bab504c4db2a7cf>:0 
  at Xamarin.Forms.VisualElement.SizeAllocated (System.Double width, System.Double height) [0x00000] in D:\agent\_work\2\s\Xamarin.Forms.Core\VisualElement.cs:637 
  at Xamarin.Forms.Layout.ForceLayout () [0x00000] in D:\agent\_work\2\s\Xamarin.Forms.Core\Layout.cs:115 
  at Syncfusion.ListView.XForms.SfListView.RefreshView () [0x00035] in <3db3fff058cc40c88bab504c4db2a7cf>:0 
  at Syncfusion.ListView.XForms.SfListView.OnItemsSourceChanged (Xamarin.Forms.BindableObject bindable, System.Object oldValue, System.Object newValue) [0x00060] in <3db3fff058cc40c88bab504c4db2a7cf>:0 
  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) [0x0011b] in D:\agent\_work\2\s\Xamarin.Forms.Core\BindableObject.cs:597 
  at Xamarin.Forms.BindableObject.SetValueCore (Xamarin.Forms.BindableProperty property, System.Object value, Xamarin.Forms.Internals.SetValueFlags attributes, Xamarin.Forms.BindableObject+SetValuePrivateFlags privateAttributes) [0x0015b] in D:\agent\_work\2\s\Xamarin.Forms.Core\BindableObject.cs:391 
  at Xamarin.Forms.BindingExpression.ApplyCore (System.Object sourceObject, Xamarin.Forms.BindableObject target, Xamarin.Forms.BindableProperty property, System.Boolean fromTarget) [0x001f9] in D:\agent\_work\2\s\Xamarin.Forms.Core\BindingExpression.cs:174 
  at Xamarin.Forms.BindingExpression.Apply (System.Boolean fromTarget) [0x0003e] in D:\agent\_work\2\s\Xamarin.Forms.Core\BindingExpression.cs:56 
  at Xamarin.Forms.BindingExpression+BindingExpressionPart.<PropertyChanged>b__47_0 () [0x00000] in D:\agent\_work\2\s\Xamarin.Forms.Core\BindingExpression.cs:551 
  at Foundation.NSAsyncActionDispatcher.Apply () [0x00000] in /Users/builder/data/lanes/5520/51128b8c/source/xamarin-macios/src/Foundation/NSAction.cs:163 


MK Muthu Kumaran Gnanavinayagam Syncfusion Team December 5, 2017 12:29 PM UTC

Hi Temístocles,   
   
We have checked the reported query “NullReferenceException thrown GetAutoFitItemSize of SfListView” from our side. As per the stack trace, we suspect that the reported exception is thrown because of SfListView renderer not initialized in your renderer projects.    
You can refer the below documentation to know about initializing SfListView renderers in each platform.   
   
   
Please let us know if you require further assistance.   
   
Regards,   
G.Muthu Kumaran.  



UN Unknown July 17, 2018 01:53 PM UTC

I too see the same error when using AutoFitMode="Height" on the Android platform (iOS is working fine).

When setting SfListView AutoFitMode="Height" , on iOS  it all works OK.  On Android, the following exception occurs:

[MonoDroid] UNHANDLED EXCEPTION:
[MonoDroid] System.NullReferenceException: Object reference not set to an instance of an object.
[MonoDroid]   at Syncfusion.ListView.XForms.LayoutBase.GetAutoFitItemSize (Syncfusion.ListView.XForms.ListViewItemInfoBase itemInfo, System.Double& itemSize, System.Double itemSpacing, System.Int32 spanCount) [0x000c1] in :0 
[MonoDroid]   at Syncfusion.ListView.XForms.LinearLayout.GetAutoFitItemSize (Syncfusion.ListView.XForms.ListViewItemInfoBase itemInfo, System.Double& itemSize, System.Double itemSpacing) [0x00000] in :0 
[MonoDroid]   at Syncfusion.ListView.XForms.LinearLayout.SetRowHeight (Syncfusion.ListView.XForms.ListViewItemInfo itemInfo, System.Int32 index, System.Double& size, System.Double itemSpacing) [0x00011] in :0 
[MonoDroid]   at Syncfusion.ListView.XForms.LinearLayout.SetRowHeight (Syncfusion.ListView.XForms.ListViewItemInfo itemInfo, System.Double itemSpacing) [0x000b0] in :0 
[MonoDroid]   at Syncfusion.ListView.XForms.LinearLayout.EnsureItems (Syncfusion.GridCommon.ScrollAxis.VisibleLinesCollection visibleLines) [0x00303] in :0 
[MonoDroid]   at Syncfusion.ListView.XForms.VisualContainer.EnsureItems () [0x0002c] in :0 


VR Vigneshkumar Ramasamy Syncfusion Team July 18, 2018 10:02 AM UTC

Hi James,  
  
We suspect that the reported issue “Application gets crashed when SfListView is loaded in Android platform” may occur due to SfListView assemblies might not be referred properly or initialized in your renderer projects. So, could you please check whether all the assemblies needed for proper functioning of SfListView control has been added as reference in your application? You can refer the below documentation to know about the list of assemblies needed for SfListView control.       
       
      
Please let us know if you require further assistance.       
    
Regards,    
Vigneshkumar R 
 


Loader.
Up arrow icon