Bug 26771 - [Android] jobject must not be IntPtr.Zero when Navigation.PushAsync after resuming app
Summary: [Android] jobject must not be IntPtr.Zero when Navigation.PushAsync after res...
Status: RESOLVED FIXED
Alias: None
Product: Forms
Classification: Xamarin
Component: Forms ()
Version: 1.3.3
Hardware: PC Mac OS
: Normal normal
Target Milestone: ---
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2015-02-05 07:47 UTC by John Miller [MSFT]
Modified: 2015-03-06 05:45 UTC (History)
7 users (show)

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


Attachments
Test Case (338.21 KB, application/zip)
2015-02-05 07:47 UTC, John Miller [MSFT]
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:
RESOLVED FIXED

Description John Miller [MSFT] 2015-02-05 07:47:38 UTC
Created attachment 9659 [details]
Test Case

**Overview:**

   An exception is raised when after calling Navigation.PushAsync after resuming the app from the background. 

**Steps to Reproduce:**

Use the attached Test Case project
1. Launch Application on Android
2. Press Change Main Page Button
3. Press the Back hardware button (Make sure not to press home, use the back button)
4. Hold down the home or recent apps button (depends on your version of Android)
5. Select Application from current running apps list to re-launch
6. Page 2 Should be shown
7. Press Navigate Button
8. Exception is raised on line 23 of Page2.xaml.cs

**Actual Results:**

jobject must not be IntPtr.Zero
     at Android.Runtime.JNIEnv.CallObjectMethod (IntPtr jobject, IntPtr jmethod) [0x00010] in /Users/builder/data/lanes/monodroid-mlion-monodroid-4.20-series/ba9bbbdd/source/monodroid/src/Mono.Android/src/Runtime/JNIEnv.g.cs:170 
  at Android.Views.View.get_Context () [0x0002d] in /Users/builder/data/lanes/monodroid-mlion-monodroid-4.20-series/ba9bbbdd/source/monodroid/src/Mono.Android/platforms/android-21/src/generated/Android.Views.View.cs:4327 
  at Xamarin.Forms.Platform.Android.NavigationRenderer.SwitchContentAsync (Xamarin.Forms.Page view, Boolean animated, Boolean removed) [0x00000] in <filename unknown>:0 
  at Xamarin.Forms.Platform.Android.NavigationRenderer.OnPushAsync (Xamarin.Forms.Page view, Boolean animated) [0x00000] in <filename unknown>:0 
  at Xamarin.Forms.Platform.Android.NavigationRenderer.PushViewAsync (Xamarin.Forms.Page page, Boolean animated) [0x00000] in <filename unknown>:0 
  at Xamarin.Forms.Platform.Android.NavigationRenderer.OnPushed (System.Object sender, Xamarin.Forms.NavigationRequestedEventArgs e) [0x00000] in <filename unknown>:0 
  at (wrapper delegate-invoke) System.EventHandler`1<Xamarin.Forms.NavigationRequestedEventArgs>:invoke_void_object_TEventArgs (object,Xamarin.Forms.NavigationRequestedEventArgs)
  at Xamarin.Forms.NavigationPage+<PushAsyncInner>d__11.MoveNext () [0x00000] in <filename unknown>:0 
--- End of stack trace from previous location where exception was thrown ---
  at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x00000] in <filename unknown>:0 
  at System.Runtime.CompilerServices.TaskAwaiter.GetResult () [0x00000] in <filename unknown>:0 
  at Xamarin.Forms.NavigationPage+<PushAsync>d__c.MoveNext () [0x00000] in <filename unknown>:0 
--- End of stack trace from previous location where exception was thrown ---
  at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x00000] in <filename unknown>:0 
  at System.Runtime.CompilerServices.TaskAwaiter.GetResult () [0x00000] in <filename unknown>:0 
  at NavigationPageSample.Page2+<Button_OnClicked>c__async0.MoveNext () [0x00034] in /Users/johnmiller/Downloads/NavigationPageSample/NavigationPageSample/NavigationPageSample/Page2.xaml.cs:23 

**Expected Results:**

   No exception. Should launch Page3.xaml

**Build Date & Platform:**

   XA 4.20
   XF 1.3.3-pre2

**Additional Information:**

   Works Ok on iOS.
Comment 1 Atin 2015-02-05 10:31:40 UTC
I have checked this issue with the help of given sample and steps given in the bug description and able to reproduce this behaviour. 

[MonoDroid] UNHANDLED EXCEPTION:
[MonoDroid] System.ArgumentException: 'jobject' must not be IntPtr.Zero.
[MonoDroid] Parameter name: jobject

Screencast:http://www.screencast.com/t/qi0xIvx7B0
Application Output:https://gist.github.com/saurabh360/fd5811f71d975db13532
Device Output:https://gist.github.com/saurabh360/cdfcb25b13fdfa1f08c3
IDE Logs:https://gist.github.com/saurabh360/61653ac27d59f80a98e8

Xamarin.Forms:1.3.3.6321-pre2

Environment Info:

=== Xamarin Studio ===

Version 5.7.1 (build 14)
Installation UUID: 2939b8b4-8977-42bd-82d6-100275ccd9cd
Runtime:
	Mono 3.12.0 ((detached/a813491)
	GTK+ 2.24.23 (Raleigh theme)

	Package version: 312000068

=== Apple Developer Tools ===

Xcode 6.2 (6770)
Build 6C121

=== Xamarin.iOS ===

Version: 8.6.1.20 (Enterprise Edition)
Hash: 3b3ef43
Branch: 
Build date: 2015-01-24 09:42:21-0500

=== Xamarin.Mac ===

Version: 1.12.0.4 (Enterprise Edition)

=== Xamarin.Android ===

Version: 4.20.0.28 (Enterprise Edition)
Android SDK: /Users/360_macmini/Library/Developer/Xamarin/android-sdk-mac_x86
	Supported Android versions:
		1.6   (API level 4)
		2.1   (API level 7)
		2.2   (API level 8)
		2.3   (API level 10)
		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)
		5.0   (API level 21)
Java SDK: /usr
java version "1.6.0_65"
Java(TM) SE Runtime Environment (build 1.6.0_65-b14-462-11M4609)
Java HotSpot(TM) 64-Bit Server VM (build 20.65-b04-462, mixed mode)

=== Build Information ===

Release ID: 507010014
Git revision: a4dd61ad7f8b3695be4b17bcb5c3ae6b81438cf7
Build date: 2015-01-19 15:21:09-05
Xamarin addins: 081208fe3bbf40e24a562867c6c7fba20a9b94b6

=== Operating System ===

Mac OS X 10.9.4
Darwin 360-MACMINIs-Mac-mini-2.local 13.3.0 Darwin Kernel Version 13.3.0
    Tue Jun  3 21:27:35 PDT 2014
    root:xnu-2422.110.17~1/RELEASE_X86_64 x86_64
Comment 2 Jason Smith [MSFT] 2015-03-06 05:45:01 UTC
Should be fixed in 1.4.1-pre1