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

NullReference in ShellPageRendererTracker.UpdateTabBarVisible() #26784

Open
Marioo1357 opened this issue Dec 23, 2024 · 0 comments · May be fixed by #26786
Open

NullReference in ShellPageRendererTracker.UpdateTabBarVisible() #26784

Marioo1357 opened this issue Dec 23, 2024 · 0 comments · May be fixed by #26786
Labels
area-controls-shell Shell Navigation, Routes, Tabs, Flyout migration-compatibility Xamarin.Forms to .NET MAUI Migration, Upgrade Assistant, Try-Convert platform/iOS 🍎 t/bug Something isn't working

Comments

@Marioo1357
Copy link

Marioo1357 commented Dec 23, 2024

Description

Sometimes (like a 0.1%) the null reference occurs in ShellPageRendererTracker.UpdateTabBarVisible() on ios.
In this method there are not a null checks for 'ViewController' and 'Page'.

I'll attach pull request in comment that fix the crash.
There is a chance that it just replace the crash by not hiding ShellTabBar when code call it

It happens when user navigate from shell tab page to any basic ContentPage where tab bar should not be visible.
Exception catched on Shell.SetTabBarIsVisible(this, false); in page constructor:

 protected BasePage(PageViewModelBase vm) : base(vm)
    {
        Shell.SetTabBarIsVisible(this, false);
        InitializeComponent();
   }

Steps to Reproduce

No response

Link to public reproduction project repository

No response

Version with bug

9.0.21 SR2.1

Is this a regression from previous behavior?

Yes, this used to work in Xamarin.Forms

Last version that worked well

Unknown/Other

Affected platforms

iOS

Affected platform versions

iOS 17, 18

Did you find any workaround?

In attached pullrequest

Relevant log output

System.NullReferenceException: Arg_NullReferenceException\n   at Microsoft.Maui.Controls.Platform.Compatibility.ShellPageRendererTracker.UpdateTabBarVisible()\n   at Microsoft.Maui.Controls.Platform.Compatibility.ShellPageRendererTracker.UpdateShellToMyPage()\n   at Microsoft.Maui.Controls.Platform.Compatibility.ShellPageRendererTracker.SetAppeared()\n   at Microsoft.Maui.Controls.Platform.Compatibility.ShellPageRendererTracker.PageAppearing(Object sender, EventArgs e)\n   at Microsoft.Maui.Controls.Page.SendAppearing()\n   at Microsoft.Maui.Controls.Shell.SendPageAppearing(Page page)\n   at Microsoft.Maui.Controls.ShellSection.PresentedPageAppearing()\n   at Microsoft.Maui.Controls.ShellSection.\u003CPresentedPageAppearing\u003Eg_OnPresentedPageParentSet|89_0(Object sender, EventArgs e)\n   at Microsoft.Maui.Controls.Element.OnParentSet()\n   at Microsoft.Maui.Controls.NavigableElement.OnParentSet()\n   at Microsoft.Maui.Controls.Page.OnParentSet()\n   at Microsoft.Maui.Controls.Element.SetParent(Element value)\n   at Microsoft.Maui.Controls.Element.OnChildAdded(Element child)\n   at Microsoft.Maui.Controls.ShellSection.OnChildAdded(Element child)\n   at Microsoft.Maui.Controls.Element.AddLogicalChild(Element element)\n   at Microsoft.Maui.Controls.ShellSection.OnPushAsync(Page page, Boolean animated)\n   at Microsoft.Maui.Controls.ShellSection.PushStackOfPages(List\u00601 pages, Nullable\u00601 animate)\n   at Microsoft.Maui.Controls.ShellSection.GoToAsync(ShellNavigationRequest request, ShellRouteParameters queryData, IServiceProvider services, Nullable\u00601 animate, Boolean isRelativePopping)\n   at Microsoft.Maui.Controls.ShellNavigationManager.GoToAsync(ShellNavigationParameters shellNavigationParameters, ShellNavigationRequest navigationRequest)\n   at Pomelo.App.Core.Helpers.MainThreadHelper.InvokeOnMainThreadAsync(Func\u00601 action)\n   at Pomelo.App.Core.Services.Core.NavigationService.GoToAsync(String path, IDictionary\u00602 parameters, Boolean withAnimation)\n   at Pomelo.App.Core.ViewModels.Base.ViewModelBase.DoActionAsync(Task action)\n   at CommunityToolkit.Mvvm.Input.AsyncRelayCommand.AwaitAndThrowIfFailed(Task )\n   at System.Threading.Tasks.Task.\u003C\u003Ec.\u003CThrowAsync\u003Eb128_0(Object state)\n   at Foundation.NSAsyncSynchronizationContextDispatcher.Apply()","ModelException":{"Type":"System.NullReferenceException","Message":"Arg_NullReferenceException","StackTrace":"   at Microsoft.Maui.Controls.Platform.Compatibility.ShellPageRendererTracker.UpdateTabBarVisible()\n   at Microsoft.Maui.Controls.Platform.Compatibility.ShellPageRendererTracker.UpdateShellToMyPage()\n   at Microsoft.Maui.Controls.Platform.Compatibility.ShellPageRendererTracker.SetAppeared()\n   at Microsoft.Maui.Controls.Platform.Compatibility.ShellPageRendererTracker.PageAppearing(Object sender, EventArgs e)\n   at Microsoft.Maui.Controls.Page.SendAppearing()\n   at Microsoft.Maui.Controls.Shell.SendPageAppearing(Page page)\n   at Microsoft.Maui.Controls.ShellSection.PresentedPageAppearing()\n   at Microsoft.Maui.Controls.ShellSection.\u003CPresentedPageAppearing\u003EgOnPresentedPageParentSet|89_0(Object sender, EventArgs e)\n   at Microsoft.Maui.Controls.Element.OnParentSet()\n   at Microsoft.Maui.Controls.NavigableElement.OnParentSet()\n   at Microsoft.Maui.Controls.Page.OnParentSet()\n   at Microsoft.Maui.Controls.Element.SetParent(Element value)\n   at Microsoft.Maui.Controls.Element.OnChildAdded(Element child)\n   at Microsoft.Maui.Controls.ShellSection.OnChildAdded(Element child)\n   at Microsoft.Maui.Controls.Element.AddLogicalChild(Element element)\n   at Microsoft.Maui.Controls.ShellSection.OnPushAsync(Page page, Boolean animated)\n   at Microsoft.Maui.Controls.ShellSection.PushStackOfPages(List\u00601 pages, Nullable\u00601 animate)\n   at Microsoft.Maui.Controls.ShellSection.GoToAsync(ShellNavigationRequest request, ShellRouteParameters queryData, IServiceProvider services, Nullable\u00601 animate, Boolean isRelativePopping)\n   at Microsoft.Maui.Controls.ShellNavigationManager.GoToAsync(ShellNavigationParameters shellNavigationParameters, ShellNavigationRequest navigationRequest)\n   at Pomelo.App.Core.Helpers.MainThreadHelper.InvokeOnMainThreadAsync(Func\u00601 action)\n   at Pomelo.App.Core.Services.Core.NavigationService.GoToAsync(String path, IDictionary\u00602 parameters, Boolean withAnimation)\n   at Pomelo.App.Core.ViewModels.Base.ViewModelBase.DoActionAsync(Task action)\n   at CommunityToolkit.Mvvm.Input.AsyncRelayCommand.AwaitAndThrowIfFailed(Task )\n   at System.Threading.Tasks.Task.\u003C\u003Ec.\u003CThrowAsync\u003Eb_128_0(Object state)\n   at Foundation.NSAsyncSynchronizationContextDispatcher.Apply()","Frames":[

