maui
maui copied to clipboard
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
I have the same issue.
I have connect to local ipad and when app start gets an following error: ... Loaded assembly: /private/var/containers/Bundle/Application/21B18619-86A4-4317-B9F5-390D3A1DA737/StressTracker.Client.app/System.Net.Http.dll [External] Loaded assembly: /private/var/containers/Bundle/Application/21B18619-86A4-4317-B9F5-390D3A1DA737/StressTracker.Client.app/System.Net.Primitives.dll [External] Loaded assembly: /private/var/containers/Bundle/Application/21B18619-86A4-4317-B9F5-390D3A1DA737/StressTracker.Client.app/System.Numerics.Vectors.dll [External] Loaded assembly: /private/var/containers/Bundle/Application/21B18619-86A4-4317-B9F5-390D3A1DA737/StressTracker.Client.app/System.Net.Sockets.dll [External] Loaded assembly: /private/var/containers/Bundle/Application/21B18619-86A4-4317-B9F5-390D3A1DA737/StressTracker.Client.app/System.Drawing.Primitives.dll [External] Loaded assembly: /private/var/containers/Bundle/Application/21B18619-86A4-4317-B9F5-390D3A1DA737/StressTracker.Client.app/System.Private.Uri.dll [External] The app has been terminated.
do we need any setting?
I'm facing same issue ? Any suggestions ?
Loaded assembly: /private/var/containers/Bundle/Application/04806506-C300-4FAA-8B16-2C3FB8BDE211/Mobile.app/Microsoft.iOS.dll [External] Loaded assembly: /private/var/containers/Bundle/Application/04806506-C300-4FAA-8B16-2C3FB8BDE211/Mobile.app/System.Runtime.dll [External] Loaded assembly: /private/var/containers/Bundle/Application/04806506-C300-4FAA-8B16-2C3FB8BDE211/Mobile.app/System.Collections.dll [External] Loaded assembly: /private/var/containers/Bundle/Application/04806506-C300-4FAA-8B16-2C3FB8BDE211/Mobile.app/System.Runtime.InteropServices.dll [External] Loaded assembly: /private/var/containers/Bundle/Application/04806506-C300-4FAA-8B16-2C3FB8BDE211/Mobile.app/System.Threading.Thread.dll [External] Loaded assembly: /private/var/containers/Bundle/Application/04806506-C300-4FAA-8B16-2C3FB8BDE211/Mobile.app/System.Threading.dll [External] Loaded assembly: /private/var/containers/Bundle/Application/04806506-C300-4FAA-8B16-2C3FB8BDE211/Mobile.app/System.Net.Http.dll [External] Loaded assembly: /private/var/containers/Bundle/Application/04806506-C300-4FAA-8B16-2C3FB8BDE211/Mobile.app/System.Net.Primitives.dll [External] Loaded assembly: /private/var/containers/Bundle/Application/04806506-C300-4FAA-8B16-2C3FB8BDE211/Mobile.app/System.Numerics.Vectors.dll [External] The app has been terminated.
Same issue with iPhone.
Any solution?
the same, 17.5 preview 1
Same, except the app also terminates on the iPhone. The app runs fine without the debugger.
https://github.com/unoplatform/uno/issues/10748
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?
None.
I am also struggling with this issue. I cannot debug my app
Same issue here, with a brand new .NET MAUI application with .NET7. Up up up! The hard point is that we have no more logs to understand a possible cause. (tested on a local iPhone and Simulator)
Same issue here. App works fine in the simulator and testable via Testflight. But not via Remote debugging. Same message, no error log of some sorts.
The only way I've found of debugging the iOS app was to use Visual Studio for Mac
Thanks for the issue report @hunsra! This issue appears to be a problem with Visual Studio, so we ask that you use the VS feedback tool to report the issue. That way it will get to the routed to the team that owns this experience in VS.
If you encounter a problem with Visual Studio, we want to know about it so that we can diagnose and fix it. By using the Report a Problem tool, you can collect detailed information about the problem, and send it to Microsoft with just a few button clicks.
- 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 issue will be automatically closed in 3 days if there are no further comments.
I'm having the same issue after upgrading to the latest VS 17.4.4 and Xcode 14.1 and the phone to the iOS 16.1.2
Unable to debug my iOS application which is very problematic 🥺
And the msftbot seem to close all these issues since it considers them related to VS, but we have no place to trace if any of these issues were able to be fixed, or if there are any workarounds ... like: https://github.com/dotnet/maui/issues/11324
Looks like we'll have to ping this issue every 3 days to keep it open if we want to have any feedback !
I'm having the same issue after upgrading to the latest VS 17.4.4 and Xcode 14.1 and the phone to the iOS 16.1.2
Unable to debug my iOS application which is very problematic 🥺
And the msftbot seem to close all these issues since it considers them related to VS, but we have no place to trace if any of these issues were able to be fixed, or if there are any workarounds ... like: #11324
Looks like we'll have to ping this issue every 3 days to keep it open if we want to have any feedback !
Agree with you @peter-bozovic.
Same version as yours for VS and iOS, I have then tried with VS community 2022 17.5.0 Preview 3.0 and it worked (on Windows) after:
- A first unsuccessful deployment.
- Unplugged the iPhone from my computer, and rebooted the iPhone.
- I tried to start the application BEFORE reconnecting the iPhone to the computer. The app crashed several times.
- Reconnecting the iPhone to the computer I was then able to, finally, deploy and debug correctly.
But it looks like a bit random, though...
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));
:
**System.InvalidOperationException:** 'RootViewController cannot be null'
I think this is the cause of the crash. AppDelegate
is extended from MauiUIApplicationDelegate
which is not yet properly initialized and its property Window.RootViewController
is null
On the iPhone device log:
Thread 0 crashed with ARM Thread State (64-bit):
x0: 0x0000000000000004 x1: 0x0000000000000000 x2: 0x0000000000008b00 x3: 0x0000000000000000
x4: 0x0000000000000000 x5: 0x00000000000000a1 x6: 0x0000000000000000 x7: 0x0000000000000000
x8: 0x000000016db3e8a8 x9: 0x0000000000000000 x10: 0x0000000102cb0340 x11: 0x0000120000001202
x12: 0x0000000000001200 x13: 0x0000000000000000 x14: 0x0000000000001200 x15: 0x0000120000001200
x16: 0x0000000000000131 x17: 0x0000000229371d40 x18: 0x0000000000000000 x19: 0x0000000102cb0328
x20: 0x0000000102cb0278 x21: 0x00000002242e17e0 x22: 0x0000000000000000 x23: 0x0000000000000000
x24: 0x0000000000008b00 x25: 0x0000000000008b01 x26: 0x0000000000008c00 x27: 0x0000000102cb0000
x28: 0x0000000000000001 fp: 0x000000016db3e920 lr: 0x000000021acd706c
sp: 0x000000016db3e890 pc: 0x000000020a86e41c cpsr: 0x60000000
far: 0x00000001028f0000 esr: 0x56000080 Address size fault
Thread 0 is the com.apple.main-thread
I 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.
I got latest iPhone 14 for tests, and after various strange error messages, cleaning, deleting, alot of restarting of everything, it seem to work now.
Maybe the only info found in https://github.com/dotnet/maui/issues/11324 is true, and the older devices are simply not fast enough to load all assemblies before VS can attach the debuger, and iOS kills it while taking too long to load ...
On my previous iPhone 8 used for testing, app seemed to be killed after 15s of loading. On the iPhone 14 it loads in around 10s and the debugger works ...
Maybe the only info found in #11324 is true, and the older devices are simply not fast enough to load all assemblies before VS can attach the debuger, and iOS kills it while taking too long to load ...
That sounds plausible. I am using a iPhone 7 and it sometimes (rarely) successfully attaches the debugger. On my newer iPad it works all the time.
Im using iPhone SE and also seeing that it crashes in different time windows.
Yes the watchdog is killing applications if they take too much time to start. Also, don't forget to disable the "Low Power Mode", where the watchdog is even shorter! This causes the app to be killed before the debugger even connects.
We're still getting issues on relatively recent devices like iPhone 11, unfortunately.
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.
Can't believe this issue was closed.
Hello lovely human, thank you for your comment on this issue. Because this issue has been closed for a period of time, please strongly consider opening a new issue linking to this issue instead to ensure better visibility of your comment. Thank you!
@Eilon considering there's already a devdiv bug for this (https://devdiv.visualstudio.com/DevDiv/_workitems/edit/1747084) is it expected to open another VS feedback issue that will ultimately end up being a xamarin/xamarin-macios issue?
@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 😉
Looks like the bot is there to sync everything so we need to keep this issue open.
Can I help in any way? Kinda want it fix ahah!