Bug 40286 - Receiving Popped Page does not appear on top of current navigation stack error
Summary: Receiving Popped Page does not appear on top of current navigation stack error
Status: RESOLVED FIXED
Alias: None
Product: Forms
Classification: Xamarin
Component: iOS ()
Version: 2.1.0
Hardware: Macintosh Mac OS
: --- normal
Target Milestone: ---
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2016-04-11 21:45 UTC by Rich Seviora
Modified: 2017-05-27 11:11 UTC (History)
14 users (show)

Tags:
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:
Status:
RESOLVED FIXED

Description Rich Seviora 2016-04-11 21:45:14 UTC
Receiving the following exception when awaiting a Task that resolves when the page disappears.

---> (Inner Exception #0) System.NotSupportedException: Popped page does not appear on top of
 current navigation stack, please file a bug.

On inspecting the stack, I can see that the dismissed page is still present in the navigation stack property of the NavigationPage I'm using.

I can't reliably reproduce the bug; sometimes the error will happen when the page is dismissed, sometimes it won't.

Exception Log Follows:

--- End of stack trace from previous location where exception was thrown ---
  at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in /Users/builder/data/lanes/3051/5f11db87/source/maccore/_build/Library/Frameworks/Xamarin.iOS.framework/Versions/git/src/mono/external/referencesource/mscorlib/system/runtime/exceptionservices/exceptionservicescommon.cs:143 
  at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) [0x00047] in /Users/builder/data/lanes/3051/5f11db87/source/maccore/_build/Library/Frameworks/Xamarin.iOS.framework/Versions/git/src/mono/external/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:201 
  at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) [0x0002e] in /Users/buil
der/data/lanes/3051/5f11db87/source/maccore/_build/Library/Frameworks/Xamarin.iOS.framework/Versions/git/src/mono/external/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:170 
  at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) [0x0000b] in /Users/builder/data/lanes/3051/5f11db87/source/maccore/_build/Library/Frameworks/Xamarin.iOS.framework/Versions/git/src/mono/external/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:142 
  at System.Runtime.CompilerServices.TaskAwaiter`1[TResult].GetResult () [0x00000] in /Users/builder/data/lanes/3051/5f11db87/source/maccore/_build/Library/Frameworks/Xamarin.iOS.framework/Versions/git/src/mono/external/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:372 
  at Xamarin.Forms.NavigationPage+<PopAsyncInner>d__69.MoveNext () [0x000ec] in <filename unknown>:0 
--- End of stack trace from previous location where exception was thrown ---
  at System.Runtime.Exceptio
nServices.ExceptionDispatchInfo.Throw () [0x0000c] in /Users/builder/data/lanes/3051/5f11db87/source/maccore/_build/Library/Frameworks/Xamarin.iOS.framework/Versions/git/src/mono/external/referencesource/mscorlib/system/runtime/exceptionservices/exceptionservicescommon.cs:143 
  at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) [0x00047] in /Users/builder/data/lanes/3051/5f11db87/source/maccore/_build/Library/Frameworks/Xamarin.iOS.framework/Versions/git/src/mono/external/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:201 
  at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) [0x0002e] in /Users/builder/data/lanes/3051/5f11db87/source/maccore/_build/Library/Frameworks/Xamarin.iOS.framework/Versions/git/src/mono/external/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:170 
  at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Th
reading.Tasks.Task task) [0x0000b] in /Users/builder/data/lanes/3051/5f11db87/source/maccore/_build/Library/Frameworks/Xamarin.iOS.framework/Versions/git/src/mono/external/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:142 
  at System.Runtime.CompilerServices.TaskAwaiter`1[TResult].GetResult () [0x00000] in /Users/builder/data/lanes/3051/5f11db87/source/maccore/_build/Library/Frameworks/Xamarin.iOS.framework/Versions/git/src/mono/external/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:372 
  at Xamarin.Forms.NavigationPage+<PopAsync>d__68.MoveNext () [0x001b9] in <filename unknown>:0 <---
