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

[Windows] Fix crash swapping MainPage #14262

Merged
merged 19 commits into from
Jun 27, 2023
Merged

[Windows] Fix crash swapping MainPage #14262

merged 19 commits into from
Jun 27, 2023

Conversation

jsuarezruiz
Copy link
Contributor

@jsuarezruiz jsuarezruiz commented Mar 29, 2023

Description of Change

Fix crash swapping MainPage on Windows.

fix-7698

To validate the changes can use this sample https://github.com/drasticactions/MauiRepros/tree/main/MauiReusePageBug from the issue or the added device test.

Tested the same on other platforms, and works on Android and iOS.

Issues Fixed

Fixes #7698

@jsuarezruiz jsuarezruiz added t/bug Something isn't working platform/windows 🪟 area-navigation NavigationPage labels Mar 29, 2023
Copy link
Member

@PureWeen PureWeen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The original issue was about pushing the same page a second time.

If that's also broken and fixed by this PR then can you add a test for that as well?

Copy link
Member

@mandel-macaque mandel-macaque left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1 as long as @PureWeen concerns are addressed.

@PureWeen
Copy link
Member

/rebase

src/Core/src/Handlers/Window/WindowHandler.Windows.cs Outdated Show resolved Hide resolved
using Xunit;
using WPanel = Microsoft.UI.Xaml.Controls.Panel;

namespace Microsoft.Maui.DeviceTests
{
public partial class WindowTests : ControlsHandlerTestBase
{
[Fact(DisplayName = "Swapping MainPage no Crash")]
public async Task SwappingMainPageNoCrash()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure if this test accurately tests the issue.

I commented out all the changes in this PR and the test still passes. One thing to note here is that the original issue was more about pushing the same page on the stack more then it was about swapping out the root page.

So, the original issue is actually two different issues.

  1. is swapping out the rootpage https://github.com/drasticactions/MauiRepros/tree/main/MauiReusePageBug

  2. is pushing a page, popping that page, pushing that page a second time. https://github.com/Keflon/MauiNavigationBugRepro

Copy link
Member

@mattleibow mattleibow left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think Shane's comment on the test is probably the most critical - is the test correctly testing the 2 scenarios?

Other than that I was wondering if it were possible to reduce the complexity of the test by avoiding the clicks? The CreateHandlerAndAddToWindow already waits for a layout pass, so the code in the click could run inside that block. But is that click necessary? The code asserts if it is true, so it will stay true inside the CreateHandlerAndAddToWindow block.

If we remove the button then we can remove other code in the tests to make it simpler. And also there is a few whitespace changes that we can revert to simplify the PR some more.

Copy link
Member

@mattleibow mattleibow left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think Shane's comment on the test is probably the most critical - is the test correctly testing the 2 scenarios?

Other than that I was wondering if it were possible to reduce the complexity of the test by avoiding the clicks? The CreateHandlerAndAddToWindow already waits for a layout pass, so the code in the click could run inside that block. But is that click necessary? The code asserts if it is true, so it will stay true inside the CreateHandlerAndAddToWindow block.

If we remove the button then we can remove other code in the tests to make it simpler. And also there is a few whitespace changes that we can revert to simplify the PR some more.

@PureWeen PureWeen enabled auto-merge (squash) June 27, 2023 15:44
@PureWeen PureWeen merged commit 4bb9541 into main Jun 27, 2023
@PureWeen PureWeen deleted the fix-7698 branch June 27, 2023 19:03
@github-actions github-actions bot locked and limited conversation to collaborators Dec 12, 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 Aug 2, 2024
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! platform/windows 🪟 t/bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

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