Reputation: 178
I am using Xamarin.Forms v2.4.0.38779 and I am facing Null Pointer exception which crashes the application. I had same issue with 2.4.0.18342
System.NullReferenceException: Object reference not set to an instance of an object
I guess, Issue occcured while I have ListView with few rows and I am adding new rows, deleting existing rows and also updating values of row based on values, I get from background thread.
As data comes too frequently, around 100 updates in matter of seconds, It crashes.
FYI, I have ObservationCollection binded to ItemSource of ListView. So I dont manage addition, removal and update myself.
Here is stackttrace:
LabelRenderer.UpdateText ()
LabelRenderer.OnElementPropertyChanged (System.Object sender,System.ComponentModel.PropertyChangedEventArgs e)
(wrapper delegate-invoke) :invoke_void_object_PropertyChangedEventArgs object,System.ComponentModel.PropertyChangedEventArgs)
BindableObject.OnPropertyChanged (System.String propertyName)
Element.OnPropertyChanged (System.String propertyName)
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)
BindableObject.SetValueCore (Xamarin.Forms.BindableProperty property, System.Object value, Xamarin.Forms.Internals.SetValueFlags attributes,
Xamarin.Forms.BindableObject+SetValuePrivateFlags privateAttributes)
BindingExpression.ApplyCore (System.Object sourceObject, Xamarin.Forms.BindableObject target, Xamarin.Forms.BindableProperty property, System.Boolean fromTarget)
BindingExpression.Apply (System.Boolean fromTarget)
BindingExpression+BindingExpressionPart.<PropertyChanged>b__47_0 ()
NSAsyncActionDispatcher.Apply ()
(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)
Does anyone has idea on how to resolve this?
FYI, This is not about how to resolve NullPointerException, as Xamarin.Forms code is not own by me. I am using that as third party module.
Upvotes: 0
Views: 267
Reputation: 11
Changing the CachingStrategy on the listview also seems to be a workaround. Based on https://bugzilla.xamarin.com/show_bug.cgi?id=59813.
For me it was fixed changing CachingStrategy to RecycleElement, but from the link above it has also been reported that changing to RetainElement can be a fix.
Upvotes: 0
Reputation: 178
https://bugzilla.xamarin.com/show_bug.cgi?id=59813
https://github.com/xamarin/Xamarin.Forms/pull/1226
Setting HasUnevenRows to false and setting RowHeight manually worked for me.
Upvotes: 1