<---
Comment 1 Samantha Houts [MSFT] 2016-04-24 21:11:33 UTC
Thank you for taking the time to submit the bug. We tried to reproduce the issue you reported but were unable given the description. If you could please attach a reproduction to the bug by starting with a clean Xamarin.Forms project and adding just the code necessary to demonstrate the issue, we would very much appreciate it. 

For your convenience, we have created some reproduction best practices viewable here: https://gist.github.com/jassmith/92405c300e54a01dcc6d

Warm regards,
Xamarin Forms Team
Comment 2 Rich Seviora 2016-04-25 16:58:32 UTC
Could you give me some guidance on how I would identify how this problem occurs? I'm not doing anything unusual with the stack itself. The only thing that comes to mind is that the navigation page is being popped within a task, however I am awaiting it so I'd imagine that shouldn't be a concern.
Comment 3 Samantha Houts [MSFT] 2016-05-02 22:30:03 UTC
It's difficult to say without seeing the actual project in question. We would need to see if there is some factor in your codebase that might lead us to the issue. If you have a code sample or project that you could share with us, we would be better able to provide guidance. 

Thank you!
Comment 4 Teo 2016-10-12 11:21:55 UTC
Also happening to me as well, seems similar to https://bugzilla.xamarin.com/show_bug.cgi?id=26316 (commented there with same info): 



Details:
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 5 Rui Marinho 2016-10-12 22:29:20 UTC
Hi, is it possible to have a reproducion?
Comment 6 Pauli Jokela 2016-10-25 14:40:58 UTC
I'm seeing the same thing, even with an empty ContentPage(). Happens every time I go back (pop). I've checked the navigation stack, and it looks normal.

I wasn't even aware of this exception before installing HockeyApp, since Xamarin wasn't reporting it. After adding HockeyApp, but app now crashes with the exception in question, but only in debug builds.

From what I can tell, this should be reproducible by creating a new Forms app, updating to latest Xamarin.Forms prerelease version, installing HockeyApp and using a NavigationPage to push and pop a view.
Comment 7 tim.ahrentlov 2016-11-09 15:22:42 UTC
I'm seeing this as well:

https://dl.dropboxusercontent.com/u/2600860/Screen%20Shot%202016-11-09%20at%2016.18.51.png
Comment 8 Pauli Jokela 2016-11-09 15:23:39 UTC
It's apparently only happening on Xamarin Forms prerelease, so switching back to stable fixed it for me.
Comment 9 PKirkley 2016-11-14 14:57:52 UTC
I was also getting exactly same issue with latest 2.3.3.166-pre4. Switching back to stable 2.3.2.127 fixes this issue.

