-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
Conversation
There was a problem hiding this 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?
src/Controls/tests/DeviceTests/Elements/Window/WindowTests.Windows.cs
Outdated
Show resolved
Hide resolved
There was a problem hiding this 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.
/rebase |
fd6db61
to
b898af2
Compare
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() |
There was a problem hiding this comment.
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.
-
is swapping out the rootpage https://github.com/drasticactions/MauiRepros/tree/main/MauiReusePageBug
-
is pushing a page, popping that page, pushing that page a second time. https://github.com/Keflon/MauiNavigationBugRepro
src/Controls/tests/DeviceTests/Elements/Window/WindowTests.Windows.cs
Outdated
Show resolved
Hide resolved
src/Controls/tests/DeviceTests/Elements/Window/WindowTests.Windows.cs
Outdated
Show resolved
Hide resolved
There was a problem hiding this 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.
There was a problem hiding this 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.
Description of Change
Fix crash swapping MainPage on Windows.
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