Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Android crash on navigate back from tab 2 without Shell #15687

Closed
sebdesalvador opened this issue Jun 15, 2023 · 2 comments
Closed

Android crash on navigate back from tab 2 without Shell #15687

sebdesalvador opened this issue Jun 15, 2023 · 2 comments
Labels
area-controls-tabbedpage TabbedPage area-navigation NavigationPage high It doesn't work at all, crashes or has a big impact. platform/android 🤖 s/triaged Issue has been reviewed s/try-latest-version Please try to reproduce the potential issue on the latest public version s/verified Verified / Reproducible Issue ready for Engineering Triage t/bug Something isn't working

Comments

@sebdesalvador
Copy link

sebdesalvador commented Jun 15, 2023

Description

I have created a very simple app with only a MainPage and a TabbedPage with its tabs at the bottom. Navigation is done without a Shell, so the App's main page is actually a NavigationPage. Pushing the TabbedPage onto the navigation stack automatically creates the navigation bar with a back button at the top (as expected, and to my current knowledge, absolutely impossible to do with a Shell). When navigating from the 2nd tab of the TabbedPage back to the MainPage via the back button, the app crashes with a NullReferenceException.

Strangely enough, if the TabbedPage only contains 2 tabs, or if the tabs are at the top, the app doesn't crash, and when it contains more than 2 bottom tabs, the crash only happens from the 2nd tab.

It happens on Android simulator as well as on an Android device and I only tested .NET 7 and latest .NET 8 preview. Doesn't happen on iOS (simulator or device).

I'd like to know if it's only on my machine (mac), or if it's a general issue.

Thanks

Steps to Reproduce

  1. Create a basic MAUI app (no blazor)
  2. Remove the AppShell (xaml and xaml.cs)
  3. Modify the App.xaml.cs constructor to initialise the NavigationPage
public App()
{
    InitializeComponent();
    MainPage = new NavigationPage( new MainPage() );
}
  1. Create a TabbedPage at the root of the project with 3 ContentPages, call it MyTabbedPage (notice the Android specific argument on the TabbedPage node to make the tabs appear at the bottom)
<?xml version="1.0" encoding="utf-8"?>

<TabbedPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
            xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
            xmlns:android="clr-namespace:Microsoft.Maui.Controls.PlatformConfiguration.AndroidSpecific;assembly=Microsoft.Maui.Controls"
            x:Class="ThreeTabsCrash.MyTabbedPage"
            Title="TabbedPage"
            android:TabbedPage.ToolbarPlacement="Bottom">

    <ContentPage Title="Tab 1">

        <ScrollView>

            <VerticalStackLayout
                Spacing="25"
                Padding="30,0"
                VerticalOptions="Center">

                <Label
                    Text="Tab 1"
                    SemanticProperties.HeadingLevel="Level1"
                    FontSize="32"
                    HorizontalOptions="Center" />

            </VerticalStackLayout>
        </ScrollView>

    </ContentPage>

    <ContentPage Title="Tab 2">

        <ScrollView>

            <VerticalStackLayout
                Spacing="25"
                Padding="30,0"
                VerticalOptions="Center">

                <Label
                    Text="Tab 2"
                    SemanticProperties.HeadingLevel="Level1"
                    FontSize="32"
                    HorizontalOptions="Center" />

            </VerticalStackLayout>
        </ScrollView>

    </ContentPage>

    <ContentPage Title="Tab 3">

        <ScrollView>

            <VerticalStackLayout
                Spacing="25"
                Padding="30,0"
                VerticalOptions="Center">

                <Label
                    Text="Tab 3"
                    SemanticProperties.HeadingLevel="Level1"
                    FontSize="32"
                    HorizontalOptions="Center" />

            </VerticalStackLayout>
        </ScrollView>

    </ContentPage>

</TabbedPage>
  1. Create a button on the MainPage to navigate to the TabbedPage
<Button
    Text="Go To Tabs"
    Clicked="OnTabsClicked"
    HorizontalOptions="Center" />
private void OnTabsClicked( object sender, EventArgs e )
{
    App.Current.MainPage.Navigation.PushAsync( new MyTabbedPage() );
}
  1. Start the app (Debug or Release mode)
  2. Navigate to the TabbedPage via the button on the MainPage
  3. Navigate to the 2nd tab
  4. Hit the back button (from the navigation bar or the actual device's back button)
  5. Suffer the crash

Link to public reproduction project repository

https://github.com/sebdesalvador/ThreeTabsCrash

Version with bug

8.0.0-preview.5.8529

Last version that worked well

Unknown/Other

Affected platforms

Android

Affected platform versions

Pixel 5 - API 33

Did you find any workaround?

No response

Relevant log output

No response

@sebdesalvador sebdesalvador added the t/bug Something isn't working label Jun 15, 2023
@jsuarezruiz jsuarezruiz added platform/android 🤖 area-controls-shell Shell Navigation, Routes, Tabs, Flyout high It doesn't work at all, crashes or has a big impact. labels Jun 16, 2023
@XamlTest XamlTest added s/verified Verified / Reproducible Issue ready for Engineering Triage s/triaged Issue has been reviewed labels Jul 25, 2023
@XamlTest
Copy link

Verified this on Visual Studio Enterprise 17.7.0 Preview 4.0. Repro on Android 13.0-API33 .NET 8, not repro on Windows 11 and iOS 16.4 with below Project:
ThreeTabsCrash.zip

image

Copy link
Contributor

Hi @sebdesalvador. We have added the "s/try-latest-version" label to this issue, which indicates that we'd like you to try and reproduce this issue on the latest available public version. This can happen because we think that this issue was fixed in a version that has just been released, or the information provided by you indicates that you might be working with an older version.

You can install the latest version by installing the latest Visual Studio (Preview) with the .NET MAUI workload installed. If the issue still persists, please let us know with any additional details and ideally a reproduction project provided through a GitHub repository.

This issue will be closed automatically in 7 days if we do not hear back from you by then - please feel free to re-open it if you come back to this issue after that time.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-controls-tabbedpage TabbedPage area-navigation NavigationPage high It doesn't work at all, crashes or has a big impact. platform/android 🤖 s/triaged Issue has been reviewed s/try-latest-version Please try to reproduce the potential issue on the latest public version s/verified Verified / Reproducible Issue ready for Engineering Triage t/bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants