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();
}
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}
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: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}