Hi,
I came across a situation while using SFlistview.On pressing backbutton while a page with sflistview loads(an api call happening), the app crashes. It shows some sort of null reference exception. The stacktrace is given.This issue is absent while using a normal listview.
08-16 14:32:02.132 I/MonoDroid( 4161): UNHANDLED EXCEPTION:08-16 14:32:02.143 I/MonoDroid( 4161): System.NullReferenceException: Object reference not set to an instance of an object.08-16 14:32:02.143 I/MonoDroid( 4161): at Syncfusion.ListView.XForms.Android.MeasureSize.Convert (Xamarin.Forms.View view, Xamarin.Forms.VisualElement valid) [0x0002d] in <db97687ea11d48428e621981a1455cc9>:008-16 14:32:02.143 I/MonoDroid( 4161): at Syncfusion.ListView.XForms.Android.MeasureSize.CalculateSize (Syncfusion.ListView.XForms.SfListView listview, Xamarin.Forms.View content, Xamarin.Forms.Size viewSize) [0x0000a] in <db97687ea11d48428e621981a1455cc9>:008-16 14:32:02.143 I/MonoDroid( 4161): at Syncfusion.ListView.XForms.LayoutBase.GetAutoFitItemSize (Syncfusion.ListView.XForms.ListViewItemInfoBase itemInfo, System.Double& itemSize, System.Double itemSpacing, System.Int32 spanCount) [0x000a1] in <3d88d4c273d540778a5d17522ab6cd46>:008-16 14:32:02.143 I/MonoDroid( 4161): at Syncfusion.ListView.XForms.LinearLayout.GetAutoFitItemSize (Syncfusion.ListView.XForms.ListViewItemInfoBase itemInfo, System.Double& itemSize, System.Double itemSpacing) [0x00000] in <3d88d4c273d540778a5d17522ab6cd46>:008-16 14:32:02.143 I/MonoDroid( 4161): at Syncfusion.ListView.XForms.LinearLayout.SetRowHeight (Syncfusion.ListView.XForms.ListViewItemInfo itemInfo, System.Int32 index, System.Double& size, System.Double itemSpacing) [0x00011] in <3d88d4c273d540778a5d17522ab6cd46>:008-16 14:32:02.143 I/MonoDroid( 4161): at Syncfusion.ListView.XForms.LinearLayout.SetRowHeight (Syncfusion.ListView.XForms.ListViewItemInfo itemInfo, System.Double itemSpacing) [0x0008e] in <3d88d4c273d540778a5d17522ab6cd46>:008-16 14:32:02.143 I/MonoDroid( 4161): at Syncfusion.ListView.XForms.LinearLayout.EnsureItems (Syncfusion.GridCommon.ScrollAxis.VisibleLinesCollection visibleLines) [0x002ab] in <3d88d4c273d540778a5d17522ab6cd46>:008-16 14:32:02.143 I/MonoDroid( 4161): at Syncfusion.ListView.XForms.VisualContainer.EnsureItems () [0x0002b] in <3d88d4c273d540778a5d17522ab6cd46>:008-16 14:32:02.143 I/MonoDroid( 4161): at Syncfusion.ListView.XForms.VisualContainer.OnSizeAllocated (System.Double width, System.Double height) [0x0003f] in <3d88d4c273d540778a5d17522ab6cd46>:008-16 14:32:02.143 I/MonoDroid( 4161): at Xamarin.Forms.VisualElement.SizeAllocated (System.Double width, System.Double height) [0x00000] in C:\BuildAgent2\work\ca3766cfc22354a1\Xamarin.Forms.Core\VisualElement.cs:62908-16 14:32:02.143 I/MonoDroid( 4161): at Xamarin.Forms.Layout.ForceLayout () [0x00000] in C:\BuildAgent2\work\ca3766cfc22354a1\Xamarin.Forms.Core\Layout.cs:10408-16 14:32:02.143 I/MonoDroid( 4161): at Syncfusion.ListView.XForms.SfListView.RefreshView () [0x00036] in <3d88d4c273d540778a5d17522ab6cd46>:008-16 14:32:02.143 I/MonoDroid( 4161): at Syncfusion.ListView.XForms.SfListView.OnItemsSourceChanged (Xamarin.Forms.BindableObject bindable, System.Object oldValue, System.Object newValue) [0x00052] in <3d88d4c273d540778a5d17522ab6cd46>:008-16 14:32:02.143 I/MonoDroid( 4161): at Xamarin.Forms.BindableObject.SetValueActual (Xamarin.Forms.BindableProperty property, Xamarin.Forms.BindableObject+BindablePropertyContext context, System.Object value, System.Boolean currentlyApplying, Xamarin.Forms.BindableObject+SetValueFlags attributes, System.Boolean silent) [0x00108] in C:\BuildAgent2\work\ca3766cfc22354a1\Xamarin.Forms.Core\BindableObject.cs:58408-16 14:32:02.143 I/MonoDroid( 4161): at Xamarin.Forms.BindableObject.SetValueCore (Xamarin.Forms.BindableProperty property, System.Object value, Xamarin.Forms.BindableObject+SetValueFlags attributes, Xamarin.Forms.BindableObject+SetValuePrivateFlags privateAttributes) [0x0014b] in C:\BuildAgent2\work\ca3766cfc22354a1\Xamarin.Forms.Core\BindableObject.cs:37808-16 14:32:02.143 I/MonoDroid( 4161): at Xamarin.Forms.BindingExpression.ApplyCore (System.Object sourceObject, Xamarin.Forms.BindableObject target, Xamarin.Forms.BindableProperty property, System.Boolean fromTarget) [0x001f9] in C:\BuildAgent2\work\ca3766cfc22354a1\Xamarin.Forms.Core\BindingExpression.cs:17308-16 14:32:02.143 I/MonoDroid( 4161): at Xamarin.Forms.BindingExpression.Apply (System.Boolean fromTarget) [0x0003e] in C:\BuildAgent2\work\ca3766cfc22354a1\Xamarin.Forms.Core\BindingExpression.cs:5508-16 14:32:02.143 I/MonoDroid( 4161): at Xamarin.Forms.BindingExpression+BindingExpressionPart.<PropertyChanged>b__47_0 () [0x00000] in C:\BuildAgent2\work\ca3766cfc22354a1\Xamarin.Forms.Core\BindingExpression.cs:54208-16 14:32:02.143 I/MonoDroid( 4161): at Java.Lang.Thread+RunnableImplementor.Run () [0x00008] in <9ab9faae1b4b4f0da28e7c4ac61e2c78>:008-16 14:32:02.143 I/MonoDroid( 4161): at Java.Lang.IRunnableInvoker.n_Run (System.IntPtr jnienv, System.IntPtr native__this) [0x00008] in <9ab9faae1b4b4f0da28e7c4ac61e2c78>:008-16 14:32:02.143 I/MonoDroid( 4161): at (wrapper dynamic-method) System.Object:1bd37b26-35f0-4ef1-8c59-fa3db8eb56af (intptr,intptr)08-16 14:32:02.153 W/art ( 4161): JNI RegisterNativeMethods: attempt to register 0 native methods for android.runtime.JavaProxyThrowable08-16 14:32:02.154 D/Mono ( 4161): DllImport searching in: '__Internal' ('(null)').08-16 14:32:02.154 D/Mono ( 4161): Searching for 'java_interop_jnienv_throw'.08-16 14:32:02.154 D/Mono ( 4161): Probing 'java_interop_jnienv_throw'.08-16 14:32:02.154 D/Mono ( 4161): Found as 'java_interop_jnienv_throw'.InspectorDebugSession(5): HandleTargetEvent: UnhandledExceptionAn unhandled exception occured.InspectorDebugSession(5): HandleTargetEvent: TargetHitBreakpoint08-16 14:32:05.243 I/art ( 4161): Thread[2,tid=4166,WaitingInMainSignalCatcherLoop,Thread*=0xaee42000,peer=0x22c070a0,"Signal Catcher"]: reacting to signal 308-16 14:32:05.411 I/art ( 4161): Wrote stack traces to '/data/anr/traces.txt'InspectorDebugSession(5): Disposed08-16 14:32:09.583 E/mono-rt ( 4161): [ERROR] FATAL UNHANDLED EXCEPTION: System.NullReferenceException: Object reference not set to an instance of an object.referenceTable GDEF length=814 1
Hi Samir,
Were you able to get around this issue? We are seeing the same exact issues, if we have a command that updates the listview, and we navigate way before it finishes loading, we get this crash.
In order to get around this, I had to do some pretty convoluted stuff, where I am creating a CancellationTokenSource for each command that executes and adding to a list. When the command finishes, I remove it from the list and dispose it but if the command doesn't finish before the page disappears I go through the current list and cancel all current commands. This seemed to workaround the issue for us.
-Jeff
This is exactly the same issue I reported other day https://www.syncfusion.com/forums/133192/autofitmode-quotheightquot-crash-on-back-button-pressed-when-sflistview-is-dispossed
We cant find a workaround with this, Solution must be provided by syncfusion. It is an obvious bug. Only thing you can do prevent your app to be crashing, Just put a try catch around your InitializeComponent of your view. Please provide a fix with this issue. It is very obvious crash and you should be able to reproduce it easily.
try
{
InitializeComponent();
}
catch (Exception ex)
{
Hi Emil,We have provided the custom assemblies for the reported issue in the support incident created under your account. Can you please log on to our support website to check for further updates.Regards,G.Muthu Kumaran.
Is it possible for me to try these new assemblies? I'm experiencing the exact same problem.
Hi,
Assemblies doesnt work. I already reported back but It is requested that I provide a reproduction sample but I dont have time for it. If you have a reproduction sample, please provide. Currently, I handled this issue myself with a workaround with some boolean control.
thanks,
Emil
It only occurs on iOS after changing orientation from portrait to landscape. Will see if I can reproduce it with a sample application. Tomorrow I won't be in so will probably do it come Thursday.
No, it happens also for Android. Repro is very simple indeed as others also wrote above. when you navigate to page, SfListview is already immediately there as empty but you may have expensive getData function takes 10secs lets assume, so after 10 secs your obversableCollection is raised as itemsource. If User presses backbutton before 10secs, lets say 9secs, sfListview is disposed and ObservableCollection is raised right after that for a null SfListview which causes null exception. StackTrace is very clear about it.
In IOS or general Orientation change causes SfListView to be disposed I believe and if you are raising PropertyChanged on your sourceItem collection, you get same error. You can prevent it by checking with some condition and not raise propertychanged. Of course this is just a workaround. Syncfusion team should do a null check in their assembly.
Yep that sounds right.
Got a sample for you guys. Open attached solution and run the iOS project. Scroll down and up. When scrolling up the app will crash.
Hello,
I have used SfListview in xamarin projet ad I have te same error on UWP, but only if I lunch my app in release version. In IOS I haven' t any problem
This is may XAML
<syncfusion:SfListView
x:Name="tipoRiga"
ItemsSource="{Binding Results}"
SelectedItem="{Binding SelectedItem, Mode=TwoWay}"
ItemTemplate="{StaticResource TipoRigaTemplateSelector}"
Grid.Row="1"
AutoFitMode="DynamicHeight"
VerticalOptions="FillAndExpand"
SelectionMode="Single"
Loaded="tipoRiga_Loaded"
PropertyChanged="tipoRiga_PropertyChanged"
LoadMoreOption="AutoOnScroll"
LayoutManager="{Binding IlMioLayout}"
LoadMoreCommand="{Binding LoadMoreCommand}"
BackgroundColor="White">
</syncfusion:SfListView>
Can you sugget me a solution?
Hi Massimo Pasquali,
We have analyzed the reported query, we are able to replicate the issue at our end. We are in need of two more business days to validate the issue properly. We will update you with further details on or before January 8, 2024. We will appreciate your patience until then.
Regards,
Suthi Yuvaraj
Hi Massimo Pasquali,
The reported issue is a known issue in the UWP platform. The
problem can be resolved by initializing the SfListView assemblies in
App.xaml.cs in the UWP project. Please make the following changes in your
App.xaml.cs file:
protected override void
OnLaunched(LaunchActivatedEventArgs e) { …
rootFrame.NavigationFailed += OnNavigationFailed;
// you'll need to add `using System.Reflection;` List<Assembly> assembliesToInclude = new List<Assembly>();
//Now, add all the assemblies your app uses assembliesToInclude.Add(typeof(SfListViewRenderer).GetTypeInfo().Assembly);
// replaces Xamarin.Forms.Forms.Init(e); Xamarin.Forms.Forms.Init(e, assembliesToInclude);
… } |
For further details, please refer to the following guideline: https://help.syncfusion.com/xamarin/listview/getting-started#releasemode-issue-in-uwp-platform