unoplatform / uno

Open-source platform for building cross-platform native Mobile, Web, Desktop and Embedded apps quickly. Create rich, C#/XAML, single-codebase apps from any IDE. Hot Reload included! 90m+ NuGet Downloads!!
https://platform.uno
Apache License 2.0
9.08k stars 736 forks source link

iOS App is getting killed by Watchdog on physical device when debugging #10748

Open jeromelaban opened 1 year ago

jeromelaban commented 1 year ago

I'm having a very annoying issue right now regarding iOS. I can't debug on a physical device because the application is being killed by iOS Watchdog. I don't understand why since it's working fine on the simulator.

Here is the debug output.

Loaded assembly: /private/var/containers/Bundle/Application/0498628C-A09A-4DA8-B542-E16C7E411FBC/ApplicationTemplate.Mobile.app/System.Collections.dll [External]
Loaded assembly: /private/var/containers/Bundle/Application/0498628C-A09A-4DA8-B542-E16C7E411FBC/ApplicationTemplate.Mobile.app/System.Runtime.Numerics.dll [External]
Loaded assembly: /private/var/containers/Bundle/Application/0498628C-A09A-4DA8-B542-E16C7E411FBC/ApplicationTemplate.Mobile.app/System.Security.Cryptography.Primitives.dll [External]
Loaded assembly: /private/var/containers/Bundle/Application/0498628C-A09A-4DA8-B542-E16C7E411FBC/ApplicationTemplate.Mobile.app/System.Formats.Asn1.dll [External]
Loaded assembly: /private/var/containers/Bundle/Application/0498628C-A09A-4DA8-B542-E16C7E411FBC/ApplicationTemplate.Mobile.app/System.Collections.Concurrent.dll [External]
Loaded assembly: /private/var/containers/Bundle/Application/0498628C-A09A-4DA8-B542-E16C7E411FBC/ApplicationTemplate.Mobile.app/System.Security.Cryptography.Encoding.dll [External]
Loaded assembly: /private/var/containers/Bundle/Application/0498628C-A09A-4DA8-B542-E16C7E411FBC/ApplicationTemplate.Mobile.app/System.Security.Cryptography.Algorithms.dll [External]
Loaded assembly: /private/var/containers/Bundle/Application/0498628C-A09A-4DA8-B542-E16C7E411FBC/ApplicationTemplate.Mobile.app/System.Collections.NonGeneric.dll [External]
Loaded assembly: /private/var/containers/Bundle/Application/0498628C-A09A-4DA8-B542-E16C7E411FBC/ApplicationTemplate.Mobile.app/System.Security.Cryptography.X509Certificates.dll [External]
Loaded assembly: /private/var/containers/Bundle/Application/0498628C-A09A-4DA8-B542-E16C7E411FBC/ApplicationTemplate.Mobile.app/System.Private.Uri.dll [External]
Loaded assembly: /private/var/containers/Bundle/Application/0498628C-A09A-4DA8-B542-E16C7E411FBC/ApplicationTemplate.Mobile.app/Microsoft.Win32.Primitives.dll [External]
Loaded assembly: /private/var/containers/Bundle/Application/0498628C-A09A-4DA8-B542-E16C7E411FBC/ApplicationTemplate.Mobile.app/System.Net.Primitives.dll [External]
Loaded assembly: /private/var/containers/Bundle/Application/0498628C-A09A-4DA8-B542-E16C7E411FBC/ApplicationTemplate.Mobile.app/System.Net.Security.dll [External]
Loaded assembly: /private/var/containers/Bundle/Application/0498628C-A09A-4DA8-B542-E16C7E411FBC/ApplicationTemplate.Mobile.app/System.Net.Quic.dll [External]
Loaded assembly: /private/var/containers/Bundle/Application/0498628C-A09A-4DA8-B542-E16C7E411FBC/ApplicationTemplate.Mobile.app/System.Net.NameResolution.dll [External]
Loaded assembly: /private/var/containers/Bundle/Application/0498628C-A09A-4DA8-B542-E16C7E411FBC/ApplicationTemplate.Mobile.app/System.IO.Compression.dll [External]
Loaded assembly: /private/var/containers/Bundle/Application/0498628C-A09A-4DA8-B542-E16C7E411FBC/ApplicationTemplate.Mobile.app/System.IO.Compression.Brotli.dll [External]
Loaded assembly: /private/var/containers/Bundle/Application/0498628C-A09A-4DA8-B542-E16C7E411FBC/ApplicationTemplate.Mobile.app/System.Threading.Channels.dll [External]
Loaded assembly: /private/var/containers/Bundle/Application/0498628C-A09A-4DA8-B542-E16C7E411FBC/ApplicationTemplate.Mobile.app/System.Runtime.InteropServices.RuntimeInformation.dll [External]
Loaded assembly: /private/var/containers/Bundle/Application/0498628C-A09A-4DA8-B542-E16C7E411FBC/ApplicationTemplate.Mobile.app/System.Net.Sockets.dll [External]
Loaded assembly: /private/var/containers/Bundle/Application/0498628C-A09A-4DA8-B542-E16C7E411FBC/ApplicationTemplate.Mobile.app/System.Net.NetworkInformation.dll [External]
Loaded assembly: /private/var/containers/Bundle/Application/0498628C-A09A-4DA8-B542-E16C7E411FBC/ApplicationTemplate.Mobile.app/System.Diagnostics.DiagnosticSource.dll [External]
Loaded assembly: /private/var/containers/Bundle/Application/0498628C-A09A-4DA8-B542-E16C7E411FBC/ApplicationTemplate.Mobile.app/System.Net.Http.dll [External]
Loaded assembly: /private/var/containers/Bundle/Application/0498628C-A09A-4DA8-B542-E16C7E411FBC/ApplicationTemplate.Mobile.app/System.Drawing.Primitives.dll [External]
Loaded assembly: /private/var/containers/Bundle/Application/0498628C-A09A-4DA8-B542-E16C7E411FBC/ApplicationTemplate.Mobile.app/System.Net.ServicePoint.dll [External]
Loaded assembly: /private/var/containers/Bundle/Application/0498628C-A09A-4DA8-B542-E16C7E411FBC/ApplicationTemplate.Mobile.app/System.Net.Requests.dll [External]
Loaded assembly: /private/var/containers/Bundle/Application/0498628C-A09A-4DA8-B542-E16C7E411FBC/ApplicationTemplate.Mobile.app/Microsoft.iOS.dll [External]
Loaded assembly: /private/var/containers/Bundle/Application/0498628C-A09A-4DA8-B542-E16C7E411FBC/ApplicationTemplate.Mobile.app/System.Linq.dll [External]
Loaded assembly: /private/var/containers/Bundle/Application/0498628C-A09A-4DA8-B542-E16C7E411FBC/ApplicationTemplate.Mobile.app/System.Collections.Immutable.dll [External]
Loaded assembly: /private/var/containers/Bundle/Application/0498628C-A09A-4DA8-B542-E16C7E411FBC/ApplicationTemplate.Mobile.app/System.ObjectModel.dll [External]
Loaded assembly: /private/var/containers/Bundle/Application/0498628C-A09A-4DA8-B542-E16C7E411FBC/ApplicationTemplate.Mobile.app/System.ComponentModel.Primitives.dll [External]
Loaded assembly: /private/var/containers/Bundle/Application/0498628C-A09A-4DA8-B542-E16C7E411FBC/ApplicationTemplate.Mobile.app/System.ComponentModel.dll [External]
Loaded assembly: /private/var/containers/Bundle/Application/0498628C-A09A-4DA8-B542-E16C7E411FBC/ApplicationTemplate.Mobile.app/System.Collections.Specialized.dll [External]
Loaded assembly: /private/var/containers/Bundle/Application/0498628C-A09A-4DA8-B542-E16C7E411FBC/ApplicationTemplate.Mobile.app/System.Diagnostics.TraceSource.dll [External]
Loaded assembly: /private/var/containers/Bundle/Application/0498628C-A09A-4DA8-B542-E16C7E411FBC/ApplicationTemplate.Mobile.app/System.Text.RegularExpressions.dll [External]
Loaded assembly: /private/var/containers/Bundle/Application/0498628C-A09A-4DA8-B542-E16C7E411FBC/ApplicationTemplate.Mobile.app/System.Linq.Expressions.dll [External]
Loaded assembly: /private/var/containers/Bundle/Application/0498628C-A09A-4DA8-B542-E16C7E411FBC/ApplicationTemplate.Mobile.app/System.Private.Xml.dll [External]
Loaded assembly: /private/var/containers/Bundle/Application/0498628C-A09A-4DA8-B542-E16C7E411FBC/ApplicationTemplate.Mobile.app/System.Private.Xml.Linq.dll [External]
Loaded assembly: /private/var/containers/Bundle/Application/0498628C-A09A-4DA8-B542-E16C7E411FBC/ApplicationTemplate.Mobile.app/System.ComponentModel.TypeConverter.dll [External]
Loaded assembly: /private/var/containers/Bundle/Application/0498628C-A09A-4DA8-B542-E16C7E411FBC/ApplicationTemplate.Mobile.app/Uno.Foundation.Logging.dll [External]
Loaded assembly: /private/var/containers/Bundle/Application/0498628C-A09A-4DA8-B542-E16C7E411FBC/ApplicationTemplate.Mobile.app/Uno.Foundation.dll [External]
Loaded assembly: /private/var/containers/Bundle/Application/0498628C-A09A-4DA8-B542-E16C7E411FBC/ApplicationTemplate.Mobile.app/Uno.Diagnostics.Eventing.dll [External]
Loaded assembly: /private/var/containers/Bundle/Application/0498628C-A09A-4DA8-B542-E16C7E411FBC/ApplicationTemplate.Mobile.app/Uno.UI.Dispatching.dll [External]
Loaded assembly: /private/var/containers/Bundle/Application/0498628C-A09A-4DA8-B542-E16C7E411FBC/ApplicationTemplate.Mobile.app/Uno.dll [External]
Loaded assembly: /private/var/containers/Bundle/Application/0498628C-A09A-4DA8-B542-E16C7E411FBC/ApplicationTemplate.Mobile.app/System.Linq.Queryable.dll [External]
Loaded assembly: /private/var/containers/Bundle/Application/0498628C-A09A-4DA8-B542-E16C7E411FBC/ApplicationTemplate.Mobile.app/Uno.Xaml.dll [External]
Loaded assembly: /private/var/containers/Bundle/Application/0498628C-A09A-4DA8-B542-E16C7E411FBC/ApplicationTemplate.Mobile.app/System.Runtime.CompilerServices.Unsafe.dll [External]
Loaded assembly: /private/var/containers/Bundle/Application/0498628C-A09A-4DA8-B542-E16C7E411FBC/ApplicationTemplate.Mobile.app/Uno.UI.Composition.dll [External]
Loaded assembly: /private/var/containers/Bundle/Application/0498628C-A09A-4DA8-B542-E16C7E411FBC/ApplicationTemplate.Mobile.app/System.Console.dll [External]
Loaded assembly: /private/var/containers/Bundle/Application/0498628C-A09A-4DA8-B542-E16C7E411FBC/ApplicationTemplate.Mobile.app/Uno.UI.dll [External]
Loaded assembly: /private/var/containers/Bundle/Application/0498628C-A09A-4DA8-B542-E16C7E411FBC/ApplicationTemplate.Mobile.app/Microsoft.Extensions.Logging.Abstractions.dll [External]
Loaded assembly: /private/var/containers/Bundle/Application/0498628C-A09A-4DA8-B542-E16C7E411FBC/ApplicationTemplate.Mobile.app/Chinook.StackNavigation.Abstractions.dll [External]
Loaded assembly: /private/var/containers/Bundle/Application/0498628C-A09A-4DA8-B542-E16C7E411FBC/ApplicationTemplate.Mobile.app/Chinook.SectionsNavigation.Abstractions.dll [External]
The app has been terminated.

