Bug 33507 - Android: "System.ArgumentException: 'jobject' must not be IntPtr.Zero" when setting Focus for Picker = True
Summary: Android: "System.ArgumentException: 'jobject' must not be IntPtr.Zero" when s...
Status: VERIFIED FIXED
Alias: None
Product: Forms
Classification: Xamarin
Component: Android ()
Version: 1.4.3
Hardware: PC Windows
: --- normal
Target Milestone: ---
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2015-08-31 10:29 UTC by Ahmad ELMadi
Modified: 2016-07-04 14:40 UTC (History)
8 users (show)

Tags: ac
Is this bug a regression?: ---
Last known good build:


Attachments
Project Showing the bug (346.20 KB, application/x-zip-compressed)
2015-08-31 10:31 UTC, Ahmad ELMadi
Details
Video to get the bug (28 bytes, text/plain)
2015-08-31 10:43 UTC, Ahmad ELMadi
Details
Revised project (240.79 KB, application/x-zip-compressed)
2016-05-23 22:03 UTC, Andrew Hall
Details
The project with the latest nuget packages (144.47 KB, application/zip)
2016-05-25 18:56 UTC, Ahmad ELMadi
Details


Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report on Developer Community or GitHub with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:
Status:
VERIFIED FIXED

Description Ahmad ELMadi 2015-08-31 10:29:44 UTC
I have an app that has master detail pages. One of the detail pages has two hidden pickers which are activated (set Focus to true) by tapping the labels . When navigating to the other detail page and navigating back to the page with the pickers; tapping on the label to show the picker box will crash the app crashes with the trace below.

Steps to generate the bug 
=========================
https://youtu.be/b1-3LngpNu4

Notes: 
1. I found this bug on Android , but not on iOS 
2. This bug appears on Xamarin.Forms 1.4.3 and later. However, earlier versions of Xamarin.Forms do not crash. 
3. By replacing the tap gestures with buttons , the app will crash 


Exception Trace 
===============

