dotnet / maui

.NET MAUI is the .NET Multi-platform App UI, a framework for building native device applications spanning mobile, tablet, and desktop.
https://dot.net/maui
MIT License
22.24k stars 1.76k forks source link

Maui.Controls.Handlers.Compatibility.NavigationRenderer.ParentingViewController: Object reference not set to an instance of an object #25726

Open PramodMAUI opened 1 week ago

PramodMAUI commented 1 week ago

Description

Getting below exception in iOS app only:

{System.NullReferenceException: Object reference not set to an instance of an object. at Microsoft.Maui.Controls.Handlers.Compatibility.NavigationRenderer.ParentingViewController.WillMoveToParentViewController(UIViewController parent) 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 61 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 xxxxx.Mobile.Program.Main(String[] args

When I manipulate the navigation stack while loading another page, the application crashes. For example, suppose I have Page1 and Page2 in the navigation stack, and I navigate to Page3 from Page2. While initializing the Page3 object, I remove Page2 from the navigation stack. After Page3 finishes loading, the application crashes.

I tried removal of page from navigation stack on Mainthread.

Steps to Reproduce

When I manipulate the navigation stack while loading another page, the application crashes. For example, suppose I have Page1 and Page2 in the navigation stack, and I navigate to Page3 from Page2. While initializing the Page3 object, I remove Page2 from the navigation stack. After Page3 finishes loading, the application crashes.

Link to public reproduction project repository

No response

Version with bug

8.0.40 SR5

Is this a regression from previous behavior?

Yes, this used to work in Xamarin.Forms

Last version that worked well

No response

Affected platforms

iOS

Affected platform versions

iOS 16, iOS 17, iOS 18

Did you find any workaround?

No response

Relevant log output

No response

Zhanglirong-Winnie commented 1 week ago

Could you provide us with a sample project so we can investigate it further? Looking forward to your reply!

eshalisa commented 1 week ago

I also recently had issues with this. I don't know how to reproduce but here are the two call stacks from Sentry: Image Image

PramodMAUI commented 4 days ago

@Zhanglirong-Winnie @jfversluis While navigating to Third page app crashes. Please find sample project here: https://github.com/PramodMAUI/iOSCrashWhenManipulatingStack/tree/main

PramodMAUI commented 3 days ago

Hi @Zhanglirong-Winnie Any update on this? Are you able to reproduce this issue?

jbeacham commented 3 days ago

We are having this same issue in our app. Would love to see an answer/solution. Will be migrating from Xamarin to MAUI for an app hosting millions of users in the next couple months.

hgarcianareia commented 3 days ago

Same error here. This is blocking our xamarin to MAUI migration launch

mattleibow commented 3 days ago

@PureWeen does this sound familiar?

sondrebh commented 2 days ago

We are seeing a lot of this in our MAUI app as well.

MichaelAtSway commented 1 day ago

Same issue here - I've tried moving the RemovePage call to different places in the app but the error still pops up and crashes the app...