Skip to content

System.NullReferenceException at NavigationRenderer.SetStatusBarStyle() #29535

@MateusMiotto

Description

@MateusMiotto

Description

After migrating from .net8 to .net9 this issue appeared.
After navigating from a login screen to the app's home page, which does not have a status bar, I receive a System.NullReferenceException

[0:] * Unhandled Exception *: System.NullReferenceException: Object reference not set to an instance of an object.
   at Microsoft.Maui.Controls.Handlers.Compatibility.NavigationRenderer.SetStatusBarStyle()
   at Microsoft.Maui.Controls.Handlers.Compatibility.NavigationRenderer.ViewWillAppear(Boolean animated)
   at Microsoft.Maui.Controls.Handlers.Compatibility.NavigationRenderer.__Registrar_Callbacks__.callback_1068_Microsoft_Maui_Controls_Handlers_Compatibility_NavigationRenderer_ViewWillAppear(IntPtr pobj, IntPtr sel, Byte p0, IntPtr* exception_gchandle)
--- End of stack trace from previous location ---
   at ObjCRuntime.Runtime.ThrowException(IntPtr gchandle) in /Users/builder/azdo/_work/1/s/xamarin-macios/src/ObjCRuntime/Runtime.cs:line 2742
   at UIKit.UIApplication.UIApplicationMain(Int32 argc, String[] argv, IntPtr principalClassName, IntPtr delegateClassName) in /Users/builder/azdo/_work/1/s/xamarin-macios/src/UIKit/UIApplication.cs:line 64
   at UIKit.UIApplication.Main(String[] args, Type principalClass, Type delegateClass) in /Users/builder/azdo/_work/1/s/xamarin-macios/src/UIKit/UIApplication.cs:line 96
   at App.Program.Main(String[] args) in C:\dev\App\Platforms\iOS\Program.cs:line 16

I am using NavigationPage.HasNavigationBar as false at HomePage but using it as true did not throw an exception in my tests
The Home page is a FlyoutPage and the details is the page with the tag NavigationPage.HasNavigationBar
This crash happens only when i try to navigate from login page to home page, if the application starts directly in that, the exception doesn't happens, using NavigationPage.HasNavigationBar as true or false.

Image

Steps to Reproduce

I don't know exactly the reason of that, so, don't have a sample

Link to public reproduction project repository

No response

Version with bug

9.0.70 SR7

Is this a regression from previous behavior?

Yes, this used to work in .NET MAUI

Last version that worked well

8.0.80 SR8

Affected platforms

iOS

Affected platform versions

iOS only

Did you find any workaround?

Nop

Relevant log output

Metadata

Metadata

Assignees

Labels

area-navigationNavigationPagehighIt doesn't work at all, crashes or has a big impact.platform/iospotential-regressionThis issue described a possible regression on a currently supported version., verification pendings/triagedIssue has been revieweds/verifiedVerified / Reproducible Issue ready for Engineering Triaget/bugSomething isn't working

Type

No type
No fields configured for issues without a type.

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions