{"record":{"id":"9ae7acd0c2d08d3a","repo":"dotnet/maui","slug":"popped-page-does-not-appear-on-top-of-current-navi","errorCode":null,"errorMessage":"Popped page does not appear on top of current navigation stack, please file a bug.","messagePattern":"Popped page does not appear on top of current navigation stack, please file a bug\\.","errorType":"exception","errorClass":"NotSupportedException","httpStatus":null,"severity":"error","filePath":"src/Compatibility/Core/src/GTK/Renderers/NavigationPageRenderer.cs","lineNumber":453,"sourceCode":"\t\t\t\tvar pageRenderer = Platform.GetRenderer(item.Page);\n\t\t\t\tWidget.Add(pageRenderer.Container);\n\n\t\t\t\tpageRenderer.Container.SetSizeRequest(\n\t\t\t\t\t  Allocation.Width,\n\t\t\t\t\t  Allocation.Height);\n\n\t\t\t\tpageRenderer.Container.ShowAll();\n\t\t\t}\n\t\t}\n\n\t\tprivate async Task<bool> PopPageAsync(Page page, bool animated)\n\t\t{\n\t\t\tif (page == null)\n\t\t\t\tthrow new ArgumentNullException(nameof(page));\n\n\t\t\tvar wrapper = _currentStack.Peek();\n\t\t\tif (page != wrapper.Page)\n\t\t\t\tthrow new NotSupportedException(\"Popped page does not appear on top of current navigation stack, please file a bug.\");\n\n\t\t\t_currentStack.Pop();\n\t\t\t(page as IPageController)?.SendDisappearing();\n\n\t\t\tvar target = Platform.GetRenderer(page);\n\t\t\tvar previousPage = _currentStack.Peek().Page;\n\n\t\t\tawait RemovePageAsync(page, false, animated);\n\n\t\t\treturn true;\n\t\t}\n\n\t\tprivate async Task<bool> PopToRootPageAsync(Page page, bool animated)\n\t\t{\n\t\t\tif (page == null)\n\t\t\t\tthrow new ArgumentNullException(nameof(page));\n\n\t\t\t(page as IPageController)?.SendDisappearing();","sourceCodeStart":435,"sourceCodeEnd":471,"githubUrl":"https://github.com/dotnet/maui/blob/f377ff1c5ee04d334d8a925f50c83a6b7afddf03/src/Compatibility/Core/src/GTK/Renderers/NavigationPageRenderer.cs#L435-L471","documentation":"PopPageAsync peeks the top of the renderer's _currentStack and compares the popped Page to that wrapper's Page. A mismatch means the page being popped is not the one on top of the visible stack — a state inconsistency. Like error 105 this is an internal invariant; the message requests a bug report because the framework normally keeps the model and renderer stacks aligned.","triggerScenarios":"A Pop request arrives for a page that is not the current top of the GTK NavigationPageRenderer's stack. Typically caused by overlapping/awaited navigation operations: a second PopPageAsync starts before the first completes, or OnPop fires for a page that was already removed.","commonSituations":"Double-tapping a back button that triggers two PopAsync calls. Awaiting a Push/Pop and then immediately popping again. Hardware back-key handling that races with programmatic navigation on GTK.","solutions":["Guard against re-entrant pops: track an in-flight flag and ignore a Pop while another navigation is completing.","Debounce or disable the back control until the awaited PopAsync/PushAsync returns.","If reproducible deterministically, report it as a framework bug with the exact sequence — the stacks should not desync under correct use."],"exampleFix":"// before\nasync void OnBack() => await Navigation.PopAsync(); // double-tap -> second pop desyncs\n\n// after\nbool _navigating;\nasync void OnBack()\n{\n    if (_navigating) return;\n    _navigating = true;\n    try { await Navigation.PopAsync(); }\n    finally { _navigating = false; }\n}","handlingStrategy":"try-catch","validationCode":"// Prevent re-entrant pops with a flag.\nstatic bool _popping;\nasync Task SafePop()\n{\n    if (_popping) return;\n    _popping = true;\n    try { await Navigation.PopAsync(); }\n    finally { _popping = false; }\n}","typeGuard":null,"tryCatchPattern":"try { await Navigation.PopAsync(); }\ncatch (NotSupportedException ex) when (ex.Message.Contains(\"navigation stack\"))\n{ /* navigation desync; reset state and skip */ }","preventionTips":["Debounce back-button handling.","Await each navigation to completion before starting the next.","Disable navigation UI during in-flight transitions."],"tags":["gtk","navigationpage","concurrency","invariant","renderer","maui"],"backgroundTag":null,"analyzedSha":"f377ff1c5ee04d334d8a925f50c83a6b7afddf03","analyzedAt":"2026-08-13T14:26:18.069Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}