Bug 39187 - UWP Navigation shows duplicate page when performing multiple nav operations
Summary: UWP Navigation shows duplicate page when performing multiple nav operations
Status: VERIFIED FIXED
Alias: None
Product: Forms
Classification: Xamarin
Component: Forms ()
Version: 2.0.0
Hardware: PC Windows
: --- normal
Target Milestone: ---
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2016-02-28 18:25 UTC by Brian Lagunas
Modified: 2017-03-16 18:54 UTC (History)
7 users (show)

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

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 on Developer Community or GitHub with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:
Status:
VERIFIED FIXED

Description Brian Lagunas 2016-02-28 18:25:55 UTC
When performing multiple navigation operations on UWP, the same page instance is shown twice resulting in a duplicate page being displayed.

Assuming I want to initially navigate to th following stack wen the app is loaded

NavigationPage -> MainPage -> ViewA

For example, when the application starts, if I were to navigate to a NavigationPage with a MainPage as it's initial page, and then push another ViewA onto the stack before setting the Application.Current.MainPage, then the "MainPage" instance will be shown when the app has loaded (instead of the expected ViewA).  Then when you navigate back it shows the same "MainPage" instance again.  You know it is the same MainPage instance because the MainPage ctor only executes once, so we are only dealing with one instance.  What should happen is that the ViewA should be the initial page shown when the app loads and then a press of the back button should go back to the "MainPage" instance.

    public class App : Application
    {
        public App()
        {
            var navPage = new NavigationPage();
            var mainPage = new MainPage();
            var viewA = new ViewA();

            mainPage.Navigation.PushAsync(viewA);
            navPage.Navigation.PushAsync(mainPage);

            MainPage = navPage;
        }
    }

    public class MainPage : ContentPage
    {
        public MainPage()
        {
            Title = "Main Page";

            Content = new Label()
            {
                Text = "Main Page",
                HorizontalTextAlignment = TextAlignment.Center,
                VerticalTextAlignment = TextAlignment.Center
            };
        }
    }

    public class ViewA : ContentPage
    {
        public ViewA()
        {
            Title = "View A";

            Content = new Label()
            {
                Text = "View A",
                HorizontalTextAlignment = TextAlignment.Center,
                VerticalTextAlignment = TextAlignment.Center
            };
        }
    }
Comment 1 Rui Marinho 2016-03-15 15:21:31 UTC
Hi Bryan if you change your code to first push the MainPage in to the NavigationPage and after that you push the viewA it will work as expected, change the code for the following: 

> navPage.Navigation.PushAsync(mainPage);
> mainPage.Navigation.PushAsync(viewA);
Comment 2 Brian Lagunas 2016-03-15 15:53:23 UTC
I can't make that change.  The Prism framework builds the navigation stack back to front in order to properly support deep-linking, and other more advanced navigation scenarios.  This is the order in which the navigation code will be invoked.
Comment 3 Brian Lagunas 2016-03-15 15:59:55 UTC
Let me clarify; this bug was discovered by a user of Prism.  

See:  https://github.com/PrismLibrary/Prism/issues/476

The Prism framework has a very powerful and feature rich navigation service that has a mature code base and is functional on all other platforms.  The sample I provided was merely to identify the issue using native XF code and to remove the possibility that Prism was playing a role in the issue.

UWP is the only XF supported platform that exhibits this behavior.  All other platforms function properly with the current Prism navigation service code base.  Making a change like you suggested would essentially be a breaking change for all current Prism XF apps, and could potentially eliminate the navigation feature altogether.
Comment 4 Rui Marinho 2016-06-02 16:23:16 UTC
This should be fixed in 2.2 stable.
Comment 5 Brian Lagunas 2016-06-02 18:31:00 UTC
Well... yes, and no.  It works in this specific scenario, but if you modify it like this:

        public App()
        {
            var mainPage = new MainPage();
            var viewA = new ViewA();

            mainPage.Navigation.PushModalAsync(viewA);            

            MainPage = mainPage;
        }

It is still broken.
Comment 6 Rui Marinho 2016-06-16 16:38:22 UTC
Should be fixed in 2.3.1-pre1
Comment 7 Parmendra Kumar 2016-06-30 18:02:04 UTC
I have checked this issue with Xamarin.Forms 2.3.1-pre1 and its working fine.

Hence closing this issue.
Comment 8 Christian Daniel 2017-01-24 13:05:38 UTC
I discovered the Problem within a Xamarin.Forms/Prism/UWP prototype for my customer today. We're using the stable release of Xamarin.Forms 2.3.3.180. It seems the bug is back. I also tried the current available prerelease 2.3.4.184, which also seems to be buggy. :(
Comment 9 Samantha Houts [MSFT] 2017-03-16 18:54:13 UTC
@Christian Daniel: Do you have a reproduction project that you can share?