-
Notifications
You must be signed in to change notification settings - Fork 1.9k
[Android] -Picker dialog causes crash when page is popped while dialo… #31747
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
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
f9a753c
[Android] -Picker dialog causes crash when page is popped while dialo…
sheiksyedm e1e7a9f
removed the dispose call.
sheiksyedm eb6f7d1
Revert "removed the dispose call."
sheiksyedm e5bc189
removed the dispose call.
sheiksyedm 7a4989d
Modified with Dismiss() method.
sheiksyedm File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,89 @@ | ||
| namespace Maui.Controls.Sample.Issues | ||
| { | ||
| [Issue(IssueTracker.Github, 31731, "Picker dialog causes crash when page is popped while dialog is open", PlatformAffected.Android)] | ||
| public class Issue31731 : NavigationPage | ||
| { | ||
| public Issue31731() : base(new MainPage()) | ||
| { | ||
| } | ||
|
|
||
| public class MainPage : ContentPage | ||
| { | ||
| public MainPage() | ||
| { | ||
| var button = new Button | ||
| { | ||
| Text = "Navigate to Picker Page", | ||
| AutomationId = "navigateButton" | ||
| }; | ||
|
|
||
| button.Clicked += OnNavigateClicked; | ||
|
|
||
| var statusLabel = new Label | ||
| { | ||
| Text = "Status: Ready", | ||
| AutomationId = "statusLabel" | ||
| }; | ||
|
|
||
| Content = new StackLayout | ||
| { | ||
| Padding = new Thickness(20), | ||
| Children = { statusLabel, button } | ||
| }; | ||
| } | ||
|
|
||
| private void OnNavigateClicked(object sender, EventArgs e) | ||
| { | ||
| Navigation.PushAsync(new PickerPage()); | ||
| } | ||
| } | ||
|
|
||
| public class PickerPage : ContentPage | ||
| { | ||
| public PickerPage() | ||
| { | ||
| var picker = new Picker | ||
| { | ||
| Title = "Select a color", | ||
| ItemsSource = new List<string> { "Red", "Green", "Blue", "Yellow", "Purple" }, | ||
| AutomationId = "colorPicker" | ||
| }; | ||
|
|
||
| var instructionsLabel = new Label | ||
| { | ||
| Text = "Tap the picker to open the dialog, then wait for auto navigation back (3 seconds). The app should not crash.", | ||
| AutomationId = "instructionsLabel", | ||
| Margin = new Thickness(0, 0, 0, 20) | ||
| }; | ||
|
|
||
| var statusLabel = new Label | ||
| { | ||
| Text = "Status: Page loaded", | ||
| AutomationId = "pageStatusLabel" | ||
| }; | ||
|
|
||
| Content = new StackLayout | ||
| { | ||
| Padding = new Thickness(20), | ||
| Children = { instructionsLabel, statusLabel, picker } | ||
| }; | ||
| } | ||
|
|
||
| protected override void OnNavigatedTo(NavigatedToEventArgs args) | ||
| { | ||
| base.OnNavigatedTo(args); | ||
|
|
||
| // Simulate the scenario: navigate back after 3 seconds | ||
| // This can cause a crash if the picker dialog is open | ||
| _ = Task.Run(async () => | ||
| { | ||
| await Task.Delay(3000); | ||
| await Dispatcher.DispatchAsync(async () => | ||
| { | ||
| await Navigation.PopToRootAsync(); | ||
| }); | ||
| }); | ||
| } | ||
| } | ||
| } | ||
| } | ||
43 changes: 43 additions & 0 deletions
43
src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue31731.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,43 @@ | ||
| using NUnit.Framework; | ||
| using UITest.Appium; | ||
| using UITest.Core; | ||
|
|
||
| namespace Microsoft.Maui.TestCases.Tests.Issues; | ||
|
|
||
| public class Issue31731 : _IssuesUITest | ||
| { | ||
| public Issue31731(TestDevice testDevice) : base(testDevice) | ||
| { | ||
| } | ||
|
|
||
| public override string Issue => "Picker dialog causes crash when page is popped while dialog is open"; | ||
|
|
||
| [Test] | ||
| [Category(UITestCategories.Picker)] | ||
| public void PickerDialogDoesNotCrashWhenPagePoppedWhileDialogOpen() | ||
| { | ||
| // Wait for the main page to load | ||
| App.WaitForElement("statusLabel"); | ||
| App.WaitForElement("navigateButton"); | ||
|
|
||
| // Navigate to the picker page | ||
| App.Tap("navigateButton"); | ||
|
|
||
| // Wait for picker page to load | ||
| App.WaitForElement("colorPicker"); | ||
| App.WaitForElement("pageStatusLabel"); | ||
|
|
||
| // Open the picker dialog | ||
| App.Tap("colorPicker"); | ||
|
|
||
| // Wait for a moment to ensure dialog is open, then wait for auto navigation | ||
| // The page will automatically pop after 3 seconds | ||
| // If the bug exists, this would cause a crash | ||
| System.Threading.Thread.Sleep(4000); // Wait longer than the 3-second delay | ||
|
|
||
| // If we reach this point without crashing, the test passes | ||
| // Verify we're back on the main page | ||
| App.WaitForElement("statusLabel"); | ||
sheiksyedm marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| App.WaitForElement("navigateButton"); | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.