{"record":{"id":"6d05cfa9713cc5ca","repo":"dotnet/maui","slug":"popped-page-does-not-appear-on-top-of-current-navi-6d05cf","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":"critical","filePath":"src/Compatibility/Core/src/iOS/Renderers/NavigationRenderer.cs","lineNumber":336,"sourceCode":"\n\t\t\t_ignorePopCall = false;\n\t\t\tvar success = !await task;\n\n\t\t\tUpdateToolBarVisible();\n\t\t\treturn success;\n\t\t}\n\n\t\tprotected virtual async Task<bool> OnPopViewAsync(Page page, bool animated)\n\t\t{\n\t\t\tif (_ignorePopCall)\n\t\t\t\treturn true;\n\n\t\t\tvar renderer = Platform.GetRenderer(page);\n\t\t\tif (renderer == null || renderer.ViewController == null)\n\t\t\t\treturn false;\n\n\t\t\tif (page != ((ParentingViewController)TopViewController).Child)\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\tvar task = GetAppearedOrDisappearedTask(page);\n\n\t\t\tUIViewController poppedViewController;\n\t\t\t_ignorePopCall = true;\n\t\t\tpoppedViewController = base.PopViewController(animated);\n\n\t\t\tvar actuallyRemoved = poppedViewController == null ? true : !await task;\n\t\t\t_ignorePopCall = false;\n\n\t\t\tpoppedViewController?.Dispose();\n\n\t\t\tUpdateToolBarVisible();\n\t\t\treturn actuallyRemoved;\n\t\t}\n\n\t\tprotected virtual async Task<bool> OnPushAsync(Page page, bool animated)\n\t\t{","sourceCodeStart":318,"sourceCodeEnd":354,"githubUrl":"https://github.com/dotnet/maui/blob/f377ff1c5ee04d334d8a925f50c83a6b7afddf03/src/Compatibility/Core/src/iOS/Renderers/NavigationRenderer.cs#L318-L354","documentation":"OnPopViewAsync verifies that the page being popped matches the Child of the current TopViewController (a ParentingViewController). If they differ, the platform's notion of the top of the stack disagrees with the MAUI logical stack - a state corruption. It throws NotSupportedException asking the user to file a bug because this is an unexpected internal-state mismatch.","triggerScenarios":"A PopAsync/PopAsync(page) call where the requested page is not actually the top of the iOS view-controller stack; concurrent/mismatched Push/Pop/InsertPageBefore/RemovePage calls; manually calling base.PopViewController elsewhere; custom navigation that mutates ViewControllers directly.","commonSituations":"Mixing NavigationPage methods with custom UINavigationController manipulation; calling RemovePage during an in-flight Pop; navigation triggered from multiple threads; handler/renderer version mismatches after an upgrade.","solutions":["Avoid mixing NavigationPage.PushAsync/PopAsync with direct UINavigationController calls.","Serialise navigation operations (await each Push/Pop) to prevent overlapping mutations.","Ensure RemovePage/InsertPageBefore are not called while a Pop is in flight.","If reproducible, report with the exact navigation sequence and MAUI version."],"exampleFix":"// before (concurrent navigation)\n_ = Navigation.PopAsync();\nNavigation.InsertPageBefore(other, current);\n\n// after (serialised)\nawait Navigation.PopAsync();\nNavigation.InsertPageBefore(other, current);","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try { await Navigation.PopAsync(animated); }\ncatch (NotSupportedException ex) when (ex.Message.Contains(\"navigation stack\"))\n{\n    // stack desync - resync by reading Navigation.NavigationStack\n    // and avoid concurrent navigation\n}","preventionTips":["Await each PushAsync/PopAsync before issuing the next.","Never mix NavigationPage APIs with direct UINavigationController calls.","Avoid calling RemovePage during an in-flight Pop."],"tags":["notsupportedexception","ios","navigation","stack-corruption","race"],"backgroundTag":null,"analyzedSha":"f377ff1c5ee04d334d8a925f50c83a6b7afddf03","analyzedAt":"2026-08-13T14:26:18.069Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}