(Exception:
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 10 Samantha Houts [MSFT] 2016-11-18 22:22:04 UTC
The instances of this issue that began with 2.3.3-pre2 will be fixed with 2.3.3 stable. Thank you!
Comment 11 ischmitz 2016-11-22 22:46:30 UTC
I'm experiencing the same behavior. Reverting to 2.3.2.127 fixed the issue for me.
Comment 12 Rui Marinho 2016-11-23 15:26:47 UTC
This is fixed in 2.3.3 stable.
Comment 13 Simon Christiansen 2016-12-12 16:48:22 UTC
I am still getting this error in 2.3.3.175. The error happens when awaiting a PopAsync() call after manually dismissing a page on the device. The dismissed page is still present in the NavigationStack property of the NavigationPage, so it seems that the stack somehow becomes corrupted. The error only happens on iOS.
Comment 16 Tim Holzkämper 2017-03-15 08:12:48 UTC
This bug still occurs in the versions:

2.3.3.180
2.3.3.193
2.3.4.192-pre2

I don't know about other versions. These are the ones I've tested.
Comment 17 Rui Marinho 2017-03-15 11:10:54 UTC
The exception?
Comment 18 Tim Holzkämper 2017-03-15 12:39:18 UTC
[NotSupportedException: Popped page does not appear on top of current navigation stack, please file a bug.]
 Xamarin.Forms.Platform.iOS.NavigationRenderer+<OnPopViewAsync>d__43.MoveNext() in C:\BuildAgent3\work\ca3766cfc22354a1\Xamarin.Forms.Platform.iOS\Renderers\NavigationRenderer.cs:305
    --- End of stack trace from previous location where exception was thrown ---
 System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() in /Users/builder/data/lanes/3969/7beaef43/source/xamarin-macios/_ios-build/Library/Frameworks/Xamarin.iOS.framework/Versions/git/src/mono/mcs/class/referencesource/mscorlib/system/runtime/exceptionservices/exceptionservicescommon.cs:143
 System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(System.Threading.Tasks.Task task) in /Users/builder/data/lanes/3969/7beaef43/source/xamarin-macios/_ios-build/Library/Frameworks/Xamarin.iOS.framework/Versions/git/src/mono/mcs/class/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:187
 System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(System.Threading.Tasks.Task task) in /Users/builder/data/lanes/3969/7beaef43/source/xamarin-macios/_ios-build/Library/Frameworks/Xamarin.iOS.framework/Versions/git/src/mono/mcs/class/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:156
 System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd(System.Threading.Tasks.Task task) in /Users/builder/data/lanes/3969/7beaef43/source/xamarin-macios/_ios-build/Library/Frameworks/Xamarin.iOS.framework/Versions/git/src/mono/mcs/class/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:128
 System.Runtime.CompilerServices.TaskAwaiter`1[TResult].GetResult() in /Users/builder/data/lanes/3969/7beaef43/source/xamarin-macios/_ios-build/Library/Frameworks/Xamarin.iOS.framework/Versions/git/src/mono/mcs/class/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:357
 Xamarin.Forms.NavigationPage+<Xamarin-Forms-INavigationPageController-PopAsyncInner>d__63.MoveNext() in C:\BuildAgent3\work\ca3766cfc22354a1\Xamarin.Forms.Core\NavigationPage.cs:250
    --- End of stack trace from previous location where exception was thrown ---
 System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() in /Users/builder/data/lanes/3969/7beaef43/source/xamarin-macios/_ios-build/Library/Frameworks/Xamarin.iOS.framework/Versions/git/src/mono/mcs/class/referencesource/mscorlib/system/runtime/exceptionservices/exceptionservicescommon.cs:143
 System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(System.Threading.Tasks.Task task) in /Users/builder/data/lanes/3969/7beaef43/source/xamarin-macios/_ios-build/Library/Frameworks/Xamarin.iOS.framework/Versions/git/src/mono/mcs/class/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:187
 System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(System.Threading.Tasks.Task task) in /Users/builder/data/lanes/3969/7beaef43/source/xamarin-macios/_ios-build/Library/Frameworks/Xamarin.iOS.framework/Versions/git/src/mono/mcs/class/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:156
 System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd(System.Threading.Tasks.Task task) in /Users/builder/data/lanes/3969/7beaef43/source/xamarin-macios/_ios-build/Library/Frameworks/Xamarin.iOS.framework/Versions/git/src/mono/mcs/class/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:128
 System.Runtime.CompilerServices.TaskAwaiter`1[TResult].GetResult() in /Users/builder/data/lanes/3969/7beaef43/source/xamarin-macios/_ios-build/Library/Frameworks/Xamarin.iOS.framework/Versions/git/src/mono/mcs/class/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:357
 Xamarin.Forms.NavigationPage+<PopAsync>d__38.MoveNext() in C:\BuildAgent3\work\ca3766cfc22354a1\Xamarin.Forms.Core\NavigationPage.cs:131
    --- End of stack trace from previous location where exception was thrown ---
 System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() in /Users/builder/data/lanes/3969/7beaef43/source/xamarin-macios/_ios-build/Library/Frameworks/Xamarin.iOS.framework/Versions/git/src/mono/mcs/class/referencesource/mscorlib/system/runtime/exceptionservices/exceptionservicescommon.cs:143
 System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(System.Threading.Tasks.Task task) in /Users/builder/data/lanes/3969/7beaef43/source/xamarin-macios/_ios-build/Library/Frameworks/Xamarin.iOS.framework/Versions/git/src/mono/mcs/class/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:187
 System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(System.Threading.Tasks.Task task) in /Users/builder/data/lanes/3969/7beaef43/source/xamarin-macios/_ios-build/Library/Frameworks/Xamarin.iOS.framework/Versions/git/src/mono/mcs/class/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:156
 System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd(System.Threading.Tasks.Task task) in /Users/builder/data/lanes/3969/7beaef43/source/xamarin-macios/_ios-build/Library/Frameworks/Xamarin.iOS.framework/Versions/git/src/mono/mcs/class/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:128
 System.Runtime.CompilerServices.TaskAwaiter`1[TResult].GetResult() in /Users/builder/data/lanes/3969/7beaef43/source/xamarin-macios/_ios-build/Library/Frameworks/Xamarin.iOS.framework/Versions/git/src/mono/mcs/class/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:357
 Azura.ViewModels.DevicePageViewModel+<>c+<<Cancel>b__69_0>d.MoveNext() in C:\Users\tholzkaemper.DOEGEL\Documents\Azura\Azura\Azura\Azura\ViewModels\DevicePageViewModel.cs:586
    --- End of stack trace from previous location where exception was thrown ---
    (wrapper managed-to-native) UIKit.UIApplication:UIApplicationMain (int,string[],intptr,intptr)
 UIKit.UIApplication.Main(System.String[] args, System.IntPtr principal, System.IntPtr delegate) in /Users/builder/data/lanes/3969/7beaef43/source/xamarin-macios/src/UIKit/UIApplication.cs:79
 UIKit.UIApplication.Main(System.String[] args, System.String principalClassName, System.String delegateClassName) in /Users/builder/data/lanes/3969/7beaef43/source/xamarin-macios/src/UIKit/UIApplication.cs:63
 Azura.iOS.Application.Main(System.String[] args) in C:\Users\tholzkaemper.DOEGEL\Documents\Azura\Azura\Azura\Azura.iOS\Main.cs:22
Comment 19 Rui Marinho 2017-03-15 14:32:37 UTC
Tim can you provide me a sample Project please?! 

Thanks
Comment 20 Dzmitry Sharkou 2017-05-27 11:11:11 UTC
Have the same issue on iPad (3rd gen, Wi-Fi+LTE AT&T) iOS 9.3.5. Used Xamarin.Forms version is 2.3.4.231.

I can also attach full json file of exception (from Visual Studio Mobile Center) wil more details.

Full stack of this issue is:

NavigationService+<PopAsync>c__async1.MoveNext ()
System.NotSupportedException: Popped page does not appear on top of current navigation stack, please file a bug.

NavigationRenderer+<OnPopViewAsync>d__43.MoveNext ()
TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task )
TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task )
TaskAwaiter`1[TResult].GetResult ()
NavigationPage+<Xamarin-Forms-INavigationPageController-PopAsyncInner>d__63.MoveNext ()
TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task )
TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task )
TaskAwaiter`1[TResult].GetResult ()
NavigationPage+<PopAsync>d__38.MoveNext ()
TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task )
TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task )
TaskAwaiter`1[TResult].GetResult ()
NavigationService+<PopAsync>c__async1.MoveNext ()
TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task )
TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task )
TaskAwaiter.GetResult ()
ScheduleWorkShiftListPage+<OnListItemSelected>c__async0.MoveNext ()
AsyncMethodBuilderCore.<ThrowAsync>m__0 (System.Object )
UIKitSynchronizationContext+<Post>c__AnonStorey0.<>m__0 ()
NSAsyncActionDispatcher.Apply ()
(wrapper managed-to-native) UIKit.UIApplication:UIApplicationMain (int,string[],intptr,intptr)
UIApplication.Main (System.String[] , System.String , System.String )
Application.Main (System.String[] args)