{"ClassName":"Microsoft.Maui.Controls.Platform.Compatibility.ShellPageRendererTracker","MethodName":"UpdateTabBarVisible","FileName":null,"LineNumber":null}
,{"ClassName":"Microsoft.Maui.Controls.Platform.Compatibility.ShellPageRendererTracker","MethodName":"UpdateShellToMyPage","FileName":null,"LineNumber":null},{"ClassName":"Microsoft.Maui.Controls.Platform.Compatibility.ShellPageRendererTracker","MethodName":"SetAppeared","FileName":null,"LineNumber":null},{"ClassName":"Microsoft.Maui.Controls.Platform.Compatibility.ShellPageRendererTracker","MethodName":"PageAppearing","FileName":null,"LineNumber":null},{"ClassName":null,"MethodName":null,"FileName":null,"LineNumber":null},{"ClassName":"Microsoft.Maui.Controls.Page","MethodName":"SendAppearing","FileName":null,"LineNumber":null},{"ClassName":"Microsoft.Maui.Controls.Shell","MethodName":"SendPageAppearing","FileName":null,"LineNumber":null},{"ClassName":"Microsoft.Maui.Controls.ShellSection","MethodName":"PresentedPageAppearing","FileName":null,"LineNumber":null},{"ClassName":"Microsoft.Maui.Controls.ShellSection","MethodName":"\u003CPresentedPageAppearing\u003Eg_OnPresentedPageParentSet|89_0","FileName":null,"LineNumber":null},{"ClassName":"Microsoft.Maui.Controls.Element","MethodName":"OnParentSet","FileName":null,"LineNumber":null},{"ClassName":"Microsoft.Maui.Controls.NavigableElement","MethodName":"OnParentSet","FileName":null,"LineNumber":null},{"ClassName":"Microsoft.Maui.Controls.Page","MethodName":"OnParentSet","FileName":null,"LineNumber":null},{"ClassName":"Microsoft.Maui.Controls.Element","MethodName":"SetParent","FileName":null,"LineNumber":null},{"ClassName":"Microsoft.Maui.Controls.Element","MethodName":"OnChildAdded","FileName":null,"LineNumber":null},{"ClassName":"Microsoft.Maui.Controls.ShellSection","MethodName":"OnChildAdded","FileName":null,"LineNumber":null},{"ClassName":"Microsoft.Maui.Controls.Element","MethodName":"AddLogicalChild","FileName":null,"LineNumber":null},{"ClassName":"Microsoft.Maui.Controls.ShellSection","MethodName":"OnPushAsync","FileName":null,"LineNumber":null},{"ClassName":"Microsoft.Maui.Controls.ShellSection\u002B\u003CPushStackOfPages\u003Ed68","MethodName":"MoveNext","FileName":null,"LineNumber":null},{"ClassName":"System.Runtime.ExceptionServices.ExceptionDispatchInfo","MethodName":"Throw","FileName":null,"LineNumber":null},{"ClassName":"System.Runtime.CompilerServices.TaskAwaiter","MethodName":"ThrowForNonSuccess","FileName":null,"LineNumber":null},{"ClassName":"System.Runtime.CompilerServices.TaskAwaiter","MethodName":"HandleNonSuccessAndDebuggerNotification","FileName":null,"LineNumber":null},{"ClassName":"Microsoft.Maui.Controls.ShellSection\u002B\u003CGoToAsync\u003Ed65","MethodName":"MoveNext","FileName":null,"LineNumber":null},{"ClassName":"System.Runtime.ExceptionServices.ExceptionDispatchInfo","MethodName":"Throw","FileName":null,"LineNumber":null},{"ClassName":"System.Runtime.CompilerServices.TaskAwaiter","MethodName":"ThrowForNonSuccess","FileName":null,"LineNumber":null},{"ClassName":"System.Runtime.CompilerServices.TaskAwaiter","MethodName":"HandleNonSuccessAndDebuggerNotification","FileName":null,"LineNumber":null},{"ClassName":"Microsoft.Maui.Controls.ShellNavigationManager\u002B\u003CGoToAsync\u003Ed14","MethodName":"MoveNext","FileName":null,"LineNumber":null},{"ClassName":"System.Runtime.ExceptionServices.ExceptionDispatchInfo","MethodName":"Throw","FileName":null,"LineNumber":null},{"ClassName":"System.Runtime.CompilerServices.TaskAwaiter","MethodName":"ThrowForNonSuccess","FileName":null,"LineNumber":null},{"ClassName":"System.Runtime.CompilerServices.TaskAwaiter","MethodName":"HandleNonSuccessAndDebuggerNotification","FileName":null,"LineNumber":null}
@Marioo1357 Marioo1357 added the t/bug Something isn't working label Dec 23, 2024
@MartyIX MartyIX added platform/iOS 🍎 area-controls-shell Shell Navigation, Routes, Tabs, Flyout migration-compatibility Xamarin.Forms to .NET MAUI Migration, Upgrade Assistant, Try-Convert labels Dec 25, 2024
@PureWeen PureWeen added this to the .NET 9 Servicing milestone Dec 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-controls-shell Shell Navigation, Routes, Tabs, Flyout migration-compatibility Xamarin.Forms to .NET MAUI Migration, Upgrade Assistant, Try-Convert platform/iOS 🍎 t/bug Something isn't working
Projects
Status: Todo
Development

Successfully merging a pull request may close this issue.

3 participants