Bug 30375 - Pressing a Button Multiple Times Sometimes Pushes More Than One Page to the Navigation Stack
Summary: Pressing a Button Multiple Times Sometimes Pushes More Than One Page to the N...
Alias: None
Product: Forms
Classification: Xamarin
Component: Android ()
Version: 1.4.3
Hardware: PC Mac OS
: Normal normal
Target Milestone: ---
Assignee: Bugzilla
Depends on:
Reported: 2015-05-22 20:18 UTC by Jimmy [MSFT]
Modified: 2017-05-11 09:04 UTC (History)
3 users (show)

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

Repro project (115.52 KB, application/zip)
2015-05-22 20:18 UTC, Jimmy [MSFT]

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:

Description Jimmy [MSFT] 2015-05-22 20:18:57 UTC
Created attachment 11308 [details]
Repro project

*** Overview ***
When a button which navigates to a new page is tapped multiple times, sometimes you end up with multiple pages being created and pushed because the  push is done asynchronously.

*** Steps to Reproduce ***
1. Run the attached repro project on Android
2. Press the “Is not Disabled” button multiple times

*** Actual Results ***
If the timing is right, pressing the button several times creates multiple pages that are pushed onto the navigation stack.

*** Expected Results ***
Only one page is created and pushed. Pressing the “Is Disabled” button multiple times does not create more than one page because the button is disabled after the first one is crated.

*** Environment Info ***
=== Xamarin Studio ===

Version 5.9.2 (build 2)
Installation UUID: 94ce5106-6a72-4691-b34e-cd5857b1db66
	Mono 4.0.1 ((detached/11b5830)
	GTK+ 2.24.23 (Raleigh theme)

	Package version: 400010043

=== Apple Developer Tools ===

Xcode 6.3.1 (7703)
Build 6D1002

=== Xamarin.iOS ===

Version: (Business Edition)
Hash: 13d1cdc
Branch: master
Build date: 2015-05-18 22:54:57-0400

=== Xamarin.Android ===

Version: (Business Edition)
Android SDK: /Users/jimmygarrido/Library/Developer/Xamarin/android-sdk-macosx
	Supported Android versions:
		2.3   (API level 10)
		4.0.3 (API level 15)
		4.1   (API level 16)
		4.4   (API level 19)
		5.0   (API level 21)
Java SDK: /usr
java version "1.7.0_71"
Java(TM) SE Runtime Environment (build 1.7.0_71-b14)
Java HotSpot(TM) 64-Bit Server VM (build 24.71-b01, mixed mode)

=== Xamarin Android Player ===

Version: Unknown version
Location: /Applications/Xamarin Android Player.app

=== Xamarin.Mac ===

Version: (Business Edition)

=== Build Information ===

Release ID: 509020002
Git revision: 43735a4b905b571f69cf9428a3ea7b52aef55476
Build date: 2015-05-18 09:38:12-04
Xamarin addins: ab18ddff45f507ed74f36c2b65df9aee22e28a56

=== Operating System ===

Mac OS X 10.10.3
Darwin Jimmys-MacBook-Pro.local 14.3.0 Darwin Kernel Version 14.3.0
    Mon Mar 23 11:59:05 PDT 2015
    root:xnu-2782.20.48~5/RELEASE_X86_64 x86_64
Comment 1 Stephane Delcroix 2015-05-26 04:23:48 UTC
The attached reproduction is not the one you're describing. Cn you update it ?

The behavior you're reporting seems correct. If you click multiple times a button that is supposed to add pages to the navigation, well, you end up with multiple pages added. You probably should handle that in your code, by deactivating the button while the async operation is running.

    var btn = new Button ();
    btn.Click += async (o,e) => {
        btn.IsEnabled = false;
        await Navigation.PushAsync (next page);
        btn.IsEnabled = true;

or the equivalent using a Command.

I'm closing the bug, reopen if you still have an issue while properly handling the async completion in your code.
Comment 2 Andrei.N 2015-05-26 14:31:45 UTC
@Stephane Delcroix

I understand that it's asynchronous because of the animation but multiple navigation doesn't happen "natively". Without Xamarin Forms, this is not an issue.
Comment 3 develop 2017-05-11 09:04:55 UTC
From experience, we know the multiple-push problem does not exist on native iOS, nor on UWP+Forms. It seems these platforms lock the UI when performing the push. Android is the only platform one that seems to be affected by this problem.

Note that the solution proposed by @Stephane Delcroix disables a single button and would have to be implemented wherever a push is done. Additionally, issue #30384 (IsEnabled not propagating) further complicates solving this problem.

This problem greatly inconveniences us, we would appreciate if you reconsidered classifying it as a bug. Thank you