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
234 stars 13 forks source link

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

Open nsood9 opened 1 month ago

nsood9 commented 1 month 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 month 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 month 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 month 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 month 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 month 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 1 month 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 1 month 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?

nsood9 commented 3 weeks ago

I'm using VSC Version: 1.94.2 (Universal) and now it's not even debugging the app after it has been installed on the device once. It works just for the first time and then it never launches again for consecutive runs. I have to first uninstall it every time to reinstall and relaunch it.

github-actions[bot] commented 3 weeks ago

@emaf, the 'needs-more-info' label has been removed upon receiving further response from the original bug filer.

baebranch commented 3 weeks ago

Also having this issue on windows

Environment Information

Here is the status of your Android development environment:

Required components:

βœ“ Java SDK - INSTALLED (version '17.0.6')
    - Path: 'C:\Program Files\Java\jdk-17' (Workload)
    - Recommended detected locations:
        - 'c:\program files\common files\oracle\java' (PATH)

βœ“ Android SDK - INSTALLED
    - Path: 'C:\Users\<user>\AppData\Local\Android\sdk' (VSCode settings)

    βœ“ platforms/android-34 - INSTALLED (version '3')
    βœ“ build-tools/34.0.0 - INSTALLED (version '34.0.0')
    βœ“ platform-tools - INSTALLED (version '35.0.2')
    βœ“ cmdline-tools/11.0 - INSTALLED (version '11.0')

Optional components:

βœ“ Android Virtual Device (AVD) - COMPLETE
    - AVD Path: 'C:\Users\<user>\.android\avd'
    - AVD devices - DETECTED ('Pixel8API35')

    βœ“ emulator - INSTALLED (version '35.2.10')
    βœ“ system-images/android-34/google_apis/x86_64 - INSTALLED (version '14')
    βœ“ system-images/android-35/google_apis_playstore/x86_64 - INSTALLED (version '8')

IMPORTANT:

mauroa commented 3 weeks ago

@nsood9 the version you should ensure to update is the .NET MAUI version, not the VS Code version. As mentioned above, please install .NET MAUI 1.5.12 or 1.5.19. Then, please make sure to also have C# DevKit 1.12.37 and C# 2.54.20. These versions are for the extensions that allows you to build and debug .NET and MAUI applications in VS Code, so please try with it. Also, the platform you are using is iOS or Android? I don't see that specified in the bug description. Also, if you can share the information that was requested before, it would be helful. Thanks for your help.

mauroa commented 3 weeks ago

@baebranch can you give us more information about your issue? I assume it's when trying to debug an Android application in Windows. Are you trying with a new .MAUI app or another app? Is there any difference between both cases? Are you trying with emulator or physical device? Any other information or log/output you might provide would be helpful. Thanks.

baebranch commented 3 weeks ago

@baebranch can you give us more information about your issue? I assume it's when trying to debug an Android application in Windows. Are you trying with a new .MAUI app or another app? Is there any difference between both cases? Are you trying with emulator or physical device? Any other information or log/output you might provide would be helpful. Thanks.

I'm targeting the android platform on windows with a new .NET MAUI app. There is no difference between the case, both emulator and physical device have the same issue. I also updated the to the latest pre-release versions of the extensions and the problem persists.

mauroa commented 1 week ago

@baebranch let's keep following up in the linked bug you started. Looks like this issue is a bit different and potentially with a different platform, so let's @nsood9 get back with the requested information while we follow up specifically on your linked issue