Bug 31542 - Inconsistent behavior of Push/PopModalAsync (Android)
Summary: Inconsistent behavior of Push/PopModalAsync (Android)
Status: RESOLVED ANSWERED
Alias: None
Product: Forms
Classification: Xamarin
Component: Android (show other bugs)
Version: 1.4.2
Hardware: PC Mac OS
: Normal normal
Target Milestone: ---
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2015-07-01 12:02 UTC by Adam Kemp
Modified: 2017-12-20 00:17 UTC (History)
4 users (show)

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


Attachments
Test case (1.13 MB, application/zip)
2015-07-01 12:02 UTC, Adam Kemp
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 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:
RESOLVED ANSWERED

Description Adam Kemp 2015-07-01 12:02:39 UTC
Created attachment 11805 [details]
Test case

Scenario:

Page1 pushes Page2 using Navigation.PushModalAsync (from Page1). Page2 then calls Navigation.PopModalAsync (from within Page2). That pop is using Page2's Navigation property, which should have its own modal stack. I believe this should throw, but instead it pops Page2. Next, Page2 pushes Page2 using Navigation.PushModalAsync (still from within Page2, using Page2's Navigation property). This page is never shown.

This behavior is inconsistent. There are two possibly consistent results:

1. Page2's call to PopModalAsync should throw.
Or
2. Page3 should be shown.

The way it works now tries to sometimes pretend that there's only one stack, but other times acts as if each page has its own independent stack. I prefer option 1 because it forces people to understand the nested hierarchical nature of navigation, and it matches the behavior of iOS's native API, where each view controller can present one and only one thing at a time, and you can only dismiss it from the view controller that presented it.

To test this run the attached app (from this discussion: https://forums.xamarin.com/discussion/44635/why-does-popmodalasync-error-in-ios-but-work-on-android), press the button on the first page, and then the first button on the second page.
Comment 1 Jason Smith [MSFT] 2016-04-10 05:27:28 UTC
Modal stack is global, not per page.
Comment 2 Adam Kemp 2016-04-11 18:17:34 UTC
There's still a bug, though. If the modal stack is global then the correct behavior is option two listed above: Page3 should have been shown. Instead, Page3 was not shown because it was pushed from Page2's Navigation object while Page2 was not on screen. If the stack is global then why does it matter whether the Page you're pushing it from is on the stack or not?

This API is broken, and it's confusing people who try to use it.
Comment 3 Mike Norman 2017-06-19 15:42:40 UTC
Still repros.
Comment 4 David Ortinau [MSFT] 2017-12-20 00:17:54 UTC
Migrated to https://github.com/xamarin/Xamarin.Forms/issues/1427

Please subscribe to that issue for future updates.