PopToRootAsync results in a Deadlock
- Dominant language
- C#
- Stars
- 23.3k
- Forks
- 2k
- Avg merge
- 1d 15h
- Merged PRs (30d)
- 290
Description
### Description
With iOS PopToRootAsync can run in a deadlock.
It works in Android and also in XF.
I found this, because i try to migrate a project from XF to Maui.
### Steps to Reproduce
- Open attached repro.
- Click Open Modal Page
- Click PopToRootAsync
Label with text "Before try PopToRootAsync" will not changes to "Popped to root successfully".
```c#
private async void Button_Clicked(object sender, EventArgs e)
{
if (App.Current.Windows[0].Page is TabbedPage tabedPage)
{
for (int i = 1; i < tabedPage.Children.Count; i++)
{
var navigationPage = tabedPage.Children[i] as NavigationPage;
await navigationPage.PopToRootAsync(); //Deadlock here!
label.Text = "Popped to root successfully";
}
//await this.Navigation.PopModalAsync();
}
}
```
Repro:
[MauiApp6.zip](https://github.com/user-attachments/files/19207458/MauiApp6.zip)
### Link to public reproduction project repository
_No response_
### Version with bug
9.0.40 SR4
### Is this a regression from previous behavior?
Yes, this used to work in Xamarin.Forms
### Last version that worked well
Unknown/Other
### Affected platforms
iOS
### Affected platform versions
_No response_
### Did you find any workaround?
_No response_
### Relevant log output
```shell
```
Contributor guide
Research direction
Start with the attached MauiApp6.zip repro and the Button_Clicked handler, then run the iOS steps through PopToRootAsync. Trace where execution stops after the await and compare the behavior with Android and Xamarin.Forms noted in the report. Done means the iOS repro completes PopToRootAsync and updates the label without a deadlock.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp, ios
- Domain
- mobile-dev
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 28/100