maui: WinUI: Pushing the same page instance onto a NavigationPage after popping it causes a crash.
Description
UWP only: Push a ContentPage onto a NavigationPage. Pop the page, using the back button. Push the same page again. Exception = {“Catastrophic failure (0x8000FFFF (E_UNEXPECTED))”}
Minimal repro: https://github.com/Keflon/MauiNavigationBugRepro
Steps to Reproduce
- Create a MAUI app.
- Make this change in App.xaml.cs:
public App()
{
InitializeComponent();
//MainPage = new AppShell();
MainPage = new NavigationPage(new MainPage());
}
In MainPage.xaml.cs add the following, where _childPage is set to an instance of a Maui Page
private void OnNavigateClicked(object sender, EventArgs e)
{
App.Current.MainPage.Navigation.PushAsync(_childPage);
}
- Add a Button in MainPage.xaml that raises the click handler.
<Button
x:Name="NavigateBtn"
Text="UWP Navigate Bug"
SemanticProperties.Hint="Demonstrates a UWP navigation bug"
Clicked="OnNavigateClicked"
HorizontalOptions="Center" />
- Click the Button.
- Press the back button.
- Click the button.
- Notice UWP crashes with Exception = {“Catastrophic failure (0x8000FFFF (E_UNEXPECTED))”}
Version with bug
6.0 (current)
Last version that worked well
Release Candidate 3 (current)
Affected platforms
Windows
Affected platform versions
Latest
Did you find any workaround?
No
Relevant log output
No response
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Reactions: 10
- Comments: 24 (6 by maintainers)
Updated the title. MAUI uses WinUI, not UWP.
Any update on this issue? I’m running into the same exception when trying to create a SwapChainPanel custom renderer in WinUI.
Please, fix this bug.
It blocks our migration from Xamarin to MAUI for the Windows support. We have not found a workaround to overcome this crash.
@PureWeen Hi, I don’t know where to put the code in to log it. That’s my question. How do I handle it or get the underlying exception that causes it? Right now all I get is the “Catastrophic failure …” exception from the OP post.
Okay, I made this more accessible to repro.
If you replace the
App.Current.MainPagewith an existing page, you can get the sameNo installed components were detectedto throw.Notes on this so far:
The Unhandled exception is thrown because “NavigationFailed” is not handled in the MAUI
NavigationRootView. If you handle that, you can continue down the stack to see the “real” exception.I’m not sure how the
PlatformViews are generally handled in MAUI, but I think when you navigate back and forth, the handlers are destroyed and recreated, and somewhere in there, it can’t recreate the new session. Still need to look into that.