Bug 26561 - PopAsync and PopToRootAsync throws NullReferenceException when current page is MasterDetailPage
Summary: PopAsync and PopToRootAsync throws NullReferenceException when current page i...
Alias: None
Product: Forms
Classification: Xamarin
Component: Forms ()
Version: 1.3.1
Hardware: Macintosh Mac OS
: Normal normal
Target Milestone: ---
Assignee: Bugzilla
Depends on:
Reported: 2015-01-29 14:07 UTC by chaseqna
Modified: 2016-04-08 19:20 UTC (History)
6 users (show)

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

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:

Description chaseqna 2015-01-29 14:07:03 UTC
If I have a navigation stack where the last page is a MasterDetailPage and I call PopToRootAsync() or PopAsync() from a button on the Master page, I get an exception. If I call PopToRootAsync from a button on the Detail page I also get an exception, but PopAsync() works.  Here's the stack trace for calling PopToRootAsync():

Xamarin.Forms.Platform.iOS.TabletMasterDetailRenderer.ViewDidDisappear (animated=false) in 
MonoTouch.UIKit.UIApplication.UIApplicationMain () in 
MonoTouch.UIKit.UIApplication.Main (args={string[0]}, principal=0x0, delegate=0x7f271230) in /Developer/MonoTouch/Source/monotouch/src/UIKit/UIApplication.cs:62
MonoTouch.UIKit.UIApplication.Main (args={string[0]}, principalClassName=(null), delegateClassName="AppDelegate") in /Developer/MonoTouch/Source/monotouch/src/UIKit/UIApplication.cs:46
CargoCompartmentPrototype.iOS.Application.Main (args={string[0]}) in /Users/ChaseQNA/Projects/CargoCompartmentPrototype/iOS/Main.cs:17

My app does not use the navigation bar, so this is preventing the user from ever exiting to the Home screen.
Comment 1 Jason Smith [MSFT] 2015-02-03 00:48:01 UTC
Can you please attach a sample?

Keep in mind the .Navigation property accesses the ancestral navigation implementor. That means that quite likely you cannot call Navigation.PopAsync from any button in the Master because it is not part of the navigation subtree.
Comment 2 chaseqna 2015-02-04 11:48:41 UTC
Hi Jason,
I'm not using the Master's .Navigation property.  I'm calling PopToRootAsync on the app shell NavigationPage through a NavigationService which has the MasterDetailPage on its NavigationStack.

I'll try to get a sample as soon as I can if you still need it, but we have a release at the end of the week, so I'm busy at the moment.

Comment 3 Rui Marinho 2016-04-08 19:20:48 UTC
Thank you for taking the time to submit this report. After reviewing the description of this bug, we believe it no longer affects the current version of Xamarin.Forms. If you are still experiencing the issue after updating your packages, please reopen this report with an attached reproduction.
For your convenience, we have created some reproduction best practices viewable here: https://gist.github.com/jassmith/92405c300e54a01dcc6d