You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
we got a crash on production that seems to be caused by Forms9Patch. Thanks to Eric Detoc from Microsoft we have a suspected code that could cause the exception.
The exception stack trace:
at Java.Interop.JniEnvironment+InstanceMethods.CallNonvirtualVoidMethod (Java.Interop.JniObjectReference instance, Java.Interop.JniObjectReference type, Java.Interop.JniMethodInfo method, Java.Interop.JniArgumentValue* args) [0x0008e] in <15a691eeeee8472c8cbc0ac12cda5b0e>:0
at Java.Interop.JniPeerMembers+JniInstanceMethods.InvokeVirtualVoidMethod (System.String encodedMember, Java.Interop.IJavaPeerable self, Java.Interop.JniArgumentValue* parameters) [0x00063] in <15a691eeeee8472c8cbc0ac12cda5b0e>:0
at Android.Views.ViewGroup.RemoveView (Android.Views.View view) [0x00031] in <62abc14cacb444a4b16dab697865a0d3>:0
at Xamarin.Forms.Platform.Android.ViewExtensions.RemoveFromParent (Android.Views.View view) [0x00013] in :0
at Xamarin.Forms.Platform.Android.VisualElementPackager.RemoveChild (Xamarin.Forms.VisualElement view) [0x0007a] in :0
at Xamarin.Forms.Platform.Android.VisualElementPackager.OnChildRemoved (System.Object sender, Xamarin.Forms.ElementEventArgs e) [0x00021] in :0
at Xamarin.Forms.Element.OnChildRemoved (Xamarin.Forms.Element child, System.Int32 oldLogicalIndex) [0x0001a] in :0
at Xamarin.Forms.VisualElement.OnChildRemoved (Xamarin.Forms.Element child, System.Int32 oldLogicalIndex) [0x00000] in :0
at Xamarin.Forms.TemplatedView.OnChildRemoved (Xamarin.Forms.Element child, System.Int32 oldLogicalIndex) [0x00000] in :0
at Xamarin.Forms.Layout.OnInternalRemoved (Xamarin.Forms.View view, System.Int32 oldIndex) [0x00012] in :0
at Xamarin.Forms.Layout.InternalChildrenOnCollectionChanged (System.Object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e) [0x00033] in :0
at System.Collections.ObjectModel.ObservableCollection1[T].OnCollectionChanged (System.Collections.Specialized.NotifyCollectionChangedEventArgs e) [0x00018] in :0
at System.Collections.ObjectModel.ObservableCollection1[T].OnCollectionChanged (System.Collections.Specialized.NotifyCollectionChangedAction action, System.Object item, System.Int32 index) [0x00009] in :0
at System.Collections.ObjectModel.ObservableCollection1[T].RemoveItem (System.Int32 index) [0x00021] in :0
at System.Collections.ObjectModel.Collection1[T].RemoveAt (System.Int32 index) [0x00027] in :0
at Xamarin.Forms.TemplateUtilities.OnControlTemplateChanged (Xamarin.Forms.BindableObject bindable, System.Object oldValue, System.Object newValue) [0x0009e] in :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) [0x0012a] in :0
at Xamarin.Forms.BindableObject.SetValueCore (Xamarin.Forms.BindableProperty property, System.Object value, Xamarin.Forms.Internals.SetValueFlags attributes, Xamarin.Forms.BindableObject+SetValuePrivateFlags privateAttributes) [0x00173] in :0
at Xamarin.Forms.BindableObject.SetValue (Xamarin.Forms.BindableProperty property, System.Object value, System.Boolean fromStyle, System.Boolean checkAccess) [0x0004d] in :0
at Xamarin.Forms.BindableObject.SetValue (Xamarin.Forms.BindableProperty property, System.Object value, System.Boolean fromStyle) [0x00000] in :0
at Xamarin.Forms.Setter.Apply (Xamarin.Forms.BindableObject target, System.Boolean fromStyle) [0x00107] in :0
at Xamarin.Forms.TriggerBase.OnConditionChanged (Xamarin.Forms.BindableObject bindable, System.Boolean oldValue, System.Boolean newValue) [0x00045] in :0
at Xamarin.Forms.BindingCondition.OnBoundPropertyChanged (Xamarin.Forms.BindableObject bindable, System.Object oldValue, System.Object newValue) [0x00023] in :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) [0x0012a] in :0
at Xamarin.Forms.BindableObject.SetValueCore (Xamarin.Forms.BindableProperty property, System.Object value, Xamarin.Forms.Internals.SetValueFlags attributes, Xamarin.Forms.BindableObject+SetValuePrivateFlags privateAttributes) [0x00173] in :0
at Xamarin.Forms.BindingExpression.ApplyCore (System.Object sourceObject, Xamarin.Forms.BindableObject target, Xamarin.Forms.BindableProperty property, System.Boolean fromTarget) [0x00226] in :0
at Xamarin.Forms.BindingExpression.Apply (System.Boolean fromTarget) [0x0003e] in :0
at Xamarin.Forms.BindingExpression+BindingExpressionPart.b__49_0 () [0x00000] in :0
at Xamarin.Forms.BindingExpression+BindingExpressionPart.PropertyChanged (System.Object sender, System.ComponentModel.PropertyChangedEventArgs args) [0x000cb] in :0
at Xamarin.Forms.BindingExpression+WeakPropertyChangedProxy.OnPropertyChanged (System.Object sender, System.ComponentModel.PropertyChangedEventArgs e) [0x00012] in :0
at (wrapper delegate-invoke) .invoke_void_object_PropertyChangedEventArgs(object,System.ComponentModel.PropertyChangedEventArgs)
at Xamarin.Forms.BindableObject.OnPropertyChanged (System.String propertyName) [0x00012] in :0
at Infra.Core.Base.ExtendedBindableObject.SetProperty[T] (T& storage, T value, System.String propertyName) [0x00021] in <557f3f9cdf9d466c993892030ae5baa8>:0
at PetActivityMobile.Core.ViewModels.Households.HouseholdEditViewModel.set_EditMode (System.Boolean value) [0x00000] in :0
at PetActivityMobile.Core.ViewModels.Households.HouseholdEditViewModel.OnSwitchEditModeCommand () [0x00302] in :0
at Infra.Core.Utils.AsyncCommand1[T].ExecuteAsync (System.Object parameter) [0x0009c] in <557f3f9cdf9d466c993892030ae5baa8>:0
12:17:55 NATIVE BLE
BleHelper.cs(397) - LogNativeSdk: #Error, Logger: [SDK local time: 25-10-22 12:17:55.577] android.runtime.JavaProxyThrowable: System.NullReferenceException: Object reference not set to an instance of an object
at FormsGestures.Droid.NativeGestureHandler.InstanceForElement (Xamarin.Forms.Element element) [0x00000] in <215471b6eead483997a97a3e2196198b>:0
at FormsGestures.Droid.NativeGestureListener.CallOnUp (Android.Views.MotionEvent ev) [0x0005f] in <215471b6eead483997a97a3e2196198b>:0
at FormsGestures.Droid.NativeGestureListener.Cancel (Android.Views.MotionEvent e) [0x00006] in <215471b6eead483997a97a3e2196198b>:0
at FormsGestures.Droid.NativeGestureDetector.OnTouchEvent (Android.Views.MotionEvent e) [0x001dc] in <215471b6eead483997a97a3e2196198b>:0
at FormsGestures.Droid.OnTouchListener.OnTouch (Android.Views.View v, Android.Views.MotionEvent e) [0x00053] in <215471b6eead483997a97a3e2196198b>:0
at Android.Views.View+IOnTouchListenerInvoker.n_OnTouch_Landroid_view_View_Landroid_view_MotionEvent_ (System.IntPtr jnienv, System.IntPtr native__this, System.IntPtr native_v, System.IntPtr native_e) [0x00017] in <62abc14cacb444a4b16dab697865a0d3>:0
at Android.Runtime.JNINativeWrapper.Wrap_JniMarshal_PPLL_Z (_JniMarshal_PPLL_Z callback, System.IntPtr jnienv, System.IntPtr klazz, System.IntPtr p0, System.IntPtr p1) [0x00005] in <62abc14cacb444a4b16dab697865a0d3>:0
--- End of stack trace from previous location where exception was thrown ---
in this stack, the app is processing a touch event which ends up in a System.NullReferenceException, see above, thrown from FormsGestures.Droid.NativeGestureHandler.InstanceForElement
there is a touch listener registered from FormsGestures.Droid.* .
This namespace FormsGestures.Droid.* is not part of Xamarin.Forms. it is part of the Forms9Patch library ( Forms9Patch/FormsGestures/FormsGestures.Droid at master · baskren/Forms9Patch (github.com) )
the code of CallOnUp is up here :
bool CallOnUp(MotionEvent ev)
{
var handled = false;
var handler = NativeGestureHandler.InstanceForElement(Element);
while (handler != null)
...
internal static NativeGestureHandler InstanceForElement(Xamarin.Forms.Element element)
{
var result = (NativeGestureHandler)element.GetValue(GestureHandlerProperty);
return result;
}
in InstanceForElement, the code doesn't check if element is null prior to the call to GetValue
so if element is null for some reason, calling GetValue will of course cause the NullRefException.
in the above stack trace, we can see that an element is removed from an observableCollection so it is also removed from the view.
Perhaps the crash for NativeGestureHandler.InstanceForElement(Element) occurred for that particular element?
Basic Information
Version with issue: 2.4.9
IDE: Microsoft Visual Studio Professional 2022
Platform Target Frameworks:
Android: targetSdkVersion="31"
The text was updated successfully, but these errors were encountered:
Description
Hi,
we got a crash on production that seems to be caused by Forms9Patch. Thanks to Eric Detoc from Microsoft we have a suspected code that could cause the exception.
The exception stack trace:
at Java.Interop.JniEnvironment+InstanceMethods.CallNonvirtualVoidMethod (Java.Interop.JniObjectReference instance, Java.Interop.JniObjectReference type, Java.Interop.JniMethodInfo method, Java.Interop.JniArgumentValue* args) [0x0008e] in <15a691eeeee8472c8cbc0ac12cda5b0e>:0
at Java.Interop.JniPeerMembers+JniInstanceMethods.InvokeVirtualVoidMethod (System.String encodedMember, Java.Interop.IJavaPeerable self, Java.Interop.JniArgumentValue* parameters) [0x00063] in <15a691eeeee8472c8cbc0ac12cda5b0e>:0
at Android.Views.ViewGroup.RemoveView (Android.Views.View view) [0x00031] in <62abc14cacb444a4b16dab697865a0d3>:0
at Xamarin.Forms.Platform.Android.ViewExtensions.RemoveFromParent (Android.Views.View view) [0x00013] in :0
at Xamarin.Forms.Platform.Android.VisualElementPackager.RemoveChild (Xamarin.Forms.VisualElement view) [0x0007a] in :0
at Xamarin.Forms.Platform.Android.VisualElementPackager.OnChildRemoved (System.Object sender, Xamarin.Forms.ElementEventArgs e) [0x00021] in :0
at Xamarin.Forms.Element.OnChildRemoved (Xamarin.Forms.Element child, System.Int32 oldLogicalIndex) [0x0001a] in :0
at Xamarin.Forms.VisualElement.OnChildRemoved (Xamarin.Forms.Element child, System.Int32 oldLogicalIndex) [0x00000] in :0
at Xamarin.Forms.TemplatedView.OnChildRemoved (Xamarin.Forms.Element child, System.Int32 oldLogicalIndex) [0x00000] in :0
at Xamarin.Forms.Layout.OnInternalRemoved (Xamarin.Forms.View view, System.Int32 oldIndex) [0x00012] in :0
at Xamarin.Forms.Layout.InternalChildrenOnCollectionChanged (System.Object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e) [0x00033] in :0
at System.Collections.ObjectModel.ObservableCollection1[T].OnCollectionChanged (System.Collections.Specialized.NotifyCollectionChangedEventArgs e) [0x00018] in :0
at System.Collections.ObjectModel.ObservableCollection1[T].OnCollectionChanged (System.Collections.Specialized.NotifyCollectionChangedAction action, System.Object item, System.Int32 index) [0x00009] in :0
at System.Collections.ObjectModel.ObservableCollection1[T].RemoveItem (System.Int32 index) [0x00021] in :0
at System.Collections.ObjectModel.Collection1[T].RemoveAt (System.Int32 index) [0x00027] in :0
at Xamarin.Forms.TemplateUtilities.OnControlTemplateChanged (Xamarin.Forms.BindableObject bindable, System.Object oldValue, System.Object newValue) [0x0009e] in :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) [0x0012a] in :0
at Xamarin.Forms.BindableObject.SetValueCore (Xamarin.Forms.BindableProperty property, System.Object value, Xamarin.Forms.Internals.SetValueFlags attributes, Xamarin.Forms.BindableObject+SetValuePrivateFlags privateAttributes) [0x00173] in :0
at Xamarin.Forms.BindableObject.SetValue (Xamarin.Forms.BindableProperty property, System.Object value, System.Boolean fromStyle, System.Boolean checkAccess) [0x0004d] in :0
at Xamarin.Forms.BindableObject.SetValue (Xamarin.Forms.BindableProperty property, System.Object value, System.Boolean fromStyle) [0x00000] in :0
at Xamarin.Forms.Setter.Apply (Xamarin.Forms.BindableObject target, System.Boolean fromStyle) [0x00107] in :0
at Xamarin.Forms.TriggerBase.OnConditionChanged (Xamarin.Forms.BindableObject bindable, System.Boolean oldValue, System.Boolean newValue) [0x00045] in :0
at Xamarin.Forms.BindingCondition.OnBoundPropertyChanged (Xamarin.Forms.BindableObject bindable, System.Object oldValue, System.Object newValue) [0x00023] in :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) [0x0012a] in :0
at Xamarin.Forms.BindableObject.SetValueCore (Xamarin.Forms.BindableProperty property, System.Object value, Xamarin.Forms.Internals.SetValueFlags attributes, Xamarin.Forms.BindableObject+SetValuePrivateFlags privateAttributes) [0x00173] in :0
at Xamarin.Forms.BindingExpression.ApplyCore (System.Object sourceObject, Xamarin.Forms.BindableObject target, Xamarin.Forms.BindableProperty property, System.Boolean fromTarget) [0x00226] in :0
at Xamarin.Forms.BindingExpression.Apply (System.Boolean fromTarget) [0x0003e] in :0
at Xamarin.Forms.BindingExpression+BindingExpressionPart.b__49_0 () [0x00000] in :0
at Xamarin.Forms.BindingExpression+BindingExpressionPart.PropertyChanged (System.Object sender, System.ComponentModel.PropertyChangedEventArgs args) [0x000cb] in :0
at Xamarin.Forms.BindingExpression+WeakPropertyChangedProxy.OnPropertyChanged (System.Object sender, System.ComponentModel.PropertyChangedEventArgs e) [0x00012] in :0
at (wrapper delegate-invoke) .invoke_void_object_PropertyChangedEventArgs(object,System.ComponentModel.PropertyChangedEventArgs)
at Xamarin.Forms.BindableObject.OnPropertyChanged (System.String propertyName) [0x00012] in :0
at Infra.Core.Base.ExtendedBindableObject.SetProperty[T] (T& storage, T value, System.String propertyName) [0x00021] in <557f3f9cdf9d466c993892030ae5baa8>:0
at PetActivityMobile.Core.ViewModels.Households.HouseholdEditViewModel.set_EditMode (System.Boolean value) [0x00000] in :0
at PetActivityMobile.Core.ViewModels.Households.HouseholdEditViewModel.OnSwitchEditModeCommand () [0x00302] in :0
at Infra.Core.Utils.AsyncCommand1[T].ExecuteAsync (System.Object parameter) [0x0009c] in <557f3f9cdf9d466c993892030ae5baa8>:0
12:17:55
NATIVE BLE
BleHelper.cs(397) - LogNativeSdk: #Error, Logger: [SDK local time: 25-10-22 12:17:55.577] android.runtime.JavaProxyThrowable: System.NullReferenceException: Object reference not set to an instance of an object
at FormsGestures.Droid.NativeGestureHandler.InstanceForElement (Xamarin.Forms.Element element) [0x00000] in <215471b6eead483997a97a3e2196198b>:0
at FormsGestures.Droid.NativeGestureListener.CallOnUp (Android.Views.MotionEvent ev) [0x0005f] in <215471b6eead483997a97a3e2196198b>:0
at FormsGestures.Droid.NativeGestureListener.Cancel (Android.Views.MotionEvent e) [0x00006] in <215471b6eead483997a97a3e2196198b>:0
at FormsGestures.Droid.NativeGestureDetector.OnTouchEvent (Android.Views.MotionEvent e) [0x001dc] in <215471b6eead483997a97a3e2196198b>:0
at FormsGestures.Droid.OnTouchListener.OnTouch (Android.Views.View v, Android.Views.MotionEvent e) [0x00053] in <215471b6eead483997a97a3e2196198b>:0
at Android.Views.View+IOnTouchListenerInvoker.n_OnTouch_Landroid_view_View_Landroid_view_MotionEvent_ (System.IntPtr jnienv, System.IntPtr native__this, System.IntPtr native_v, System.IntPtr native_e) [0x00017] in <62abc14cacb444a4b16dab697865a0d3>:0
at Android.Runtime.JNINativeWrapper.Wrap_JniMarshal_PPLL_Z (_JniMarshal_PPLL_Z callback, System.IntPtr jnienv, System.IntPtr klazz, System.IntPtr p0, System.IntPtr p1) [0x00005] in <62abc14cacb444a4b16dab697865a0d3>:0
--- End of stack trace from previous location where exception was thrown ---
in this stack, the app is processing a touch event which ends up in a System.NullReferenceException, see above, thrown from FormsGestures.Droid.NativeGestureHandler.InstanceForElement
there is a touch listener registered from FormsGestures.Droid.* .
This namespace FormsGestures.Droid.* is not part of Xamarin.Forms. it is part of the Forms9Patch library ( Forms9Patch/FormsGestures/FormsGestures.Droid at master · baskren/Forms9Patch (github.com) )
the code of CallOnUp is up here :
https://github.com/baskren/Forms9Patch/blob/0ea7ec7a606462c9507ebf9abb59e2e849650050/FormsGestures/FormsGestures.Droid/Handlers/NativeGestureListener.cs#L422
bool CallOnUp(MotionEvent ev)
{
var handled = false;
var handler = NativeGestureHandler.InstanceForElement(Element);
while (handler != null)
...
internal static NativeGestureHandler InstanceForElement(Xamarin.Forms.Element element)
{
var result = (NativeGestureHandler)element.GetValue(GestureHandlerProperty);
return result;
}
in InstanceForElement, the code doesn't check if element is null prior to the call to GetValue
so if element is null for some reason, calling GetValue will of course cause the NullRefException.
in the above stack trace, we can see that an element is removed from an observableCollection so it is also removed from the view.
Perhaps the crash for NativeGestureHandler.InstanceForElement(Element) occurred for that particular element?
Basic Information
The text was updated successfully, but these errors were encountered: