microsoft / vscode-dotnettools

This is a feedback repository to capture issues logged for the C# Dev Kit and related extensions from Visual Studio Code
Other
228 stars 12 forks source link

[BUG] <title> MAUI mobile app keep crashing after launch on the splash #1521

Open nsood9 opened 2 weeks ago

nsood9 commented 2 weeks ago

Describe the Issue

I'm able to run my MAUI app only once using Visual Studio Code, but it just keep crashing after getting stuck for sometime on the splash screen. This is what I get in the debug window:

The program 'TestApp.dll' has exited with code 0 (0x0).

It was working absolutely fine with VS mac. If I uninstall the app and do a fresh run it will start the app but if I'm re-running the app without uninstalling it manually, it just stuck on splash for few seconds and then crashes with the above mentioned error. I'm not even getting what exactly is the issue because there's no exception details or stack trace given apart from this:

The program 'TestApp.dll' has exited with code 0 (0x0).

Steps To Reproduce

  1. Debug a MAUI app for the first time it will work as expected.
  2. Stop or kill the app and try to debug it again, it will launch the app but will crash on splash screen after few seconds with this error in debug window: The program 'TestApp.dll' has exited with code 0 (0x0).
  3. Uninstall the app manually from the device and then debug it again from VS Code, it will work again for once till you try to debug it again.

If the app is not already installed on the device then only it runs as expected otherwise just keep crashing. So, every time I want to debug the app I have to uninstall it manually from the device before installing it.

Expected Behavior

It should run/debug smoothly every time without any issue or crash.

Environment Information

VS Code : Version: 1.94.1 (Universal)

emaf commented 1 week ago

@nsood9 Does this happen with a specific platform (i.e., iOS) and with physical devices or simulators?

Could you attach a sample project where we can reproduce this?

DDHSchmidt commented 1 week ago

Also experiencing this. Happens when I try to debug a physical device. First run works, although no breakpoints are hit! :/

Second run onwards crashes with the same messages as @nsood9 mentioned

I did not test with a blank MAUI project, because for the deployment to a physical device I'd need new certificates, provisioning profiles ApplicationId, etc... tons of stuff that would block me for another day...

Environment: macOS: Sonoma 14.5 dotnet --version: 9.0.100-rc.2.24474.11 maui-ios workload : 9.0.0-rc.2.24503/9.0.100-rc2 C# Dev Kit extension: v1.12.16 C# Extension: v2.50.27 .Net Maui Extension: v1.4.36

The actual Maui version we use in our app is: 8.0.90 The target iPad has iOS 17.7 Installed Xcode on mac is 16.0

Please help me. Coming back to iOS-development after a week only to find debugging broken is a pretty catastrophic experience.

rolfbjarne commented 1 week ago

I did not test with a blank MAUI project, because for the deployment to a physical device I'd need new certificates, provisioning profiles ApplicationId, etc... tons of stuff that would block me for another day...

You could re-use the same bundle identifier as in your main app, that way you can also use the same certificates, etc (remember to uninstall the app first manually from the device though).

DDHSchmidt commented 1 week ago

I did not test with a blank MAUI project, because for the deployment to a physical device I'd need new certificates, provisioning profiles ApplicationId, etc... tons of stuff that would block me for another day...

You could re-use the same bundle identifier as in your main app, that way you can also use the same certificates, etc (remember to uninstall the app first manually from the device though).

That is a great suggestion! And so simple that I honestly feel embarassed to not have thought of that myself 😅

I did that and... it works with a blank MAUI project. No crash on subsequent startups, all breakpoints are hit... it works as expected.

But where does that leave me? My main app still crashes on subsequent startup and the output gives me no hint of what the cause might be. I'm using around 20 NuGet packages, some handler modifications in MauiProgram.cs and lots of other stuff that a vanilla project doesn't have of course... Do I have to play whack-a-mole with all of these again or is there a simpler/faster approach to find the root cause?

rolfbjarne commented 1 week ago

@DDHSchmidt there are a few ways to gather some information (some may not be present, depending on exactly what's happening):

  1. Crash reports: https://github.com/xamarin/xamarin-macios/wiki/Diagnosis#crash-reports
  2. Device logs: https://support.apple.com/en-in/guide/console/cnsl1012/mac0

Also a few questions:

DDHSchmidt commented 2 days ago

I was about to retest today when the .Net Maui extension auto-upated to version v1.5.12 and magically it works again. Sorry, but unfortunately debugging now works again. But the whole toolchain is so fragile. I'll probably open a new issue soon... this one however: Not relevant for me anymore.

emaf commented 11 hours ago

@nsood9 could you try the latest version of the .NET MAUI extension (v1.5.12)? If you still face this issue, could you share the information mentioned in https://github.com/microsoft/vscode-dotnettools/issues/1521#issuecomment-2422729885?