Bug 26316 - [iOS] When deploying app on the iPad iOS 7.1 simulator, an unhandled exception occurs: 'System.NotSupportedException: popped page does not current navigation stack, please file a bug.'
Summary: [iOS] When deploying app on the iPad iOS 7.1 simulator, an unhandled exceptio...
Status: RESOLVED FIXED
Alias: None
Product: Forms
Classification: Xamarin
Component: Forms (show other bugs)
Version: 1.3.0
Hardware: PC Mac OS
: Normal normal
Target Milestone: ---
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2015-01-22 21:19 UTC by Kent Green [MSFT]
Modified: 2017-05-27 11:12 UTC (History)
19 users (show)

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


Attachments
logs from customer (109.29 KB, application/octet-stream)
2015-01-22 21:19 UTC, Kent Green [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 Kent Green [MSFT] 2015-01-22 21:19:50 UTC
Created attachment 9458 [details]
logs from customer

---Overview---
From this desk case:
https://xamarin.desk.com/agent/case/119517

Customer reports that when deploying their app on the iOS simulator (iPad Retina 64 bit iOS 7.1), an unhandled exception occurs 'System.NotSupportedException: popped page does not current navigation stack, please file a bug.'

---Steps to reproduce---
Customer states that their app implements a breadcrumbs control, which lists the pages in the navigation stack and lets users navigate back to each using repeated PopAsync() calls. They reported that it works as expected on Android but in the iOS simulator it throws the "System.NotSupportedException" when they navigate several pages in, then navigate back once using the inbuilt Navigation page control, then  
navigate back to a page 3 pages ago using a breadcrumb control. (3 calls to await App.NavigationPage.Navigation.PopAsync(false); App.NavigationPage is a static reference to the navigation page wrapped in the root page.)

The customer also noted that navigating back to the last or second to last page via the breadcrumbs doesn't cause an error, it has to be at least 3 pages back.

The customer also noted that the same error does not occur on Android.

---Denenv log snippet---
The following entries in the log the customer sent over appeared like they might be the exception they are seeing. (I'm attaching the full log file they sent over as well):

> Xamarin.VisualStudio.Debugger.AD7DebugExceptionEvent Verbose: 0 : [2015-01-22 16:25:36.2] AD7DebugExceptionEvent ctor: Unhandled Exception:

> System.NotSupportedException: popped page does not current navigation stack, please file a bug.
> Xamarin.VisualStudio.Debugger.AD7DebugExceptionEvent Verbose: 0 : [2015-01-22 16:25:36.2] AD7DebugExceptionEvent GetException: Unhandled Exception:

> System.NotSupportedException: popped page does not current navigation stack, please file a bug.
> Xamarin.VisualStudio.Debugger.AD7DebugExceptionEvent Verbose: 0 : [2015-01-22 16:25:36.3] AD7DebugExceptionEvent GetException: Unhandled Exception:

> System.NotSupportedException: popped page does not current navigation stack, please file a bug.
> Xamarin.VisualStudio.Debugger.AD7DebugExceptionEvent Verbose: 0 : [2015-01-22 16:25:36.4] AD7DebugExceptionEvent CanPassToDebuggee ()
> Xamarin.VisualStudio.Debugger.AD7DebugExceptionEvent Verbose: 0 : [2015-01-22 16:25:36.5] AD7DebugExceptionEvent GetExceptionDescription: Unhandled Exception:

> System.NotSupportedException: popped page does not current navigation stack, please file a bug.

---Build information---
Microsoft Visual Studio Premium 2013
Version 12.0.31101.00 Update 4
Microsoft .NET Framework
Version 4.5.50938

Installed Version: Premium

LightSwitch for Visual Studio 2013 06191-004-0454001-02906
Microsoft LightSwitch for Visual Studio 2013

Team Explorer for Visual Studio 2013 06191-004-0454001-02906
Microsoft Team Explorer for Visual Studio 2013

Visual Basic 2013 06191-004-0454001-02906
Microsoft Visual Basic 2013

Visual C# 2013 06191-004-0454001-02906
Microsoft Visual C# 2013

Visual C++ 2013 06191-004-0454001-02906
Microsoft Visual C++ 2013

Visual F# 2013 06191-004-0454001-02906
Microsoft Visual F# 2013

Visual Studio 2013 Code Analysis Spell Checker 06191-004-0454001-02906
Microsoft(r) Visual Studio(r) 2013 Code Analysis Spell Checker

Portions of International CorrectSpell(tm) spelling correction system (c) 1993 by Lernout & Hauspie Speech Products N.V. All rights reserved.

The American Heritage(r) Dictionary of the English Language, Third Edition Copyright (c) 1992 Houghton Mifflin Company. Electronic version licensed from Lernout & Hauspie Speech Products N.V. All rights reserved.

ASP.NET and Web Tools 12.4.51016.0
Microsoft Web Developer Tools contains the following components:
Support for creating and opening ASP.NET web projects
Browser Link: A communication channel between Visual Studio and browsers
Editor extensions for HTML, CSS, and JavaScript
Page Inspector: Inspection tool for ASP.NET web projects
Scaffolding: A framework for building and running code generators
Server Explorer extensions for Microsoft Azure Websites
Web publishing: Extensions for publishing ASP.NET web projects to hosting providers, on-premises servers, or Microsoft Azure

ASP.NET Web Frameworks and Tools 2012.2 4.1.21001.0
For additional information, visit http://go.microsoft.com/fwlink/?LinkID=309563

ASP.NET Web Frameworks and Tools 2013 5.2.21010.0
For additional information, visit http://www.asp.net/

Common Azure Tools 1.3
Provides common services for use by Azure Mobile Services and Microsoft Azure Tools.

Microsoft Azure Mobile Services Tools 1.3
Microsoft Azure Mobile Services Tools

NuGet Package Manager 2.8.50926.663
NuGet Package Manager in Visual Studio. For more information about NuGet, visit http://docs.nuget.org/.

Office Developer Tools for Visual Studio 2013 ENU 12.0.30626
Microsoft Office Developer Tools for Visual Studio 2013 ENU

PowerShell Tools 1.3
Provides file classification services using PowerShell

PreEmptive Analytics Visualizer 1.2
Microsoft Visual Studio extension to visualize aggregated summaries from the PreEmptive Analytics product.

Release Management for Visual Studio Package 1.0
Release Management for Visual Studio

SQL Server Data Tools 12.0.41012.0
Microsoft SQL Server Data Tools

Windows Phone 8.1 SDK Integration 1.0
This package integrates the tools for the Windows Phone 8.1 SDK into the menus and controls of Visual Studio.

Workflow Manager Tools 1.0 1.0
This package contains the necessary Visual Studio integration components for Workflow Manager.

Xamarin 3.8.150.0 (10cfd178d55287f09c85f5a1e604dfe20889a40f)
Visual Studio extension to enable development for Xamarin.iOS and Xamarin.Android.

Xamarin.Android 4.20.0.28 (ba9bbbdd44cfdc4bf485e8885bd2ad24fba525f7)
Visual Studio plugin to enable development for Xamarin.Android.

Xamarin.iOS 8.4.0.0 (840a925103a0bf4a856507f13d5eaee3c1579c2f)
Visual Studio extension to enable development for Xamarin.iOS.

---Additional Info---
I talked with Seth Rosetter as a quick sanity check of this issue, and one possibility he pointed out is if somehow AsyncPop is getting called more times then there are pages in the stack; that *might* cause something like this; since AsyncPop will fail if called more times then the number of pages available to pop. 

Naturally, given that the exception is unhandled & the "expected" behavior depends on the code structure itself I suspect a sample repo will be required; I've requested the customer send this info & some other possible info for more clues.
Comment 1 Rolf Bjarne Kvinge [MSFT] 2015-01-23 05:17:02 UTC
I've never seen this exception message ("popped page does not current navigation stack") before, Google doesn't show anything and I can't find it in our source code either. In addition there is no stack trace, so it's impossible to say where it comes from.

IOW: we need more information, at the very least a complete stack trace in order to know where to start looking, however a complete test project would likely be the fastest and easiest way to track it down.
Comment 4 Sebastien Pouliot 2015-01-29 18:52:08 UTC
Stack traces shows this is coming from XF.

> popped page does not current navigation stack, please file a bug.

That's likely a uncommon condition they want to be made aware of.
Comment 5 Jason Smith [MSFT] 2015-02-02 02:02:44 UTC
Poorly worded... two bugs for one
Comment 6 Jason Smith [MSFT] 2015-03-03 01:13:09 UTC
Should be fixed in 1.4.0-pre1
Comment 7 Kevin Kraemer 2015-08-31 09:58:06 UTC
I am still seeing this issue running XF 1.4.3.6376. Got two Insights issues reported with this on iPhone 6 and iPad mini.

Stack trace is below:
System.NotSupportedExceptionPopped page does not appear on top of current navigation stack, please file a bug.

  at Xamarin.Forms.Platform.iOS.NavigationRenderer+<OnPopViewAsync>d__28.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.ThrowForNonSuccess (System.Threading.Tasks.Task task) [0x00000] in <filename unknown>:0 
  at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) [0x00000] in <filename unknown>:0 
  at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) [0x00000] in <filename unknown>:0 
  at System.Runtime.CompilerServices.TaskAwaiter`1[System.Boolean].GetResult () [0x00000] in <filename unknown>:0 
  at Xamarin.Forms.NavigationPage+<PopAsyncInner>d__23.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.ThrowForNonSuccess (System.Threading.Tasks.Task task) [0x00000] in <filename unknown>:0 
  at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) [0x00000] in <filename unknown>:0 
  at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) [0x00000] in <filename unknown>:0 
  at System.Runtime.CompilerServices.TaskAwaiter`1[Xamarin.Forms.Page].GetResult () [0x00000] in <filename unknown>:0 
  at Xamarin.Forms.NavigationPage+<PopAsync>d__1b.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.ThrowForNonSuccess (System.Threading.Tasks.Task task) [0x00000] in <filename unknown>:0 
  at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) [0x00000] in <filename unknown>:0 
  at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) [0x00000] in <filename unknown>:0 
  at System.Runtime.CompilerServices.TaskAwaiter`1[Xamarin.Forms.Page].GetResult () [0x00000] in <filename unknown>:0 
  at PdrMobile.Core.Areas.Compare.Views.ComparisonView+<<OnAppearing>b__1>d__5.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.AsyncMethodBuilderCore.<ThrowAsync>m__0 (System.Object state) [0x00000] in <filename unknown>:0 
  at UIKit.UIKitSynchronizationContext+<Post>c__AnonStorey0.<>m__0 () [0x00000] in <filename unknown>:0 
  at Foundation.NSAsyncActionDispatcher.Apply () [0x00000] in <filename unknown>:0 
  at (wrapper managed-to-native) UIKit.UIApplication:UIApplicationMain (int,string[],intptr,intptr)
  at UIKit.UIApplication.Main (System.String[] args, IntPtr principal, IntPtr delegate) [0x00000] in <filename unknown>:0 
  at UIKit.UIApplication.Main (System.String[] args, System.String principalClassName, System.String delegateClassName) [0x00000] in <filename unknown>:0 
  at PdrMobile.iOS.Application.Main (System.String[] args) [0x00000] in <filename unknown>:0
Comment 8 NMackay 2016-01-13 21:41:26 UTC
I know this is marked as fixed but I've had it reported in Forms 2.0 Stable.

iPad Mini 2 (v4,5)
iOS 9.2
1 (1.0)
January 13, 2016 8:38pmUTC

Stacktrace
1 of 1
System.NotSupportedExceptionPopped page does not appear on top of current navigation stack, please file a bug.
Xamarin.Forms.Platform.iOS.NavigationRenderer.<OnPopViewAsync>d__55.MoveNext()
Xamarin.Forms.NavigationPage.<PopAsyncInner>d__69.MoveNext()
Xamarin.Forms.NavigationPage.<PopAsync>d__68.MoveNext()
MarineOps.Helpers.NavigationService.<GoBack>d__8.MoveNext()
MarineOps.Data.ViewModel.OrderDetailViewModel.<DialogAction>d__11.MoveNext()
Comment 9 Ramon 2016-03-07 14:34:10 UTC
I also see this issue regularly.

Here is a sample of the clients I see experiencing it: iPhone OS 9.2.1, iPhone OS 8.3, iPhone OS 8.4.1, iPhone OS 9.0.2
 
Message: [NotSupportedException: Popped page does not appear on top of current navigation stack, please file a bug.]
     at Xamarin.Forms.Platform.iOS.NavigationRenderer+<OnPopViewAsync>d__51.MoveNext () <0x100b6d560 + 0x00108> in <filename unknown>
    --- End of stack trace from previous location where exception was thrown ---
     at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () <0x1002e6620 + 0x00028> in <filename unknown>
     at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) <0x1002e5ae0 + 0x000d3> in <filename unknown>
     at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) <0x1002e5a30 + 0x0008b> in <filename unknown>
     at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) <0x1002e59d0 + 0x00047> in <filename unknown>
     at System.Runtime.CompilerServices.TaskAwaiter`1[TResult].GetResult () <0x100464060 + 0x0001b> in <filename unknown>
     at Xamarin.Forms.NavigationPage+<PopAsyncInner>d__69.MoveNext () <0x100a1b570 + 0x0026b> in <filename unknown>
    --- End of stack trace from previous location where exception was thrown ---
     at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () <0x1002e6620 + 0x00028> in <filename unknown>
     at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) <0x1002e5ae0 + 0x000d3> in <filename unknown>
     at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) <0x1002e5a30 + 0x0008b> in <filename unknown>
     at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) <0x1002e59d0 + 0x00047> in <filename unknown>
     at System.Runtime.CompilerServices.TaskAwaiter`1[TResult].GetResult () <0x1002e5d20 + 0x0001b> in <filename unknown>
     at Xamarin.Forms.NavigationPage+<PopAsync>d__68.MoveNext () <0x100a1aff0 + 0x0048f> in <filename unknown>
Comment 10 aed 2016-06-24 17:27:34 UTC
Started repro-ing in XF2.3. Please re-open bug

Message:
Popped page does not appear on top of current navigation stack, please file a bug.
Stack Trace:
Xamarin.Forms.Platform.iOS.NavigationRenderer+<OnPopViewAsync>d__41.MoveNext()
[...] as above
Comment 11 stephen.machwirth 2016-10-07 11:24:48 UTC
*** Terminating app due to uncaught exception 'System.AggregateException', reason: 'System.AggregateException: A Task's exception(s) were not observed either by Waiting on the Task or accessing its Exception property. As a result, the unobserved exception was rethrown by the finalizer thread. ---> System.NotSupportedException: Popped page does not appear on top of current navigation stack, please file a bug.
  at Xamarin.Forms.Platform.iOS.NavigationRenderer+<OnPopViewAsync>d__41.MoveNext () [0x0005e] in C:\BuildAgent2\work\ca3766cfc22354a1\Xamarin.Forms.Platform.iOS\Renderers\NavigationRenderer.cs:291 
   --- End of inner exception stack trace ---
---> (Inner Exception #0) System.NotSupportedException: Popped page does not appear on top of current navigation stack, please file a bug.
  at Xamarin.Forms.Platform.iOS.NavigationRenderer+<OnPopViewAsync>d__41.MoveNext () [0x0005e] in C:\BuildAgent2\work\ca3766cfc22354a1\Xamarin.Forms.Platform.iOS\Renderers\NavigationRenderer.cs:291 <---
Comment 12 stephen.machwirth 2016-10-07 11:26:50 UTC
happens at 2.3.3.152pre-2
Comment 13 Stefano 2016-10-07 12:35:11 UTC
Thousand crashes per day in production, almost all on iOS 10.
Please reopen.


Application Specific Information:
*** Terminating app due to uncaught exception 'System.NotSupportedException: Popped page does not appear on top of current navigation stack, please file a bug.', reason: 'System.NotSupportedException: Popped page does not appear on top of current navigation stack, please file a bug.
  at Xamarin.Forms.Platform.iOS.NavigationRenderer+<OnPopViewAsync>d__55.MoveNext () <0x100d1d3d8 + 0x001f8> in <filename unknown>:0 
--- End of stack trace from previous location where exception was thrown ---
  at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) <0x1006921d4 + 0x000d4> in <filename unknown>:0 
  at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) <0x1006920fc + 0x000c7> in <filename unknown>:0 
  at System.Runtime.CompilerServices.TaskAwaiter`1[TResult].GetResult () <0x10078018c + 0x0003b> in <filename unknown>:0 
  at Xamarin.Forms.NavigationPage+<PopAsyncInner>d__69.MoveNext () <0x1004f6280 + 0x0007f> in <filename unknown>:0 