Here is my configuration for debug.

<When Condition="'$(TargetFramework)'=='net6.0-ios'">
    <PropertyGroup>
        <MtouchExtraArgs>$(MtouchExtraArgs) --setenv=MONO_GC_PARAMS=soft-heap-limit=512m,nursery-size=64m,evacuation-threshold=66,major=marksweep,concurrent-sweep</MtouchExtraArgs>
        <MtouchExtraArgs>$(MtouchExtraArgs) --xml=./iOS/LinkerExclusions.xml --linkskip=$(AssemblyName)</MtouchExtraArgs>
        <!-- See https://github.com/unoplatform/uno/issues/9430 for more details. -->
        <MtouchExtraArgs>$(MtouchExtraArgs) --registrar:static</MtouchExtraArgs>
        <!-- See https://github.com/xamarin/xamarin-macios/issues/14812 for more details. -->
        <MtouchExtraArgs>$(MtouchExtraArgs) --marshal-objectivec-exceptions:disable</MtouchExtraArgs>
        <MtouchLink>Full</MtouchLink>
    </PropertyGroup>
    <Choose>
        <When Condition="'$(Configuration)'=='Debug'">
            <PropertyGroup>
                <CodesignEntitlements>./iOS/Entitlements.plist</CodesignEntitlements>
                <MtouchDebug>True</MtouchDebug>
                <MtouchExtraArgs>$(MtouchExtraArgs) --optimize=-remove-dynamic-registrar --setenv=MONO_LOG_LEVEL=debug --setenv=MONO_LOG_MASK=gc</MtouchExtraArgs>
                <Optimize>False</Optimize>
            </PropertyGroup>
            <PropertyGroup Condition="'$(Platform)'=='iPhone'">
                <CodesignKey>iPhone Developer</CodesignKey>
            </PropertyGroup>
        </When>
