Skip to content

Double tap gesture NullReferenceException when navigating #19465

@konrad-gora

Description

@konrad-gora

Description

I have a problem with the double tap gesture. If it triggers navigation, I get a NullReferenceException
DoubleTap error
The error doesn't show if I use a different gesture (swipe).
I'm using this trick in navigation because there is no reason to return to a page with GestureRecognizers (FirstPage), I always want to return to MainPage.

The problem exists only on Android (I'm using Samsung A52s with Android 13). When I was trying to run it on Windows, I couldn't reproduce the error. Also, this problem appeared when I migrated to .NET 8, on NET 7 it works correctly.

Steps to Reproduce

        <VerticalStackLayout.GestureRecognizers>
            <TapGestureRecognizer NumberOfTapsRequired="2" Tapped="OnGesture" />
            <SwipeGestureRecognizer Direction="Up,Down,Left,Right" Swiped="OnGesture" />
        </VerticalStackLayout.GestureRecognizers>
    private async void OnGesture(object sender, EventArgs e)
    {
        Navigation.InsertPageBefore(new SecondPage(), this);
        await Navigation.PopAsync(animated: false);
    }

Link to public reproduction project repository

https://github.com/konrad-gora/DoubleTapError

Version with bug

8.0.3

Is this a regression from previous behavior?

Yes, this used to work in .NET MAUI

Last version that worked well

Unknown/Other

Affected platforms

Android

Affected platform versions

Android 13 Samsung A52s

Did you find any workaround?

Adding Delay makes it work.

        await Navigation.PushAsync(new SecondPage(), animated: false);
        await Task.Delay(1);
        Navigation.RemovePage(this);

Also if I'm not removing this page from navigation, there is no error (but this is not an expected behavior).

Relevant log output

No response

Metadata

Metadata

Assignees

Labels

area-gesturesGesture typeshighIt doesn't work at all, crashes or has a big impact.platform/androidpotential-regressionThis issue described a possible regression on a currently supported version., verification pendingt/bugSomething isn't working

Type

No type

Projects

Status

Done

Relationships

None yet

Development

No branches or pull requests

Issue actions