Bug 25979 - Removing page from Navigation stack throws System.ArgumentException
Summary: Removing page from Navigation stack throws System.ArgumentException
Status: VERIFIED FIXED
Alias: None
Product: Forms
Classification: Xamarin
Component: Android ()
Version: 1.4.2
Hardware: PC Mac OS
: High major
Target Milestone: ---
Assignee: Seth Rosetter
URL:
Depends on:
Blocks:
 
Reported: 2015-01-13 11:00 UTC by Prashant Cholachagudda
Modified: 2015-07-17 07:52 UTC (History)
9 users (show)

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


Attachments
Possible bug example (77 bytes, text/plain)
2015-06-18 09:29 UTC, Bob
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 Prashant Cholachagudda 2015-01-13 11:00:27 UTC
When we try to remove a page from Navigation stack in Android throws System.ArgumentException: ‘jobject’ must not be IntPtr.Zero.

protected override void OnAppearing()
{
    Navigation.NavigationStack[0].BindingContext = null;
    Navigation.RemovePage(Navigation.NavigationStack[0]); // Exception, however it works on iOS and Win Phone
}

Version Information:

Xamarin.Forms v1.3

=== Xamarin Studio ===

Version 5.7 (build 661)
Installation UUID: f8016946-f8ae-41ff-8a6e-6c3d1a711d07
Runtime:
	Mono 3.12.0 ((detached/a813491)
	GTK+ 2.24.23 (Raleigh theme)

	Package version: 312000068

=== Apple Developer Tools ===

Xcode 6.1.1 (6611)
Build 6A2008a

=== Xamarin.Mac ===

Version: 1.10.0.18 (Business Edition)

=== Xamarin.Android ===

Version: 4.20.0.28 (Business Edition)
Android SDK: /Users/prashantvc/android-sdk
	Supported Android versions:
		2.2    (API level 8)
		3.1    (API level 12)
		4.0    (API level 14)
		4.0.3  (API level 15)
		4.1    (API level 16)
		4.2    (API level 17)
		4.3    (API level 18)
		4.4    (API level 19)
		4.4.87 (API level 20)
		5.0    (API level 21)
Java SDK: /usr
java version "1.8.0_20"
Java(TM) SE Runtime Environment (build 1.8.0_20-b26)
Java HotSpot(TM) 64-Bit Server VM (build 25.20-b23, mixed mode)

=== Xamarin.iOS ===

Version: 8.6.0.51 (Business Edition)
Hash: dfb682f
Branch: 
Build date: 2015-01-08 13:39:32-0500

=== Build Information ===

Release ID: 507000661
Git revision: b70bab61da996da29045ea8ee8aed1a6faedbe78
Build date: 2015-01-05 16:31:31-05
Xamarin addins: 82f6c71490562d6cd125a09287f441902fdac3d7

=== Operating System ===

Mac OS X 10.10.1
Darwin Prashant-MBPr.local 14.0.0 Darwin Kernel Version 14.0.0
    Fri Sep 19 00:26:44 PDT 2014
    root:xnu-2782.1.97~2/RELEASE_X86_64 x86_64
Comment 2 foxanna 2015-02-16 09:09:16 UTC
I am experiencing the same problem.

Maybe this stack trace can be helpful:

02-16 15:56:55.899 I/MonoDroid(25927): UNHANDLED EXCEPTION:
02-16 15:56:55.907 I/MonoDroid(25927): System.ArgumentException: 'jobject' must not be IntPtr.Zero.
02-16 15:56:55.907 I/MonoDroid(25927): Parameter name: jobject
02-16 15:56:55.907 I/MonoDroid(25927): at Android.Runtime.JNIEnv.CallNonvirtualVoidMethod (intptr,intptr,intptr,Android.Runtime.JValue[]) [0x00010] in /Users/builder/data/lanes/monodroid-mlion-monodroid-4.21-series/49a04b96/source/monodroid/src/Mono.Android/src/Runtime/JNIEnv.g.cs:886
An unhandled exception occured.

02-16 15:56:55.907 I/MonoDroid(25927): at Android.Views.View.set_Visibility (Android.Views.ViewStates) [0x00070] in /Users/builder/data/lanes/monodroid-mlion-monodroid-4.21-series/49a04b96/source/monodroid/src/Mono.Android/platforms/android-21/src/generated/Android.Views.View.cs:9908
02-16 15:56:55.907 I/MonoDroid(25927): at Xamarin.Forms.Platform.Android.NavigationRenderer/<>c__DisplayClass8.<SwitchContentAsync>b__5 (Android.Animation.Animator) <IL 0x0000f, 0x0007b>
02-16 15:56:55.907 I/MonoDroid(25927): at Xamarin.Forms.Platform.Android.GenericAnimatorListener.OnAnimationEnd (Android.Animation.Animator) <IL 0x0000f, 0x000ab>
02-16 15:56:55.908 I/MonoDroid(25927): at Android.Animation.AnimatorListenerAdapter.n_OnAnimationEnd_Landroid_animation_Animator_ (intptr,intptr,intptr) [0x00011] in /Users/builder/data/lanes/monodroid-mlion-monodroid-4.21-series/49a04b96/source/monodroid/src/Mono.Android/platforms/android-21/src/generated/Android.Animation.AnimatorListenerAdapter.cs:96
02-16 15:56:55.908 I/MonoDroid(25927): at (wrapper dynamic-method) object.7dbc8ee0-2c83-4eae-88a4-0b3e432e3577 (intptr,intptr,intptr) <IL 0x00017, 0x00043>
02-16 15:56:55.917 W/art     (25927): JNI RegisterNativeMethods: attempt to register 0 native methods for android.runtime.JavaProxyThrowable
referenceTable GDEF length=670 1
referenceTable GSUB length=7202 1
referenceTable GPOS length=24560 1
referenceTable GDEF length=670 1
referenceTable GSUB length=7186 1
referenceTable GPOS length=26482 1
referenceTable head length=54 1
referenceTable head length=54 1
02-16 15:56:57.902 E/mono    (25927): 
02-16 15:56:57.902 E/mono    (25927): Unhandled Exception:
02-16 15:56:57.902 E/mono    (25927): System.ArgumentException: 'jobject' must not be IntPtr.Zero.
02-16 15:56:57.902 E/mono    (25927): Parameter name: jobject
02-16 15:56:57.902 E/mono    (25927):   at Android.Runtime.JNIEnv.CallNonvirtualVoidMethod (IntPtr jobject, IntPtr jclass, IntPtr jmethod, Android.Runtime.JValue[] parms) [0x00010] in /Users/builder/data/lanes/monodroid-mlion-monodroid-4.21-series/49a04b96/source/monodroid/src/Mono.Android/src/Runtime/JNIEnv.g.cs:886 
02-16 15:56:57.902 E/mono    (25927):   at Android.Views.View.set_Visibility (ViewStates value) [0x00070] in /Users/builder/data/lanes/monodroid-mlion-monodroid-4.21-series/49a04b96/source/monodroid/src/Mono.Android/platforms/android-21/src/generated/Android.Views.View.cs:9908
Comment 3 tim.ahrentlov 2015-02-17 11:37:38 UTC
I found that removing the call to RemovePage from OnAppearing, made the bug disappear.
Comment 4 Kevin Ford 2015-02-26 14:17:26 UTC
I'm also hitting this same bug in Xamarin Forms 1.3.4 with Navigation.Remove.

02-26 13:56:40.485 I/MonoDroid( 3507): at (wrapper dynamic-method) object.a5db5057-cd11-4cb5-926a-7c12378fde22 (intptr,intptr,intptr) <IL 0x00017, 0x0001f>
02-26 13:56:45.877 E/mono-rt ( 3507): [ERROR] FATAL UNHANDLED EXCEPTION: System.ArgumentException: 'jobject' must not be IntPtr.Zero.
02-26 13:56:45.877 E/mono-rt ( 3507): Parameter name: jobject
02-26 13:56:45.877 E/mono-rt ( 3507):   at Android.Runtime.JNIEnv.CallNonvirtualVoidMethod (IntPtr jobject, IntPtr jclass, IntPtr jmethod, Android.Runtime.JValue[] parms) [0x00010] in /Users/builder/data/lanes/monodroid-mlion-monodroid-4.21-series/49a04b96/source/monodroid/src/Mono.Android/src/Runtime/JNIEnv.g.cs:886 
02-26 13:56:45.877 E/02-26 13:56:45.877 E/mono-rt ( 3507):   at Android.Views.View.set_Visibility (ViewStates value) [0x00070] in /Users/builder/data/lanes/monodroid-mlion-monodroid-4.21-series/49a04b96/source/monodroid/src/Mono.Android/platforms/android-19/src/generated/Android.Views.View.cs:9179 
02-26 13:56:45.877 E/mono-rt ( 3507):   at Xamarin.Forms.Platform.Android.NavigationRenderer+<>c__DisplayClass8.<SwitchContentAsync>b__5 (Android.Animation.Animator a) [0x00000] in <filename unknown>:0 
02-26 13:56:45.877 E/mono-rt ( 3507):   at Xamarin.Forms.Platform.Android.GenericAnimatorListener.OnAnimationEnd (Android.Animation.Animator animation) [0x00000] in <filename unknown>:0 
02-26 13:56:45.877 E/mono-rt ( 3507):   at Android.Animation.AnimatorListenerAdapter.n_OnAnimationEnd_Landroid_animation_Animator_ (IntPtr jnienv, IntPtr native__this, IntPtr native_animation) [0x00011] in /Users/builder/data/lanes/monodroid-mlion-monodroid-4.21-series/49a04b96/source/monodroid/src/Mono.Android/platforms/android-19/src/generated/Android.Animation.AnimatorListenerAdapter.cs:96 
02-26 13:56:45.877 E/mono-rt ( 3507):   at (wrapper dynamic-method) object:a5db5057-cd11-4cb5-926a-7c12378fde22 (intptr,intptr,intptr)
02-26 13:56:45.885 I/ActivityManager(  526): Process MyVoteUI.MyVoteUI (pid 3507) has died.
Comment 6 Bob 2015-06-18 09:29:01 UTC
Created attachment 11663 [details]
Possible bug example

I believe the bug we are seeing in our project is related to this one. This bug only happens on Android.  Not iOS.  I have tried the most recent nuget package and prerelease to no avail.  How to reproduce:

Run the project. 
Click Login
Tap the menu, Add Time
Tap the resource button
Tap Back
Tap the resource button
Tap Back
Keep doing this until the timer fires. Exception will occur.


06-18 09:16:26.960 I/MonoDroid( 5898): UNHANDLED EXCEPTION:
06-18 09:16:26.960 I/MonoDroid( 5898): System.ArgumentException: 'jobject' must not be IntPtr.Zero.
06-18 09:16:26.960 I/MonoDroid( 5898): Parameter name: jobject
06-18 09:16:26.960 I/MonoDroid( 5898): at Android.Runtime.JNIEnv.CallNonvirtualVoidMethod (intptr,intptr,intptr,Android.Runtime.JValue*) [0x00010] in /Users/builder/data/lanes/monodroid-mavericks-monodroid-5.1-series/d419c934/source/monodroid/src/Mono.Android/src/Runtime/JNIEnv.g.cs:1019
06-18 09:16:26.960 I/MonoDroid( 5898): at Android.Views.View.set_Visibility (Android.Views.ViewStates) [0x00070] in /Users/builder/data/lanes/monodroid-mavericks-monodroid-5.1-series/d419c934/source/monodroid/src/Mono.Android/platforms/android-21/src/generated/Android.Views.View.cs:10725
06-18 09:16:26.970 I/MonoDroid( 5898): at Xamarin.Forms.Platform.Android.NavigationRenderer/<>c__DisplayClass8.<SwitchContentAsync>b__5 (Android.Animation.Animator) <IL 0x0000f, 0x0007b>
06-18 09:16:26.970 I/MonoDroid( 5898): at Xamarin.Forms.Platform.Android.GenericAnimatorListener.OnAnimationEnd (Android.Animation.Animator) <IL 0x0000f, 0x000ab>
06-18 09:16:26.970 I/MonoDroid( 5898): at Android.Animation.AnimatorListenerAdapter.n_OnAnimationEnd_Landroid_animation_Animator_ (intptr,intptr,intptr) [0x00011] in /Users/builder/data/lanes/monodroid-mavericks-monodroid-5.1-series/d419c934/source/monodroid/src/Mono.Android/platforms/android-21/src/generated/Android.Animation.AnimatorListenerAdapter.cs:105
06-18 09:16:26.970 I/MonoDroid( 5898): at (wrapper dynamic-method) object.c5fd2b15-4035-4d2b-af13-17abf93d99f5 (intptr,intptr,intptr) <IL 0x00017, 0x00043>
06-18 09:16:26.980 D/AndroidRuntime( 5898): Shutting down VM
06-18 09:16:26.980 W/dalvikvm( 5898): threadid=1: thread exiting with uncaught exception (group=0x417ddda0)
An unhandled exception occured.
Comment 7 Jason Smith [MSFT] 2015-06-26 02:42:21 UTC
Should be fixed in 1.4.4-pre1
Comment 8 Parmendra Kumar 2015-07-17 07:52:03 UTC
I have checked this issue with attached sample project in comment #5 and its working fine with X.F 1.4.4-pre2.

Hence closing this issue.