Xamarin.Forms icon indicating copy to clipboard operation
Xamarin.Forms copied to clipboard

[Bug] Navigation.PopToRootAsync() then Navigation.PushAsync() Doesn't Display New Page At All.

Open Jakar510 opened this issue 5 years ago • 6 comments

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

  1. Open repository, run app.
  2. Add a few pages to stack.
  3. Click the 4th button "Go To Root, then add page" and see the result.
  4. 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.

  1. add the page data to the root page (whatever you need to perform the navigation and display properly)
  2. call: await page.Navigation.PopToRootAsync().ConfigureAwait(true);
  3. 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.

Jakar510 avatar Jul 15 '20 16:07 Jakar510

Added Platform Target Frameworks where the issue occurs: iOS: 13.18.3.2 Android: 10.3.1.4

It occurs on both platforms.

Jakar510 avatar Aug 03 '20 18:08 Jakar510

@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:

  1. I see the DirectoryPage for a short time
  2. 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.

xperseguers avatar Jan 19 '21 11:01 xperseguers

Any update? This has existed for nearly a year.

Jakar510 avatar Mar 22 '21 03:03 Jakar510

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.

MarkusWst avatar Apr 21 '22 06:04 MarkusWst

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()

chironexsoftware avatar Sep 05 '22 21:09 chironexsoftware

Setting the animate option to true seems to fix this on Android for me, with no animation shown.

jameswestgate avatar Sep 13 '22 14:09 jameswestgate