-
Notifications
You must be signed in to change notification settings - Fork 1.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
App crashes when navigating from TabbedPage to another TabbedPage #22131
Comments
Verified this issue with Visual Studio 17.10 Preview 5 (8.0.21&8.0.7). Can repro on windows platform with sample project. Android platform works fine. |
/similarissues |
Hi I'm an AI powered bot that finds similar issues based off the issue title. Please view the issues below to see if they solve your problem, and if the issue describes your problem please consider closing this one and thumbs upping the other issue to help us prioritize it. Thank you! Open similar issues:
Closed similar issues:
|
Idk if it is of any help but we have testers who can switch between tabs just fine all day long without it crashing and then we have testers that it consistently crashes on when changing tabs more than once. We have looked at every difference in the machines that we can think of like font scaling, light and dark themes, Windows versions, etc and the only difference we can say for sure that we see is the ones using Windows Enterprise it does not crash on but the ones using Windows Pro it crashes on. Maybe that is totally a coincidence but we have been trying to find some reason for it not crashing for some and crashing for others. I just wanted to share in case it helps speed up a fix for this. |
Duplicate of #22790 |
### Description of Change Fixes a long-standing crash when navigating pages: 1. Manually clear the `ContentPresenter.Content` property. When navigating pages it was discovered that the `Content` property of the `ContentPresenter` sometimes was not being detached from the parent `ContentPresenter` (the `ContentPresenter` itself does detach from the Page). A workaround for this was to manually clear the `Content` property. **The actual cause of this bug:** I suspect that something causing the lifecycle tracking to be messed up. I'm still not sure what this is, but for now this will help our customers more than nothing. ## Workaround The following can be used as a workaround. Place it in the `Loaded` event for your `AppShell`: ```csharp private void AppShell_Loaded(object? sender, EventArgs e) { Loaded -= AppShell_Loaded; #if WINDOWS if (Handler != null && Handler.PlatformView is ShellView shellView && shellView.Content is MauiNavigationView nv && nv.Content is Microsoft.UI.Xaml.Controls.Frame frame) { frame.Navigating += (s, e) => { if (frame.Content is Microsoft.UI.Xaml.Controls.Page page) { page.Unloaded += PageUnloaded; void PageUnloaded(object sender, Microsoft.UI.Xaml.RoutedEventArgs e) { page.Unloaded -= PageUnloaded; if (page.Content is Microsoft.UI.Xaml.Controls.ContentPresenter presenter) { presenter.Content = null; } }; } }; } #endif } ``` ### Issues Fixed Fixes #22790 #18441 #22131
Description
I'm using
MainPage = new NavigationPage(new MainPage());
instead ofAppShell()
The app crashes when navigating from one TabbedPage to another.Exception:
Microsoft.UI.Xaml.Controls.Frame.NavigationFailed was unhandled.
Example apps: MauiAppTabbedPage.zip
Recording.2024-04-30.124611.mp4
Steps to Reproduce
No response
Link to public reproduction project repository
No response
Version with bug
8.0.21 SR4.1
Is this a regression from previous behavior?
Yes, this used to work in Xamarin.Forms
Last version that worked well
Unknown/Other
Affected platforms
Windows
Affected platform versions
WinUI
Did you find any workaround?
No response
Relevant log output
The text was updated successfully, but these errors were encountered: