WinUI: Pushing the same page instance onto a NavigationPage after popping it causes a crash.
Keflon opened this issue ยท 24 comments
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
Updated the title. MAUI uses WinUI, not UWP.
verified repro on windows using above repro project.
Any update on this issue? I'm running into the same exception when trying to create a SwapChainPanel custom renderer in WinUI.
The issue with SwapChainPanel seems unrelated to this issue. The issue was caused by Maui's Background assignment which is not allowed on WinUI's SwapChainPanel. I had to add an empty property mapping handler for the Background property via the ModifyMapping method to prevent the crash.
@mlancione Would you be willing to share the code fragment that you implemented as a workaround with Background?
@dgerding In my Maui custom View constructor I added this:
this.propertyMapper = new PropertyMapper<View>();
var overrides = GetRendererOverrides<CustomView>();
overrides.ModifyMapping( "Background",
( handler, view, act ) =>
{
} );
We've moved this issue to the Backlog milestone. This means that it is not going to be worked on for the coming release. We will reassess the backlog following the current release and consider this item at that time. To learn more about our issue management process and to have better expectation regarding different types of issues you can read our Triage Process.
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 PlatformView
s 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.
Will do more tests but, cannot reproduce it with the current main branch (7.0.200).
I just installed VS 17.4.5 which comes with a new MAUI version:
maui-windows 7.0.59/7.0.100 VS 17.4.33403.182
The issue still occurs. See screencast:
How to reproduce:
- Clone jbe2277/waf@ef83760 or latest master
- Open
./src/NewsReader/NewsReader.sln
- Set
NewsReader.MauiSystem
as startup project - Run it for Windows (error comes in Debug and Release config)
- Navigate to the page
Add Feed
2x times. The second time the error comes.
Note:
This issue occurs with the AddEditFeedView
page. But it does not occur when I navigate multiple times to the SettingsView
page. The notable difference is:
AddEditFeedView
is aContentPage
SettingsView
is aTabbedPage
Will do more tests but, cannot reproduce it with the current main branch (7.0.200).
https://github.com/drasticactions/MauiRepros/tree/main/MauiReusePageBug
On the Current MAUI stable and main, it throws with the same errors listed above.
I can confirm what drasticactions reported 2 weeks ago with the exact same repository and we can reproduce it across multiple machines as well.
Really disheartening to see this being pushed back to the backlog.
How do you handle the NavigationFailed
event to get the causing exception? I am having the same issue with MAUI Blazor: tapping a Blazor button to push another ContentPage, then press Back and the app crashes.
@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.
There are a lot of problems with navigation in MAUI for WinUI, and no problems for Android & iOS & macOS. So we rejected winui support. I waste a lot of time...
await Shell.Current.GoToAsync($"{nameof(MapPage)}") : Exception = {"Catastrophic failure (0x8000FFFF (E_UNEXPECTED))"} for WinUI only
Page2: await Shell.Current.GoToAsync($"///home") or "//home" - it works for Android & iOS & macOS, WinUI - does not. This is a basic thing that is not tested at all ?! Where are public MS MAUI unit tests?
If you pay me, I will make basic samples that demonstrate the problems for WinUI only.
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.
Mine also happen when a collectionview
bind to list property WINUI
Error:
No installed components were detected.
<CollectionView
x:Name="PetAvatarCollectionView"
ItemsLayout="HorizontalList"
ItemsSource="{x:Binding UserProfile.UserPetProfile}">
<CollectionView.ItemTemplate>
<DataTemplate x:DataType="app:UserPetProfile">
<toolkit:AvatarView
CornerRadius="35"
HeightRequest="65"
ImageSource="{x:Binding PetImageUrl}"
WidthRequest="65" />
</DataTemplate>
</CollectionView.ItemTemplate>
</CollectionView>
namespace petaverse.frontend.mauiapp;
public partial class UserProfile : BaseModel
{
#region [ Properties ]
[ObservableProperty]
string guid;
[ObservableProperty]
string email;
[ObservableProperty]
string userName;
[ObservableProperty]
string phoneNumber;
[ObservableProperty]
string avatarUrl;
[ObservableProperty]
string bio;
[ObservableProperty]
bool gender;
[ObservableProperty]
string countryName;
[ObservableProperty]
string city;
[ObservableProperty]
string district;
[ObservableProperty]
string ward;
[ObservableProperty]
List<UserPetProfile> userPetProfile = new();
#endregion
}
public partial class UserPetProfile : BaseModel
{
[ObservableProperty]
string petImageUrl;
}
As this issue was marked fixed months ago, I was curious if anyone has confirmed it fixed using .net 8 preview?
Cant update to .net 8 myself do to other problems, but seems to me this is a critical issue yet not convinced it was addressed in the closing issue.
Hello lovely human, thank you for your comment on this issue. Because this issue has been closed for a period of time, please strongly consider opening a new issue linking to this issue instead to ensure better visibility of your comment. Thank you!