Bug 43298 - Unexpected behavior of PopAsync after PopToRootAsync has been called previously on Windows Phone (Silverlight)
Summary: Unexpected behavior of PopAsync after PopToRootAsync has been called previous...
Status: CONFIRMED
Alias: None
Product: Forms
Classification: Xamarin
Component: Windows ()
Version: 2.3.1
Hardware: PC Windows
: Normal major
Target Milestone: ---
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2016-08-12 09:43 UTC by Robert Ros
Modified: 2017-06-14 15:40 UTC (History)
4 users (show)

Tags: ac
Is this bug a regression?: ---
Last known good build:


Attachments
demo (58.73 KB, application/x-zip-compressed)
2016-08-12 09:43 UTC, Robert Ros
Details


Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report for Bug 43298 on Developer Community or GitHub if you have new information to add and do not yet see a matching new report.

If the latest results still closely match this report, you can use the original description:

  • Export the original title and description: Developer Community HTML or GitHub Markdown
  • Copy the title and description into the new report. Adjust them to be up-to-date if needed.
  • Add your new information.

In special cases on GitHub you might also want the comments: GitHub Markdown with public comments

Related Links:
Status:
CONFIRMED

Description Robert Ros 2016-08-12 09:43:00 UTC
Created attachment 17004 [details]
demo

Pushing and Popping ContentPages on Windows Phone (silverlight) works as expected until PopToRootAsync has been called. After PopToRootAsync has been called PopAsync will behave unexpectly:
1. When there are two pages on the stack, PopAsync will fail to pop to the first page.
2. When there are three or more pages on the stack, PopAsync skips one page.

I attached a visual studio solution to demonstrate the issue.

Steps to reproduce 1:
* Load a ContentPage (FirstPage) in a NavigationPage
* Push a new ContentPage (SecondPage)
* Call PopToRootAsync
* Push a new ContentPage (SecondPage)
* Call PopAsync
Result: The ContentPage won't be popped and navigation stops working.

Steps to reproduce 2:
* Load a ContentPage (FirstPage) in a NavigationPage
* Push a new ContentPage (SecondPage)
* Call PopToRootAsync
* Push a new ContentPage (SecondPage
* Push a new ContentPage (ThirdPage)
* Call PopAsync
Result: The app pops to FirstPage instead of SecondPage.


I tracked the issue to line 239 in Xamarin.Forms.Platform.WP8.Platform.cs: 
Page navRoot = _navModel.Tree.Last().Skip(1).First();

This line will throw an Exception when called after calling PopToRootAsync because the stack only contains the initial NavigationPage and not the first ContentPage.

This issue blocks the release of our app for WindowsPhone, as there is no known workaround at the moment.
Comment 1 Robert Ros 2016-08-12 11:15:21 UTC
Currently we're using the following code as a workaround for this issue: https://gist.github.com/rros/99e48cf452e1c798ec3a71fae5fd490e
Comment 2 KubarUS 2017-02-26 10:18:13 UTC
Exactly the same behave on 2.3.3.193 version. nothing change till now...