xamarin / xamarin-macios

.NET for iOS, Mac Catalyst, macOS, and tvOS provide open-source bindings of the Apple SDKs for use with .NET managed languages such as C#
Other
2.47k stars 514 forks source link

iOS app crashes randomly on startup #21485

Open vsfeedback opened 2 weeks ago

vsfeedback commented 2 weeks ago

This issue has been moved from a ticket on Developer Community.


[severity:I'm unable to use this version] I am experiencing random startup crashes of iOS app when run on Simulator. This has been happening on all versions of .NET 8/9 I have tested, and can be reproduced via both VS and VS Code. The app usually starts up correctly several times, but on a subsequent build it starts crashing immediately after deploy and the only quite reliable way to fix it is to uninstall it from Simulator, git clean, and rebuild completely.

I attached the native crash dump below in errorreport.txt.

I made a recording of the issue below, which shows I ran the app, and it immediately crashed. Then I uninstalled it and rebuilt the slnf, and then ran again - which made the app run fine again. This sort of random behavior is what I am encountering with this issue.

Repro steps:

  1. Clone https://github.com/unoplatform/uno
  2. In src folder rename crosstargeting_override.props.sample to crosstargeting_override.props
  3. In the crosstargeting_override.props file uncomment prop and set it to net8.0-ios
  4. Open Uno.UI-netcoremobile-only.slnf and try to run SamplesApp.netcoremobile on iOS Simulator
  5. If it runs successfully, stop debugging, and make a small change like a debug writeline somewhere
  6. After several tries you should see the app crash immediately on startup

Original Comments

Feedback Bot on 10/12/2024, 04:43 AM:

We have directed your feedback to the appropriate engineering team for further evaluation. The team will review the feedback and notify you about the next steps.

Feedback Bot on 10/18/2024, 09:44 PM:

Thank you for sharing your feedback! Our teams prioritize action on product issues with broad customer impact. See details at: https://docs.microsoft.com/en-us/visualstudio/ide/report-a-problem#faq. In case you need answers to common questions or need assisted support, be sure to use https://visualstudio.microsoft.com/vs/support/. We’ll keep you posted on any updates to this feedback.

rolfbjarne commented 2 weeks ago

I can reproduce this with something like this:

$ dotnet build /bl
$ sed -i '' 's_// you can specify it here._System.Console.WriteLine("Hello world!");_' iOS/Main.iOS.cs
$ dotnet build /bl
# launch
yeahg-dev commented 1 day ago

Is this crash report also related to this issue? this crash infer app crashed as soon as launched.

Exception Type:  EXC_CRASH (SIGABRT)
Exception Codes: 0x0000000000000000, 0x0000000000000000
Triggered by Thread:  0

Thread 0 name:
Thread 0 name:
Thread 0 Crashed:
0   libsystem_kernel.dylib          0x00000001d9a882ec __pthread_kill + 8 (:-1)
1   libsystem_pthread.dylib         0x00000001ed87bc0c pthread_kill + 268 (pthread.c:1721)
2   libsystem_c.dylib               0x0000000198d87ba0 abort + 180 (abort.c:118)
3   FindingMateView                 0x000000010d573404 xamarin_unhandled_exception_handler + 60 (runtime.m:1134)
4   FindingMateView                 0x000000010d724ca0 mono_invoke_unhandled_exception_hook + 156 (exception.c:1219)
5   FindingMateView                 0x000000010d7bf748 mono_jit_exec_internal + 56 (driver.c:1374)
6   FindingMateView                 0x000000010d7bf748 mono_jit_exec + 396 (driver.c:1314)
7   FindingMateView                 0x000000010d57ba64 xamarin_main + 952 (monotouch-main.m:495)
8   FindingMateView                 0x000000010d8a4408 main + 64 (main.arm64.mm:555)
9   dyld                            0x00000001b45cf154 start + 2356 (dyldMain.cpp:1298)

Crash report

rolfbjarne commented 17 hours ago

@yeahg-dev no, that's an unhandled managed exception. You need to figure out what that exception was.

One way to do that is to add event handlers for the exception marshaling process; for more information see: https://github.com/MicrosoftDocs/xamarin-docs/blob/live/docs/ios/platform/exception-marshaling.md