Xamarin.forms: App Crashes on nested Shell section

Created on 25 Dec 2018  路  4Comments  路  Source: xamarin/Xamarin.Forms

Description

I do this test (Xamarin.Forms 4.0.0.8055-pre1):

   <Shell.FlyoutHeader>
        <local:FlyoutHeader />
    </Shell.FlyoutHeader>

    <ShellItem Title="Home" Icon="home.png">
        <ShellSection>
            <ShellContent>
                <local:MainPage />
            </ShellContent>
        </ShellSection>
    </ShellItem>

    <ShellItem Title="Notifications" Icon="notification.png">
        <ShellSection>
            <ShellContent Title="Recent">
                <local:NotificationPage />
            </ShellContent>
        </ShellSection>
    </ShellItem>

    <ShellItem Title="Test" Icon="icon.png">
        <ShellSection Title="Home" Icon="home.png">
            <ShellContent>
                <local:MainPage />
            </ShellContent>
        </ShellSection>

        <ShellSection Title="Notifications" Icon="notification.png">
            <ShellContent Title="Recent">
                <local:NotificationPage />
            </ShellContent>

            <ShellContent Title="Settings">
                <local:SettingsPage />
            </ShellContent>
        </ShellSection>
    </ShellItem>

All works when we tap the hamburger menu.

Steps to Reproduce

  1. Go to Test menu and tap Home and Notifications back and forth.
  2. Choose between Recent or Settings in Notifications, the page will open respectively.
  3. Then, when we tap the hamburger menu again, the app crashes.

Expected Behavior

Should just open the hamburger menu and can select any menu.

Actual Behavior

App crashes

Basic Information

  • Version with issue: Xamarin.Forms 4.0.0.8055-pre1
  • Last known good version: N/A
  • IDE: VS2019 Preview-1
  • Platform Target Frameworks:

    • Android: 8.0 API 26 SDK

  • Affected Devices:

    • Samsung Galaxy A5 SM-A520F

Screenshots

Before it crashes.
image

Shell.zip
Parent: #2415

shell blocker 3 bug

All 4 comments

Was able to reproduce this. Here is the exception info.



Object reference not set to an instance of an object.

  at Xamarin.Forms.Shell.GetBackButtonBehavior (Xamarin.Forms.BindableObject obj) [0x00000] in D:\a\1\s\Xamarin.Forms.Core\Shell\Shell.cs:40 
  at Xamarin.Forms.Platform.Android.ShellToolbarTracker.Android.Views.View.IOnClickListener.OnClick (Android.Views.View v) [0x00000] in D:\a\1\s\Xamarin.Forms.Platform.Android\Renderers\ShellToolbarTracker.cs:114 
  at Android.Views.View+IOnClickListenerInvoker.n_OnClick_Landroid_view_View_ (System.IntPtr jnienv, System.IntPtr native__this, System.IntPtr native_v) [0x00011] in <5d263f668f4d46bbbef4d384660c2883>:0 
  at (wrapper dynamic-method) Android.Runtime.DynamicMethodNameCounter.46(intptr,intptr,intptr)

It appears that the Page is null when the click is processed.

https://github.com/xamarin/Xamarin.Forms/blob/a6088fe/Xamarin.Forms.Platform.Android/Renderers/ShellToolbarTracker.cs#L114

I was able to reproduce this on 4.0.0.8055-pre1, but could not reproduce on 4.0.0.304370-pre8.
Seems the latest changes have fixed this bug.
@rizamarhaban can you confirm?

I can't reproduce this with pre9, either. I think we can call this fixed! Thanks!

This works now. Awesome. Thanks @samhouts and the team.

Was this page helpful?
0 / 5 - 0 ratings