We've found some rather annoying issues with multiple taps and navigation on Android using Xamarin.Forms. Let's say there's a button press and in the handler there's a bog-standard await Navigation.PushAsync(new SomePage())
.
If you're really fast, you can tap the button multiple times, pushing multiple pages on to the stack.
This class of bug also happens when dismissing pages. Suppose you have a button with a handler with an await Navigation.PopAsync()
. If you're really fast, you can multiple-tap that button as it animates away; in our test cases, this often caused a crash mentioning jobject being equal to IntPtr.Zero or something.
We've managed limited mitigation by storing a time-of-last-tap and swallowing excess taps within a certain threshold of the previous successful tap, but this seems very kludgey...
Ideally pages should not respond to touch events unless they're the top page on the navigation stack and there's no page-related animation happening. Is there a good general solution to this?
By the way, you can see this in the Xamarin Evolve app. Go to a session, multi-tap Send Feedback, and watch a bunch of feedback windows push onto the stack. Or multi-tap Cancel and watch a bunch of them dismiss. (In this case it doesn't seem to crash.)