Skip to content

Maui Shell ios crashes on navigation #16862

@PureWeen

Description

@PureWeen

Description

https://developercommunity.visualstudio.com/t/Maui-Shell-ios-crashes-on-navigation/10441135

I am intermittantly getting a null reference exception in Main when navigating in a Maui Shell iOS app. To be honest, I have not tried to reproduce this in Android, so I don’t know if it happens there.

Anyways, this seems to happen when you have multiple pages in a chain. Page A => Tab Page => Page B => Page C => Page D => Back to Page A.

I’ve seen it blow up on pages D and A. In my production app, there is only one page it’s blowing up on, but it does it pretty consistently.

This issue has been reported a few times before, but has always been closed because it can’t be reproduced. I’m adding a link to a sample project, screenshots, and logs. The sample project has produced the error, but you may have to go through the sequence (just click the buttons) many times. I’ve had it happen on the first try and I’ve not had it happen until the 20th try.

When it happens, it will dump you to Program.cs in UIApplication.Main with a null reference exception. You can’t catch it anywhere except for Program.cs, because it happens inside the inner workings. The screenshots are in the shared files.

This is a very critical bug. It is unpredicatable and it completely crashes the app. At this point, I have a page that crashes 3 out of every 4 times.

You can get to the sample project and supporting files at this link.

https://1drv.ms/f/s!AhJ6I4T65XJfgu4_8FhpL26cUoNQhA?e=QO6DBy

EDIT:

This may be my issue. I noticed on one of my web searches that there was a permanent issue with navigation after trying to call navigation off the main thread (#13538). That had me go look at my code, and I realized I’m not actually calling it on the main thread. I made the change in my sample project (uploaded the modified ViewModel.cs, but didn’t change the uploaded project) and tried to get it to happen. It didn’t.

I can’t try it in my main project right this second, but I will later to see if that resolves the issue. Even if it does, a better error message - like the one you normally get when you execute on the wrong thread - would be amazing. It’s also very odd that I’ve spent hundreds of hours working in this app and have never had a null reference crash happen on navigation.

At any rate, I’ll give it a try in my main app and report back.

EDIT #2

That wasn’t the problem. I did make that change, but I’m still getting the same error on my main application. I stepped through the code and verified that I am on the main thread. I included another screenshot that shows in the logic that I’m in the main thread.

I was also able to reproduce it again in the sample application. It took me about 20 times of doing it, but it does still happen.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions