maui: iOS Debugger Indicates App Has Terminated Immediately
Description
When using the iOS remote simulator in Visual Studio 17.3.0 Preview 5, after the initial use of the debugger, subsequent uses of the debugger fail to stay connected to the app, indicating “The app has been terminated”, even though the app successfully launches and stays running in the simulator.
Repro project: https://github.com/hunsra/iOSDebugger.App
Steps to Reproduce
- Create a new .NET MAUI App.
- Choose the “iPhone 13 Pro Max iOS 15.5” simulator from the list iOS Simulators targets.
- Debug the app.
- Press the stop debugging button on the toolbar.
- Debug the app again.
- Observe the app launch in the simulator, but the debugger detach and report “The app has been terminated.” in the Debug output window.
Version with bug
6.0.400
Last version that worked well
Unknown/Other
Affected platforms
iOS
Affected platform versions
iOS 15.5
Did you find any workaround?
If you close Visual Studio and re-open it, the debugger works once as described above.
Relevant log output
Build Log:
Build started...
1>------ Build started: Project: iOSDebugger, Configuration: Debug Any CPU ------
1>You are using a preview version of .NET. See: https://aka.ms/dotnet-core-preview
1>Executing SayHello Task to establish a connection to a Remote Server.
1> Properties:
1> SessionId=b92a0820222943055e8a343c271a5ad24afb06e716c984bec440a9277f42317b,
1> Addresss=192.168.0.188,
1> SshPort=22,
1> TcpPort=50727,
1> User=randy,
1> AppName=iOSDebugger,
1> VisualStudioProcessId=12564,
1> ContinueOnDisconnected=False
1>Detected signing identity:
1> Bundle Id: com.companyname.iosdebugger
1> App Id: com.companyname.iosdebugger
1>Skipping analyzers to speed up the build. You can execute 'Build' or 'Rebuild' command to run analyzers.
1>iOSDebugger -> D:\Repos\iOSDebugger\iOSDebugger\bin\Debug\net6.0-ios\iossimulator-x64\iOSDebugger.dll
1>Optimizing assemblies for size, which may change the behavior of the app. Be sure to test after publishing. See: https://aka.ms/dotnet-illink
1>/usr/bin/mdimport bin/Debug/net6.0-ios/iossimulator-x64/
2>------ Deploy started: Project: iOSDebugger, Configuration: Debug Any CPU ------
========== Build: 1 succeeded, 0 failed, 0 up-to-date, 0 skipped ==========
========== Deploy: 1 succeeded, 0 failed, 0 skipped ==========
Launching 'iOSDebugger' on 'iPhone 13 Pro Max iOS 15.5'...
Debug Log:
The app has been terminated.
Hot Reload Log:
17:05 47.75 iOSDebugger: Hot Reload session started
17:05 52.32 iOSDebugger: Hot Reload session complete
Xamarin Log:
Connection to 'mbp2017' completed successfully
The dotnet SDK is already installed. Version: '6.0.400-preview.22330.6'
dotnet validation completed
Sdk packs found: Microsoft.iOS.Sdk
The dotnet ios workload is already installed. Version: '15.4.430'
dotnet validation completed
Server Settings:
- mlaunch path: /Users/randy/Library/Caches/Xamarin/XMA/SDKs/dotnet/packs/Microsoft.iOS.Sdk/15.4.430/tools/bin/mlaunch
- Xcode version: 13.4
- Xcode path: /Applications/Xcode.app
Checking Xcode version compatibility...
Build properties for D:\Repos\iOSDebugger\iOSDebugger\iOSDebugger.csproj: VisualStudioProcessId: 12564, RunConfiguration: Default, ArchiveOnBuild: False, ArchivePath: , IsAppDistribution: False, SolutionPath: D:\Repos\iOSDebugger\iOSDebugger.sln, SolutionName: iOSDebugger, MessagingVersion: 15.4.430, DeviceSpecificBuild: false, TargetiOSDevice: , _iOSRuntimeIdentifier: iossimulator-x64, IsHotRestartBuild: False, _DotNetRootRemoteDirectory: /Users/randy\Library\Caches\Xamarin\XMA\SDKs\dotnet/, ServerSshPort: 22, ServerTcpPort: 50727, ServerUser: randy, ContinueOnDisconnected: False, ServerAddress: 192.168.0.188
SetSelectedDeviceAsync BEST Pixel 5 - API 31 (Android 12.0 - API 31)
Build properties for D:\Repos\iOSDebugger\iOSDebugger\iOSDebugger.csproj: VisualStudioProcessId: 12564, RunConfiguration: Default, ArchiveOnBuild: False, ArchivePath: , IsAppDistribution: False, SolutionPath: D:\Repos\iOSDebugger\iOSDebugger.sln, SolutionName: iOSDebugger, MessagingVersion: 15.4.430, DeviceSpecificBuild: false, TargetiOSDevice: , _iOSRuntimeIdentifier: iossimulator-x64, IsHotRestartBuild: False, _DotNetRootRemoteDirectory: /Users/randy\Library\Caches\Xamarin\XMA\SDKs\dotnet/, ServerSshPort: 22, ServerTcpPort: 50727, ServerUser: randy, ContinueOnDisconnected: False, ServerAddress: 192.168.0.188
Build properties for D:\Repos\iOSDebugger\iOSDebugger\iOSDebugger.csproj: VisualStudioProcessId: 12564, RunConfiguration: Default, ArchiveOnBuild: False, ArchivePath: , IsAppDistribution: False, SolutionPath: D:\Repos\iOSDebugger\iOSDebugger.sln, SolutionName: iOSDebugger, MessagingVersion: 15.4.430, DeviceSpecificBuild: false, TargetiOSDevice: , _iOSRuntimeIdentifier: iossimulator-x64, IsHotRestartBuild: False, _DotNetRootRemoteDirectory: /Users/randy\Library\Caches\Xamarin\XMA\SDKs\dotnet/, ServerSshPort: 22, ServerTcpPort: 50727, ServerUser: randy, ContinueOnDisconnected: False, ServerAddress: 192.168.0.188
Build properties for D:\Repos\iOSDebugger\iOSDebugger\iOSDebugger.csproj: VisualStudioProcessId: 12564, RunConfiguration: Default, ArchiveOnBuild: False, ArchivePath: , IsAppDistribution: False, SolutionPath: D:\Repos\iOSDebugger\iOSDebugger.sln, SolutionName: iOSDebugger, MessagingVersion: 15.4.430, DeviceSpecificBuild: false, TargetiOSDevice: , _iOSRuntimeIdentifier: iossimulator-x64, IsHotRestartBuild: False, _DotNetRootRemoteDirectory: /Users/randy\Library\Caches\Xamarin\XMA\SDKs\dotnet/, ServerSshPort: 22, ServerTcpPort: 50727, ServerUser: randy, ContinueOnDisconnected: False, ServerAddress: 192.168.0.188
Starting Simulator to launch App...
The Simulator has been started to launch App...
Build properties for D:\Repos\iOSDebugger\iOSDebugger\iOSDebugger.csproj: VisualStudioProcessId: 12564, RunConfiguration: Default, ArchiveOnBuild: False, ArchivePath: , IsAppDistribution: False, SolutionPath: D:\Repos\iOSDebugger\iOSDebugger.sln, SolutionName: iOSDebugger, MessagingVersion: 15.4.430, DeviceSpecificBuild: false, TargetiOSDevice: , _iOSRuntimeIdentifier: iossimulator-x64, IsHotRestartBuild: False, _DotNetRootRemoteDirectory: /Users/randy\Library\Caches\Xamarin\XMA\SDKs\dotnet/, ServerSshPort: 22, ServerTcpPort: 50727, ServerUser: randy, ContinueOnDisconnected: False, ServerAddress: 192.168.0.188
Build properties for D:\Repos\iOSDebugger\iOSDebugger\iOSDebugger.csproj: VisualStudioProcessId: 12564, RunConfiguration: Default, ArchiveOnBuild: False, ArchivePath: , IsAppDistribution: False, SolutionPath: D:\Repos\iOSDebugger\iOSDebugger.sln, SolutionName: iOSDebugger, MessagingVersion: 15.4.430, DeviceSpecificBuild: false, TargetiOSDevice: , _iOSRuntimeIdentifier: iossimulator-x64, IsHotRestartBuild: False, _DotNetRootRemoteDirectory: /Users/randy\Library\Caches\Xamarin\XMA\SDKs\dotnet/, ServerSshPort: 22, ServerTcpPort: 50727, ServerUser: randy, ContinueOnDisconnected: False, ServerAddress: 192.168.0.188
Build properties for D:\Repos\iOSDebugger\iOSDebugger\iOSDebugger.csproj: VisualStudioProcessId: 12564, RunConfiguration: Default, ArchiveOnBuild: False, ArchivePath: , IsAppDistribution: False, SolutionPath: D:\Repos\iOSDebugger\iOSDebugger.sln, SolutionName: iOSDebugger, MessagingVersion: 15.4.430, DeviceSpecificBuild: false, TargetiOSDevice: , _iOSRuntimeIdentifier: iossimulator-x64, IsHotRestartBuild: False, _DotNetRootRemoteDirectory: /Users/randy\Library\Caches\Xamarin\XMA\SDKs\dotnet/, ServerSshPort: 22, ServerTcpPort: 50727, ServerUser: randy, ContinueOnDisconnected: False, ServerAddress: 192.168.0.188
Build properties for D:\Repos\iOSDebugger\iOSDebugger\iOSDebugger.csproj: VisualStudioProcessId: 12564, RunConfiguration: Default, ArchiveOnBuild: False, ArchivePath: , IsAppDistribution: False, SolutionPath: D:\Repos\iOSDebugger\iOSDebugger.sln, SolutionName: iOSDebugger, MessagingVersion: 15.4.430, DeviceSpecificBuild: false, TargetiOSDevice: , _iOSRuntimeIdentifier: iossimulator-x64, IsHotRestartBuild: False, _DotNetRootRemoteDirectory: /Users/randy\Library\Caches\Xamarin\XMA\SDKs\dotnet/, ServerSshPort: 22, ServerTcpPort: 50727, ServerUser: randy, ContinueOnDisconnected: False, ServerAddress: 192.168.0.188
Starting Simulator to launch App...
The Simulator has been started to launch App...
Xamarin Hot Reload Log:
[5:05:41 PM] (iOSDebugger) .NET 6 Project references .NET MAUI.
[5:05:41 PM] (iOSDebugger) Starting Hot Reload session...
[5:05:42 PM] XAML Hot Reload initializing...
[5:05:45 PM] (iOSDebugger) Hot Reload: Initialized Agent.
[5:05:47 PM] XAML Hot Reload Connected and Ready.
[5:06:01 PM] (iOSDebugger) Stopping a Hot Reload session due to ExplicitlyEnded ...
[5:06:01 PM] Stopped Hot Reload session.
VS bug #1747084
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Reactions: 9
- Comments: 63 (8 by maintainers)
This issue is being closed due to inactivity. If this issue is still affecting you, please follow the steps above to use the VS Feedback Tool to report the issue.
Looks like the bot is there to sync everything so we need to keep this issue open.
There is no fix. They didn’t fix anything that corresponds to this ticket. They just closed the ticket with the flag “Try latest version”.
@jeromelaban that’s a great question and I’m trying to figure out what happened here. It seems there’s some bot I’m unfamiliar with that is syncing issues between GitHub and Azure DevOps but I’m not sure what it’s doing or why.
I’m working on figuring that out. In theory we just need the Azure DevOps issue (https://devdiv.visualstudio.com/DevDiv/_workitems/edit/1747084) but there’s something weird going on.
I’ll report back when I find out what’s happening.
In the meantime, just to be safe, don’t trust your microwave or electric toothbrush in case it’s the start of the robot uprising 😉
Here, I used the VS feedback tool. https://developercommunity.visualstudio.com/t/iOS-Debugger-Indicates-App-Has-Been-Te/10453966 the recording and all attachments are not visible for you guys but I did provided them.
Logs are collected and uploaded by default, but you can opt out of this if you want. It will make it much more difficult to figure out what’s going on though. It would be ideal if you can slim down your project to a minimal repro project that demonstrates the problem and that you can share.
Or if someone else following this issue has a reliable repro that they can share please go ahead and file your own VS feedback ticket. More data from more users helps.
This should be opened if it still is happening, but in the VS Feedback tool or in the macos repo.
I am also having the issue. I tried to change from Xamarin to .net MAUI because of this. I have seen similar issues dating back to 2016. This is ridiculous.
Considering just completely rebuilding my app using flutter because of this.
Can you please log this using the Report a Problem tool? That will enable us to get more information and prioritize easier. Go to the Visual Studio for Windows feedback tool or Visual Studio for Mac feedback tool to report the issue Close this bug, and consider adding a link to the VS Feedback issue so that others can follow its activity there.
This also happens to us. We have no way to get around this issue other than by debugging on an iOS simulator instead, but there are certain things that can only be tested on physical devices. We can run the app on device without the debugger attached, but then we can’t step through our code and we have to resort to putting
Console.WriteLine()everywhere to see what’s happening (🤮).I gave it a try tonight once again, and with my setup I was only able to reproduce this issue with the following crash report on
iOS 16.3.1 iPhone 8-VS 17.6.0 preview 1.0-MAUI .NET7:Where effectively the “crash” is due to the watchdog killing the application. In my case, I have tried in different scenarios:
In my case my device is a bit old, it can be great to have feedback from people that commented on this issue with more recent devices, to check if the reason is the same for them.
If yes, this is very probable that the reason of this crash are the .NET cold start + application initial load.
To check the
iOSnative logs on crash:Settings->Privacy & Security->Analytics & Improvements->Analytics Data->Xamarin.PreBuilt.iOS-YYYY-MM-DD-HHmmss.ips.I could find these two exceptions and logs which occurred right before the app crash. It is not wrote in the logs in every crash, because the apple main thread is also working with the RootViewController and it will crash the app sooner as the debugger stops at the exception in MAUI.
On the MAUI side in the
UIApplication.Main(args, null, typeof(AppDelegate));:I think this is the cause of the crash.
AppDelegateis extended fromMauiUIApplicationDelegatewhich is not yet properly initialized and its propertyWindow.RootViewControlleris nullOn the iPhone device log:
Thread 0 is the
com.apple.main-threadI think a workaround till MAUI fixes it could be to initialize the
MauiUIApplicationDelegate.Window.RootViewController, but I dont know yet how and where to do it.Same here, app starts, splash is showing, then the app is terminated. If I start it manually from the phone then, it starts and works fine. Any workaround so far?