08-31 16:26:04.674 I/MonoDroid( 2285): UNHANDLED EXCEPTION:
08-31 16:26:04.675 I/MonoDroid( 2285): System.ArgumentException: 'jobject' must not be IntPtr.Zero.
08-31 16:26:04.675 I/MonoDroid( 2285): Parameter name: jobject
08-31 16:26:04.675 I/MonoDroid( 2285): at Android.Runtime.JNIEnv.CallObjectMethod (intptr,intptr) [0x00010] in /Users/builder/data/lanes/1978/f98871a9/source/monodroid/src/Mono.Android/src/Runtime/JNIEnv.g.cs:170
08-31 16:26:04.675 I/MonoDroid( 2285): at Xamarin.Forms.Platform.Android.PickerRenderer.OnClick () <IL 0x0001b, 0x000e7>
08-31 16:26:04.675 I/MonoDroid( 2285): at Xamarin.Forms.Platform.Android.PickerRenderer.OnFocusChangeRequested (object,Xamarin.Forms.VisualElement/FocusRequestArgs) <IL 0x00011, 0x0006f>
08-31 16:26:04.675 I/MonoDroid( 2285): at (wrapper delegate-invoke) System.EventHandler`1<Xamarin.Forms.VisualElement/FocusRequestArgs>.invoke_void_object_TEventArgs (object,Xamarin.Forms.VisualElement/FocusRequestArgs) <0x00063>
08-31 16:26:04.675 I/MonoDroid( 2285): at Xamarin.Forms.VisualElement.Focus () <IL 0x0002b, 0x000fe>
08-31 16:26:04.675 I/MonoDroid( 2285): at ActivityReplica.MasterDetails.ActivityPage.OnRoleClicked (object,System.EventArgs) [0x00038] in c:\Users\aelmadi\Documents\Visual Studio 2013\Projects\ActivityReplica\ActivityReplica\ActivityReplica\MasterDetails\DetailPages\ActivityPage.xaml.cs:25
08-31 16:26:04.675 I/MonoDroid( 2285): at Xamarin.Forms.TapGestureRecognizer.SendTapped (Xamarin.Forms.View) <IL 0x0003b, 0x0015c>
08-31 16:26:04.675 I/MonoDroid( 2285): at Xamarin.Forms.Platform.Android.VisualElementRenderer`1<Xamarin.Forms.View>.OnTap (int) <0x0013f>
08-31 16:26:04.675 I/MonoDroid( 2285): at Xamarin.Forms.Platform.Android.InnerGestureListener.Android.Views.GestureDetector.IOnGestureListener.OnSingleTapUp (Android.Views.MotionEvent) <IL 0x0002e, 0x000d0>
08-31 16:26:04.675 I/MonoDroid( 2285): at Android.Views.GestureDetector/IOnGestureListenerInvoker.n_OnSingleTapUp_Landroid_view_MotionEvent_ (intptr,intptr,intptr) [0x00011] in /Users/builder/data/lanes/1978/f98871a9/source/monodroid/src/Mono.Android/platforms/android-22/src/generated/Android.Views.GestureDetector.cs:515
08-31 16:26:04.675 I/MonoDroid( 2285): at (wrapper dynamic-method) object.8b10c0c1-923a-4386-90b4-e71770134be0 (intptr,intptr,intptr) <IL 0x00017, 0x0002b>
08-31 16:26:04.680 W/art     ( 2285): JNI RegisterNativeMethods: attempt to register 0 native methods for md52ce486a14f4bcd95899665e9d932190b.JavaProxyThrowable
08-31 16:26:04.685 I/MonoDroid( 2285): UNHANDLED EXCEPTION:
08-31 16:26:04.685 I/MonoDroid( 2285): System.ArgumentException: 'jobject' must not be IntPtr.Zero.
08-31 16:26:04.685 I/MonoDroid( 2285): Parameter name: jobject
08-31 16:26:04.685 I/MonoDroid( 2285): at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000b] in /Users/builder/data/lanes/1978/f98871a9/source/mono/mcs/class/corlib/System.Runtime.ExceptionServices/ExceptionDispatchInfo.cs:61
An unhandled exception occured.