</When>

This is why I think it`s the iOS Watchdog. image image

Originally posted by @Soap-141 in https://github.com/unoplatform/uno/discussions/10746

jeromelaban commented 1 year ago

@Soap-141 can you try doing this: https://github.com/dotnet/maui/issues/11392#issuecomment-1355182295, and see what the stack trace looks like?

Soap-141 commented 1 year ago

@jeromelaban Yes, should be done next Monday. So to be sure you need the same crash report but with debug symbols?

spouliot commented 1 year ago

This behaviour can be duplicated without Uno, just dotnet new ios and VSfM.

I have not tried from Windows but I doubt that would change anything since it ends up being the SDK's mlaunch to install/launch the process to be debugged.

Soap-141 commented 1 year ago

Got some updates https://github.com/dotnet/maui/issues/9056 looks like MS bot wants to close the issue and that right now people are agreeing that it's device slowness issue even if it shouldn't be the case I'm using an iPhone 11 and it's not that old.

jeromelaban commented 1 year ago

It's not something we'll be able to fix on our end, in all cases, so we'll only be able to push on Microsoft to get this issue resolved.

MartinZikmund commented 1 year ago

@Soap-141 is this still relevant? It seems the linked issue on Microsoft side has been fixed

Soap-141 commented 1 year ago

@MartinZikmund Not fixed at all, they released an update and closed it for the x time. Sometimes it works on small apps.

jeromelaban commented 12 months ago

It was reported that recent versions of visual studio (17.8 and later) seem to have fixed this particular issue.

imsam67 commented 11 months ago

I've now started to experience this problem and I'm on VS 17.8.3. The start up does seem to take longer which makes watchdog kill the app. My setup is an iPhone Xs connected to my laptop via USB. This has been my setup for a long time and everything's been working fine but now startup takes too long and the app crashes.

bodeg commented 11 months ago

I'm on VS 17.8.2. with iPhone 6s Plus - fresh new Maui app crash on startup

Soap-141 commented 11 months ago

Yeah def not fix :/

Soap-141 commented 10 months ago

@bodeg Try to delete ~/Library/Caches/Xamarin/XMA/SDK/dotnet/ then connect to your mac with VS, then try to debug your app, this helped someone I know.

yeahg-dev commented 10 months ago

@bodeg Try to delete ~/Library/Caches/Xamarin/XMA/SDK/dotnet/ then connect to your mac with VS, then try to debug your app, this helped someone I know.

I struggled same issue, and this solution works for me👍 thank you!

bodeg commented 10 months ago

@bodeg Try to delete ~/Library/Caches/Xamarin/XMA/SDK/dotnet/ then connect to your mac with VS, then try to debug your app, this helped someone I know.

I struggled same issue, and this solution works for me👍 thank you!

Thanks for sharing. I am using VS on Windows with a iPhone connected via USB, no Mac involved.

Is that relevant to my configuration?

yeahg-dev commented 10 months ago

Thanks for sharing. I am using VS on Windows with a iPhone connected via USB, no Mac involved.

Is that relevant to my configuration?

I am using Visual Studio Code on Mac with iPhone connected via USB. It seems to be applied regardless of the development environment.

bodeg commented 10 months ago

Thanks for sharing. I am using VS on Windows with a iPhone connected via USB, no Mac involved. Is that relevant to my configuration?

I am using Visual Studio Code on Mac with iPhone connected via USB. It seems to be applied regardless of the development environment.

I tried deleting the cache files - still not working -> "The app has been terminated."

I deleted C:\Users###\AppData\Local\Xamarin\iOS

C:\Users###\AppData\Local\Xamarin\iOS\Caches\Xamarin\XMA\Cache was empty

Also, after the deployment, VS placed an icon on my iPhone. The application crash when the VS is connected - it runs fine when the VS is not in connected/debug

TheSundayDev commented 5 months ago

I have the same issue

jeromelaban commented 5 months ago

Note that is not a behavior we can fix, it's being tracked by microsoft https://github.com/dotnet/maui/issues/11392#issuecomment-1355182295. If you have any additional information about the issue over there, it will help troubleshoot it further.