--- End of stack trace from previous location where exception was thrown ---
  at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) <0x1006921d4 + 0x000d4> in <filename unknown>:0 
  at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) <0x1006920fc + 0x000c7> in <filename unknown>:0 
  at System.Runtime.CompilerServices.TaskAwaiter`1[TResult].GetResult () <0x100692414 + 0x0003b> in <filename unknown>:0 
  at Xamarin.Forms.NavigationPage+<PopAsync>d__68.MoveNext () <0x1004f5ee0 + 0x0015b> in <filename unknown>:0 
--- End of stack trace from previous location where exception was thrown ---
Comment 14 Teo 2016-10-12 11:18:59 UTC
On Xamarin.Forms 2.3.3.152-pre2, happens continuously:


System.NotSupportedException: Popped page does not appear on top of current navigation stack, please file a bug. at Xamarin.Forms.Platform.iOS.NavigationRenderer+<OnPopViewAsync>d__41.MoveNext () [0x0005e] in C:\BuildAgent2\work\ca3766cfc22354a1\Xamarin.Forms.Platform.iOS\Renderers\NavigationRenderer.cs:291 --- End of inner exception stack trace --- ---> (Inner Exception #0) System.NotSupportedException: Popped page does not appear on top of current navigation stack, please file a bug. at Xamarin.Forms.Platform.iOS.NavigationRenderer+<OnPopViewAsync>d__41.MoveNext () [0x0005e] in C:\BuildAgent2\work\ca3766cfc22354a1\Xamarin.Forms.Platform.iOS\Renderers\NavigationRenderer.cs:291
Comment 15 Guillermo Tinoco 2016-10-24 19:57:08 UTC
you can comment the line 291 at https://github.com/xamarin/Xamarin.Forms/blob/2.3.3/Xamarin.Forms.Platform.iOS/Renderers/NavigationRenderer.cs and set return false, is hack for XF by the moment :/
Comment 16 Pauli Jokela 2016-10-25 13:58:23 UTC
Same issue here. Happens on both iOS 9.3 and 10.
Comment 17 Paulo Ortins 2016-11-17 11:52:24 UTC
A CustomNavigationRenderer did the trick to me:

public class CustomNavigationRenderer : NavigationRenderer
{
	protected override async System.Threading.Tasks.Task<bool> OnPopViewAsync(Page page, bool animated)
	{
		try
		{
			var popped = await base.OnPopViewAsync(page, animated);
			return popped;
		}
		catch (NotSupportedException ex)
		{
			return false;
		}
	}
}
Comment 18 aed 2016-11-17 17:23:13 UTC
@Paulo Ortins - could you provide more context as to how to use the class in your fix?
Comment 19 Samantha Houts [MSFT] 2016-11-18 22:22:41 UTC
The instances of this issue that began with 2.3.3-pre2 will be fixed in 2.3.3 stable. Thank you!
Comment 20 nkallman 2017-02-14 18:46:30 UTC
I am currently using 2.3.3.180 and am still experiencing this issue.
Comment 21 Dzmitry Sharkou 2017-05-27 11:12:46 UTC
Also have been reproduce. Please see comment here https://bugzilla.xamarin.com/show_bug.cgi?id=40286#c20.