Skip to content
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

WinUI: Pushing the same page instance onto a NavigationPage after popping it causes a crash. #7698

Closed
Keflon opened this issue Jun 2, 2022 · 24 comments · Fixed by #14262
Closed
Assignees
Labels
area-navigation NavigationPage fixed-in-8.0.0-preview.6.8686 Look for this fix in 8.0.0-preview.6.8686! migration-compatibility Xamarin.Forms to .NET MAUI Migration, Upgrade Assistant, Try-Convert p/1 Work that is important, and has been scheduled for release in this or an upcoming sprint platform/windows 🪟 t/bug Something isn't working

Comments

@Keflon
Copy link

Keflon commented Jun 2, 2022

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

  1. Create a MAUI app.
  2. 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);
}
  1. 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" />
  1. Click the Button.
  2. Press the back button.
  3. Click the button.
  4. 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

@Keflon Keflon added s/needs-verification Indicates that this issue needs initial verification before further triage will happen t/bug Something isn't working labels Jun 2, 2022
@drasticactions drasticactions changed the title UWP: Pushing the same page instance onto a NavigationPage after popping it causes a crash. WinUI: Pushing the same page instance onto a NavigationPage after popping it causes a crash. Jun 2, 2022
@drasticactions
Copy link
Contributor

Updated the title. MAUI uses WinUI, not UWP.

@Eilon Eilon added the area-navigation NavigationPage label Jun 2, 2022
@kristinx0211 kristinx0211 added s/verified Verified / Reproducible Issue ready for Engineering Triage and removed s/needs-verification Indicates that this issue needs initial verification before further triage will happen labels Jun 7, 2022
@kristinx0211
Copy link

verified repro on windows using above repro project.

@mlancione
Copy link

Any update on this issue? I'm running into the same exception when trying to create a SwapChainPanel custom renderer in WinUI.

@mlancione
Copy link

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.

@dgerding
Copy link

@mlancione Would you be willing to share the code fragment that you implemented as a workaround with Background?

@mlancione
Copy link

@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 ) =>
        {
        } );

@ghost
Copy link

ghost commented Nov 14, 2022

image
I got same error using a singleton page and then navigating back and forth.

@SqueakyBed
Copy link

Same error using Maui Blazor App too. It crashes as soon as I push the settings page. If I remove the button from the xaml it works just fine!

image

image

image

@samhouts samhouts added the p/1 Work that is important, and has been scheduled for release in this or an upcoming sprint label Feb 3, 2023
@mattleibow mattleibow added this to the Backlog milestone Feb 3, 2023
@ghost
Copy link

ghost commented Feb 3, 2023

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.

@samhouts samhouts added p/1 Work that is important, and has been scheduled for release in this or an upcoming sprint and removed p/1 Work that is important, and has been scheduled for release in this or an upcoming sprint labels Feb 3, 2023
@drasticactions
Copy link
Contributor

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.

image

image

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.

@drasticactions drasticactions self-assigned this Feb 8, 2023
@drasticactions
Copy link
Contributor

Okay, I made this more accessible to repro.

If you replace the App.Current.MainPage with an existing page, you can get the same No installed components were detected to throw.

image

@jsuarezruiz
Copy link
Contributor

Will do more tests but, cannot reproduce it with the current main branch (7.0.200).

@drasticactions
Copy link
Contributor

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.

@DDHSchmidt
Copy link

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.

@jsuarezruiz jsuarezruiz self-assigned this Mar 29, 2023
@jsuarezruiz jsuarezruiz moved this from Todo to In Progress in MAUI SDK Ongoing Mar 29, 2023
@samhouts samhouts removed the s/verified Verified / Reproducible Issue ready for Engineering Triage label Apr 5, 2023
@datvm
Copy link

datvm commented Apr 13, 2023

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
Copy link
Member

@datvm can you log a new bug?

@datvm
Copy link

datvm commented Apr 18, 2023

@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.

@vsvsav
Copy link

vsvsav commented Apr 21, 2023

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.

@omghb
Copy link

omghb commented Apr 27, 2023

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.

@Murtaya
Copy link

Murtaya commented Apr 28, 2023

Hitting this bug also. I'm trying out Maui to see if our team can move to it, but the pushback on fixing such an easy-to-get error is not encouraging.
image

@Strypper
Copy link

Strypper commented May 9, 2023

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;
}

@samhouts samhouts modified the milestones: Backlog, .NET 8 May 24, 2023
@github-project-automation github-project-automation bot moved this from In Progress to Done in MAUI SDK Ongoing Jun 27, 2023
@samhouts samhouts modified the milestones: .NET 8, .NET 8 Planning Jul 10, 2023
@samhouts samhouts added the fixed-in-8.0.0-preview.6.8686 Look for this fix in 8.0.0-preview.6.8686! label Jul 11, 2023
@samhouts samhouts added the migration-compatibility Xamarin.Forms to .NET MAUI Migration, Upgrade Assistant, Try-Convert label Aug 28, 2023
@axa88
Copy link

axa88 commented Sep 18, 2023

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.

@ghost
Copy link

ghost commented Sep 18, 2023

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!

@ghost ghost locked as resolved and limited conversation to collaborators Oct 19, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-navigation NavigationPage fixed-in-8.0.0-preview.6.8686 Look for this fix in 8.0.0-preview.6.8686! migration-compatibility Xamarin.Forms to .NET MAUI Migration, Upgrade Assistant, Try-Convert p/1 Work that is important, and has been scheduled for release in this or an upcoming sprint platform/windows 🪟 t/bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.