简体   繁体   中英

Xamarin.IOS Forms LabelRenderer.UpdateText throws NullReferenceException

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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM