{"record":{"id":"bd45b13fdb4f8f56","repo":"dotnet/maui","slug":"poptorootasync-is-not-supported-globally-on-gtk-p","errorCode":null,"errorMessage":"PopToRootAsync is not supported globally on GTK, please use a NavigationPage.","messagePattern":"PopToRootAsync is not supported globally on GTK, please use a NavigationPage\\.","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"src/Compatibility/Core/src/GTK/Platform.cs","lineNumber":218,"sourceCode":"\t\t\t\t\t\t\tpage.ShowAll();\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tDisposeModelAndChildrenRenderers(modal);\n\t\t\t});\n\n\t\t\treturn Task.FromResult<Page>(modal);\n\t\t}\n\n\t\tTask INavigation.PopToRootAsync()\n\t\t{\n\t\t\treturn ((INavigation)this).PopToRootAsync(true);\n\t\t}\n\n\t\tTask INavigation.PopToRootAsync(bool animated)\n\t\t{\n\t\t\tthrow new InvalidOperationException(\"PopToRootAsync is not supported globally on GTK, please use a NavigationPage.\");\n\t\t}\n\n\t\tTask INavigation.PushAsync(Page root)\n\t\t{\n\t\t\treturn ((INavigation)this).PushAsync(root, true);\n\t\t}\n\n\t\tTask INavigation.PushAsync(Page root, bool animated)\n\t\t{\n\t\t\tthrow new InvalidOperationException(\"PushAsync is not supported globally on GTK, please use a NavigationPage.\");\n\t\t}\n\n\t\tTask INavigation.PushModalAsync(Page modal)\n\t\t{\n\t\t\treturn ((INavigation)this).PushModalAsync(modal, true);\n\t\t}\n\n\t\tTask INavigation.PushModalAsync(Page modal, bool animated)","sourceCodeStart":200,"sourceCodeEnd":236,"githubUrl":"https://github.com/dotnet/maui/blob/f377ff1c5ee04d334d8a925f50c83a6b7afddf03/src/Compatibility/Core/src/GTK/Platform.cs#L200-L236","documentation":"The GTK global Platform implements INavigation but only manages a modal stack, not a page navigation stack. PopToRootAsync is a stack-level operation, so the global Platform throws rather than silently doing nothing. The intended host for non-modal navigation is a NavigationPage, which carries its own renderer-backed stack (NavigationPageRenderer). This is a hard platform limitation of the GTK backend, not a runtime misconfiguration.","triggerScenarios":"Calling Navigation.PopToRootAsync() (or the bool overload) on a Page whose Navigation property resolves to the global GTK Platform instead of a NavigationPage. Concretely: Application.MainPage is set to a plain ContentPage/CarouselPage/TabbedPage (not a NavigationPage), and code calls await Navigation.PopToRootAsync() on GTK.","commonSituations":"Porting an app to the GTK backend that worked on iOS/Android where the global host exposes a full stack. Setting MainPage to a bare ContentPage and then calling Navigation methods. Code shared across platforms that assumes global navigation support.","solutions":["Wrap your root page in a NavigationPage: Application.Current.MainPage = new NavigationPage(rootPage); then call PopToRootAsync on the NavigationPage, not the global Navigation.","If you need root-level navigation, restructure so the page you navigate from is a child of a NavigationPage, and use that page's Navigation property (which resolves to the NavigationPage).","If you only ever use modals on GTK, switch the call to Navigation.PopModalAsync() and PushModalAsync() which the global Platform does support."],"exampleFix":"// before\nApplication.Current.MainPage = new ContentPage();\nawait somePage.Navigation.PopToRootAsync(); // throws on GTK\n\n// after\nApplication.Current.MainPage = new NavigationPage(new ContentPage());\nawait somePage.Navigation.PopToRootAsync(); // resolved by NavigationPageRenderer","handlingStrategy":"validation","validationCode":"// Before calling PopToRootAsync on GTK, ensure a NavigationPage hosts the page.\nbool HasNavigationPageHost(Page p) =>\n    p?.Parent is NavigationPage ||\n    (p?.Navigation?.NavigationStack?.Count ?? 0) >= 0 && p.Parent is NavigationPage;\n\nif (HasNavigationPageHost(currentPage))\n    await currentPage.Navigation.PopToRootAsync();","typeGuard":"static bool IsNavigationPageRoot(Page root) => root is NavigationPage;","tryCatchPattern":null,"preventionTips":["Always set MainPage to a NavigationPage when you need non-modal navigation.","On GTK, treat the global Navigation as modal-only.","Centralize navigation in a service that knows the platform capability."],"tags":["gtk","navigation","navigationpage","platform-limitation","maui","xamarin"],"backgroundTag":null,"analyzedSha":"f377ff1c5ee04d334d8a925f50c83a6b7afddf03","analyzedAt":"2026-08-13T14:26:18.069Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}