08-31 16:26:04.685 I/MonoDroid( 2285): at Android.Runtime.JNIEnv.CallBooleanMethod (intptr,intptr,Android.Runtime.JValue*) [0x00064] in /Users/builder/data/lanes/1978/f98871a9/source/monodroid/src/Mono.Android/src/Runtime/JNIEnv.g.cs:236
08-31 16:26:04.685 I/MonoDroid( 2285): at Android.Views.GestureDetector.OnTouchEvent (Android.Views.MotionEvent) [0x0005a] in /Users/builder/data/lanes/1978/f98871a9/source/monodroid/src/Mono.Android/platforms/android-22/src/generated/Android.Views.GestureDetector.cs:1445
08-31 16:26:04.685 I/MonoDroid( 2285): at Xamarin.Forms.Platform.Android.VisualElementRenderer`1<Xamarin.Forms.View>.Android.Views.View.IOnTouchListener.OnTouch (Android.Views.View,Android.Views.MotionEvent) <0x00055>
08-31 16:26:04.685 I/MonoDroid( 2285): at Android.Views.View/IOnTouchListenerInvoker.n_OnTouch_Landroid_view_View_Landroid_view_MotionEvent_ (intptr,intptr,intptr,intptr) [0x00019] in /Users/builder/data/lanes/1978/f98871a9/source/monodroid/src/Mono.Android/platforms/android-22/src/generated/Android.Views.View.cs:3240
08-31 16:26:04.685 I/MonoDroid( 2285): at (wrapper dynamic-method) object.0f48f050-016a-4ec8-95fa-f7bc2ed7e2ae (intptr,intptr,intptr,intptr) <IL 0x0001d, 0x00037>
08-31 16:26:04.686 I/MonoDroid( 2285): UNHANDLED EXCEPTION:
08-31 16:26:04.686 I/MonoDroid( 2285): System.ArgumentException: 'jobject' must not be IntPtr.Zero.
08-31 16:26:04.686 I/MonoDroid( 2285): Parameter name: jobject
08-31 16:26:04.686 I/MonoDroid( 2285): at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000b] in /Users/builder/data/lanes/1978/f98871a9/source/mono/mcs/class/corlib/System.Runtime.ExceptionServices/ExceptionDispatchInfo.cs:61
08-31 16:26:04.686 I/MonoDroid( 2285): at Android.Runtime.JNIEnv.CallNonvirtualBooleanMethod (intptr,intptr,intptr,Android.Runtime.JValue*) [0x00085] in /Users/builder/data/lanes/1978/f98871a9/source/monodroid/src/Mono.Android/src/Runtime/JNIEnv.g.cs:662
08-31 16:26:04.686 I/MonoDroid( 2285): at Android.Views.View.DispatchTouchEvent (Android.Views.MotionEvent) [0x00071] in /Users/builder/data/lanes/1978/f98871a9/source/monodroid/src/Mono.Android/platforms/android-22/src/generated/Android.Views.View.cs:13339
08-31 16:26:04.686 I/MonoDroid( 2285): at Xamarin.Forms.Platform.Android.PlatformRenderer.DispatchTouchEvent (Android.Views.MotionEvent) <IL 0x00050, 0x0024f>
08-31 16:26:04.686 I/MonoDroid( 2285): at Android.Views.View.n_DispatchTouchEvent_Landroid_view_MotionEvent_ (intptr,intptr,intptr) [0x00011] in /Users/builder/data/lanes/1978/f98871a9/source/monodroid/src/Mono.Android/platforms/android-22/src/generated/Android.Views.View.cs:13319
08-31 16:26:04.686 I/MonoDroid( 2285): at (wrapper dynamic-method) object.6da1a5e8-6512-4806-8ca5-99b09750863d (intptr,intptr,intptr) <IL 0x00017, 0x0002b>
08-31 16:26:04.686 E/InputEventReceiver( 2285): Exception dispatching input event.
08-31 16:26:04.688 E/MessageQueue-JNI( 2285): Exception in MessageQueue callback: handleReceiveCallback
08-31 16:26:04.692 E/MessageQueue-JNI( 2285): md52ce486a14f4bcd95899665e9d932190b.JavaProxyThrowable: System.ArgumentException: 'jobject' must not be IntPtr.Zero.
08-31 16:26:04.692 E/MessageQueue-JNI( 2285): Parameter name: jobject
08-31 16:26:04.692 E/MessageQueue-JNI( 2285): at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000b] in /Users/builder/data/lanes/1978/f98871a9/source/mono/mcs/class/corlib/System.Runtime.ExceptionServices/ExceptionDispatchInfo.cs:61
08-31 16:26:04.692 E/MessageQueue-JNI( 2285): at Android.Runtime.JNIEnv.CallNonvirtualBooleanMethod (intptr,intptr,intptr,Android.Runtime.JValue*) [0x00085] in /Users/builder/data/lanes/1978/f98871a9/source/monodroid/src/Mono.Android/src/Runtime/JNIEnv.g.cs:662
08-31 16:26:04.692 E/MessageQueue-JNI( 2285): at Android.Views.View.DispatchTouchEvent (Android.Views.MotionEvent) [0x00071] in /Users/builder/data/lanes/1978/f98871a9/source/monodroid/src/Mono.Android/platforms/android-22/src/generated/Android.Views.View.cs:13339
08-31 16:26:04.692 E/MessageQueue-JNI( 2285): at Xamarin.Forms.Platform.Android.PlatformRenderer.DispatchTouchEvent (Android.Views.MotionEvent) <IL 0x00050, 0x0024f>
08-31 16:26:04.692 E/MessageQueue-JNI( 2285): at Android.Views.View.n_DispatchTouchEvent_Landroid_view_MotionEvent_ (intptr,intptr,intptr) [0x00011] in /Users/builder/data/lanes/1978/f98871a9/source/monodroid/src/Mono.Android/platforms/android-22/src/generated/Android.Views.View.cs:13319
08-31 16:26:04.692 E/MessageQueue-JNI( 2285): at (wrapper dynamic-method) object.6da1a5e8-6512-4806-8ca5-99b09750863d (intptr,intptr,intptr) <IL 0x00017, 0x0002b>
08-31 16:26:04.692 E/MessageQueue-JNI( 2285): 
08-31 16:26:04.692 E/MessageQueue-JNI( 2285): 	at md5530bd51e982e6e7b340b73e88efe666e.PlatformRenderer.n_dispatchTouchEvent(Native Method)
08-31 16:26:04.692 E/MessageQueue-JNI( 2285): 	at md5530bd51e982e6e7b340b73e88efe666e.PlatformRenderer.dispatchTouchEvent(PlatformRenderer.java:70)
08-31 16:26:04.692 E/MessageQueue-JNI( 2285): 	at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2405)
08-31 16:26:04.692 E/MessageQueue-JNI( 2285): 	at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2106)
08-31 16:26:04.692 E/MessageQueue-JNI( 2285): 	at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2405)
08-31 16:26:04.692 E/MessageQueue-JNI( 2285): 	at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2106)
08-31 16:26:04.692 E/MessageQueue-JNI( 2285): 	at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2405)
08-31 16:26:04.692 E/MessageQueue-JNI( 2285): 	at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2106)
08-31 16:26:04.692 E/MessageQueue-JNI( 2285): 	at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2405)
08-31 16:26:04.692 E/MessageQueue-JNI( 2285): 	at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2106)
08-31 16:26:04.692 E/MessageQueue-JNI( 2285): 	at com.android.internal.policy.impl.PhoneWindow$DecorView.superDispatchTouchEvent(PhoneWindow.java:2369)
08-31 16:26:04.692 E/MessageQueue-JNI( 2285): 	at com.android.internal.policy.impl.PhoneWindow.superDispatchTouchEvent(PhoneWindow.java:1719)
08-31 16:26:04.692 E/MessageQueue-JNI( 2285): 	at android.app.Activity.dispatchTouchEvent(Activity.java:2742)
08-31 16:26:04.692 E/MessageQueue-JNI( 2285): 	at com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchTouchEvent(PhoneWindow.java:2330)
08-31 16:26:04.692 E/MessageQueue-JNI( 2285): 	at android.view.View.dispatchPointerEvent(View.java:8666)
08-31 16:26:04.692 E/MessageQueue-JNI( 2285): 	at android.view.ViewRootImpl$ViewPostImeInputStage.processPointerEvent(ViewRootImpl.java:4123)
08-31 16:26:04.692 E/MessageQueue-JNI( 2285): 	at android.view.ViewRootImpl$ViewPostImeInputStage.onProcess(ViewRootImpl.java:3989)
08-31 16:26:04.692 E/MessageQueue-JNI( 2285): 	at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:3544)
08-31 16:26:04.692 E/MessageQueue-JNI( 2285): 	at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:3597)
08-31 16:26:04.692 E/MessageQueue-JNI( 2285): 	at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:3563)
08-31 16:26:04.692 E/MessageQueue-JNI( 2285): 	at android.view.ViewRootImpl$AsyncInputStage.forward(ViewRootImpl.java:3680)
08-31 16:26:04.692 E/MessageQueue-JNI( 2285): 	at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:3571)
08-31 16:26:04.692 E/MessageQueue-JNI( 2285): 	at android.view.ViewRootImpl$AsyncInputStage.apply(ViewRootImpl.java:3737)
08-31 16:26:04.692 E/MessageQueue-JNI( 2285): 	at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:3544)
08-31 16:26:04.692 E/MessageQueue-JNI( 2285): 	at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:3597)
08-31 16:26:04.692 E/MessageQueue-JNI( 2285): 	at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:3563)
08-31 16:26:04.692 E/MessageQueue-JNI( 2285): 	at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:3571)
08-31 16:26:04.692 E/MessageQueue-JNI( 2285): 	at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:3544)
08-31 16:26:04.692 E/MessageQueue-JNI( 2285): 	at android.view.ViewRootImpl.deliverInputEvent(ViewRootImpl.java:5807)
08-31 16:26:04.692 E/MessageQueue-JNI( 2285): 	at android.view.ViewRootImpl.doProcessInputEvents(ViewRootImpl.java:5781)
08-31 16:26:04.692 E/MessageQueue-JNI( 2285): 	at android.view.ViewRootImpl.enqueueInputEvent(ViewRootImpl.java:5752)
08-31 16:26:04.692 E/MessageQueue-JNI( 2285): 	at android.view.ViewRootImpl$WindowInputEventReceiver.onInputEvent(ViewRootImpl.java:5897)
08-31 16:26:04.692 E/MessageQueue-JNI( 2285): 	at android.view.InputEventReceiver.dispatchInputEvent(InputEventReceiver.java:185)
08-31 16:26:04.692 E/MessageQueue-JNI( 2285): 	at android.os.MessageQueue.nativePollOnce(Native Method)
08-31 16:26:04.692 E/MessageQueue-JNI( 2285): 	at android.os.MessageQueue.next(MessageQueue.java:143)
08-31 16:26:04.692 E/MessageQueue-JNI( 2285): 	at android.os.Looper.loop(Looper.java:122)
08-31 16:26:04.692 E/MessageQueue-JNI( 2285): 	at android.app.ActivityThread.
08-31 16:26:04.694 D/AndroidRuntime( 2285): Shutting down VM
Comment 1 Ahmad ELMadi 2015-08-31 10:31:40 UTC
Created attachment 12692 [details]
Project Showing the bug
Comment 2 Ahmad ELMadi 2015-08-31 10:43:33 UTC
Created attachment 12693 [details]
Video to get the bug
Comment 3 Dustin Jackson 2016-03-25 16:02:23 UTC
I am also experiencing this issue.  Has there been any progress on this issue?  Ahmad did you ever find a work around ?
Comment 4 Andrew Hall 2016-05-20 14:23:30 UTC
Hi Jason,

Now that the status of this bug is confirmed - can you give us any idea when it may be fixed?
Comment 5 Chris King 2016-05-23 21:15:43 UTC
Ahmad, could you please refresh your repro project using the latest version of forms and re-upload. We are unable to restore the nuget packages now.
Comment 6 Andrew Hall 2016-05-23 22:03:36 UTC
Created attachment 16080 [details]
Revised project

Chris, here is a revised version of Ahmad's project using an implementation of a BindablePicker copied from: NMackay in https://forums.xamarin.com/discussion/17875/binding-to-picker-items

Still the same steps to reproduce..
Comment 7 Ahmad ELMadi 2016-05-25 18:56:10 UTC
Created attachment 16102 [details]
The project with the latest nuget packages

Hello . this is a replication of the project showing the bug , and it has the latest stable nuget packages, rebuild the solution and may your nuget packages be restored ;)
Comment 8 Samantha Houts [MSFT] 2016-06-16 16:42:57 UTC
Should be fixed in 2.3.1-pre1
Comment 9 Parmendra Kumar 2016-07-04 14:40:14 UTC
I have checked this issue with Xamarin.Forms 2.3.1-pre2 and its working fine.

Hence closing this issue.