Xamarin.Forms
Xamarin.Forms copied to clipboard
[Bug] Navigation.PopToRootAsync() then Navigation.PushAsync() Doesn't Display New Page At All.
Description
Navigation.PopToRootAsync() then Navigation.PushAsync() Doesn't Display New Page. See the repository for details. Related to https://github.com/xamarin/Xamarin.Forms/issues/10856.
Steps to Reproduce
- Open repository, run app.
- Add a few pages to stack.
- Click the 4th button "Go To Root, then add page" and see the result.
- then press "Workaround".
Expected Behavior
Clears the navigation stack and add a new page to the stack afterward.
Actual Behavior
navigation stack is cleared but no new pages are added OR the new pages go to the ether.
Basic Information
- Version with issue: Xamarin.Forms v4.7.0.1080
- Last known good version: 4.4.x?
- IDE: Visual Studio 2019. v16.6.4
- Platform Target Frameworks:
- iOS: 13.18.3.2
- Android: 10.3.1.4
- UWP: n/a ( untested )
- Android Support Library Version:
- Nuget Packages:
- Affected Devices:
Screenshots
Reproduction Link
https://github.com/Jakar510/FreezeTest
Workaround
I found a workaround for now.
- add the page data to the root page (whatever you need to perform the navigation and display properly)
- call: await page.Navigation.PopToRootAsync().ConfigureAwait(true);
- override the OnAppearing() method of the root page, adding await Navigation.PushAsync(new Page(PageData)).ConfigureAwait(true);
It works as this occurs on a completely different thread/Task, but does show the original page briefly which is not ideal but I haven't found any other way to get around it for now.
Added Platform Target Frameworks where the issue occurs: iOS: 13.18.3.2 Android: 10.3.1.4
It occurs on both platforms.
@samhouts You removed this from the 5.0.0 milestone but the problem actually exists in v5.0 as released a few days ago. I'm now facing this problem after upgrading from v4.6 to v5.0.
My problem is reproduced like that:
public void ShowMember(Member member)
{
var page = new DirectoryPage();
Shell.Current.Navigation.PopToRootAsync(false);
Shell.Current.Navigation.PushAsync(page);
page.ShowMemberDetails(member);
}
Method page.ShowMemberDetails will basically check whether the member is "complete" and if so will add a "member detail page" to the navigation page.
Now, this just doesn't work, it lands on the DirectoryPage instead. When I comment out the last line page.ShowMemberDetails(member);, then something interesting appears:
- I see the
DirectoryPagefor a short time - Then it goes back to the main page
This means Shell.Current.Navigation.PopToRootAsync(false) is executed after the other pages have been pushed to the navigation.
Any update? This has existed for nearly a year.
Hi, i have the same problem since i had updated xamarins.forms. It makes no matter what android target framework or what android versions i will use (greater than 9). I found out that it still works with version 5.0.0.2012, but no longer from version 5.0.0.2083 up to the latest version. When debugging i have no difference in navigation.navigationstack ... there are the same values. I hope, this will help to resolve the problem as soon as possible!
update .... In my case, the problem appears only when i use Navigation.PopToRootAsync(false) with parameter "false". When ich use Navigation.PopToRootAsync() without parameter or with parameter (true) the failure does not occur.
I can confirm also having problems on android when using parameter false. pages go missing etc, blank screen in the nav stack..
e.g Navigation.PopToRootAsync(false)
but no problem with. Navigation.PopToRootAsync()
Setting the animate option to true seems to fix this on Android for me, with no animation shown.