AvaloniaUI / Avalonia

Develop Desktop, Embedded, Mobile and WebAssembly apps with C# and XAML. The most popular .NET UI client technology
https://avaloniaui.net
MIT License
25.41k stars 2.2k forks source link

iOS Simulator 17.4 "native crash" on Template Solution #15135

Closed dgor82 closed 2 months ago

dgor82 commented 6 months ago

Describe the bug

With a clean Avalonia Cross-Platform Template Solution, on macOS 14.4.1 (with Rider 2023.3.4) and Xcode 15.3, when running on iOS Simulator (17.4), it crashes with the following error output. On Android simulator AND on a physical iPhone connected to the mac via cable, there is no problem and the Hello World app launches as expected:

Native Crash Reporting

Got a SIGBUS while executing native code. This usually indicates a fatal error in the mono runtime or one of the native libraries used by your application.

================================================================= Native stacktrace:

0x1290540a0 - /Users/danielgorin/Library/Developer/CoreSimulator/Devices/F00DB27F-DD84-4D2E-89BA-5D24F7F7882B/data/Containers/Bundle/Application/5A144CE8-BE4B-4D97-977E-2C24183C8EF2/CheckMade.iOS.app/libmonosgen-2.0.dylib : mono_dump_native_crash_info 0x12900428c - /Users/danielgorin/Library/Developer/CoreSimulator/Devices/F00DB27F-DD84-4D2E-89BA-5D24F7F7882B/data/Containers/Bundle/Application/5A144CE8-BE4B-4D97-977E-2C24183C8EF2/CheckMade.iOS.app/libmonosgen-2.0.dylib : mono_handle_native_crash 0x128f6b798 - /Users/danielgorin/Library/Developer/CoreSimulator/Devices/F00DB27F-DD84-4D2E-89BA-5D24F7F7882B/data/Containers/Bundle/Application/5A144CE8-BE4B-4D97-977E-2C24183C8EF2/CheckMade.iOS.app/libmonosgen-2.0.dylib : mono_sigsegv_signal_handler_debug 0x13eb9b7e0 - /usr/lib/system/libsystem_platform.dylib : _sigtramp 0x1466b9ff8 - /Library/Developer/CoreSimulator/Volumes/iOS_21E213/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS 17.4.simruntime/Contents/Resources/RuntimeRoot/System/Library/Frameworks/OpenGLES.framework/libCoreVMClient.dylib : cvmsServerElementBuild 0x1466b5e34 - /Library/Developer/CoreSimulator/Volumes/iOS_21E213/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS 17.4.simruntime/Contents/Resources/RuntimeRoot/System/Library/Frameworks/OpenGLES.framework/libCoreVMClient.dylib : cvms_element_build_from_source 0x1466d6854 - /Library/Developer/CoreSimulator/Volumes/iOS_21E213/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS 17.4.simruntime/Contents/Resources/RuntimeRoot/System/Library/Frameworks/OpenGLES.framework/libCVMSPluginSupport.dylib : _Z26cvm_deferred_build_modularPv 0x13e767978 - /Library/Developer/CoreSimulator/Volumes/iOS_21E213/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS 17.4.simruntime/Contents/Resources/RuntimeRoot/usr/lib/system/libdispatch.dylib : _dispatch_client_callout 0x13e76fb10 - /Library/Developer/CoreSimulator/Volumes/iOS_21E213/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS 17.4.simruntime/Contents/Resources/RuntimeRoot/usr/lib/system/libdispatch.dylib : _dispatch_lane_serial_drain 0x13e770688 - /Library/Developer/CoreSimulator/Volumes/iOS_21E213/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS 17.4.simruntime/Contents/Resources/RuntimeRoot/usr/lib/system/libdispatch.dylib : _dispatch_lane_invoke 0x13e77ba84 - /Library/Developer/CoreSimulator/Volumes/iOS_21E213/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS 17.4.simruntime/Contents/Resources/RuntimeRoot/usr/lib/system/libdispatch.dylib : _dispatch_root_queue_drain_deferred_wlh 0x13e77b0d0 - /Library/Developer/CoreSimulator/Volumes/iOS_21E213/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS 17.4.simruntime/Contents/Resources/RuntimeRoot/usr/lib/system/libdispatch.dylib : _dispatch_workloop_worker_thread 0x13ed67814 - /usr/lib/system/libsystem_pthread.dylib : _pthread_wqthread 0x13ed665d4 - /usr/lib/system/libsystem_pthread.dylib : start_wqthread

================================================================= Basic Fault Address Reporting

Memory around native instruction pointer (0x13eb9b410):0x13eb9b400 28 24 40 a8 2a 2c 41 a8 21 80 00 91 42 00 05 cb ($@.,A.!...B... 0x13eb9b410 0c 34 00 a9 0e 3c 01 a9 42 00 01 f1 29 01 00 54 .4...<..B...)..T 0x13eb9b420 68 24 00 a9 6a 2c 01 a9 63 80 00 91 28 24 40 a8 h$..j,..c...($@. 0x13eb9b430 2a 2c 41 a8 21 80 00 91 42 80 00 f1 28 ff ff 54 ,A.!...B...(..T

================================================================= Native Crash Reporting

Got a SIGBUS while executing native code. This usually indicates a fatal error in the mono runtime or one of the native libraries used by your application.

An error has occurred in the native fault reporting. Some diagnostic information will be unavailable.

================================================================= Native stacktrace:

0x1290540a0 - /Users/danielgorin/Library/Developer/CoreSimulator/Devices/F00DB27F-DD84-4D2E-89BA-5D24F7F7882B/data/Containers/Bundle/Application/5A144CE8-BE4B-4D97-977E-2C24183C8EF2/CheckMade.iOS.app/libmonosgen-2.0.dylib : mono_dump_native_crash_info 0x12900428c - /Users/danielgorin/Library/Developer/CoreSimulator/Devices/F00DB27F-DD84-4D2E-89BA-5D24F7F7882B/data/Containers/Bundle/Application/5A144CE8-BE4B-4D97-977E-2C24183C8EF2/CheckMade.iOS.app/libmonosgen-2.0.dylib : mono_handle_native_crash 0x128f6b798 - /Users/danielgorin/Library/Developer/CoreSimulator/Devices/F00DB27F-DD84-4D2E-89BA-5D24F7F7882B/data/Containers/Bundle/Application/5A144CE8-BE4B-4D97-977E-2C24183C8EF2/CheckMade.iOS.app/libmonosgen-2.0.dylib : mono_sigsegv_signal_handler_debug 0x13eb9b7e0 - /usr/lib/system/libsystem_platform.dylib : _sigtramp 0x1466b9ff8 - /Library/Developer/CoreSimulator/Volumes/iOS_21E213/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS 17.4.simruntime/Contents/Resources/RuntimeRoot/System/Library/Frameworks/OpenGLES.framework/libCoreVMClient.dylib : cvmsServerElementBuild 0x1466b5e34 - /Library/Developer/CoreSimulator/Volumes/iOS_21E213/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS 17.4.simruntime/Contents/Resources/RuntimeRoot/System/Library/Frameworks/OpenGLES.framework/libCoreVMClient.dylib : cvms_element_build_from_source 0x1466d6854 - /Library/Developer/CoreSimulator/Volumes/iOS_21E213/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS 17.4.simruntime/Contents/Resources/RuntimeRoot/System/Library/Frameworks/OpenGLES.framework/libCVMSPluginSupport.dylib : _Z26cvm_deferred_build_modularPv 0x13e767978 - /Library/Developer/CoreSimulator/Volumes/iOS_21E213/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS 17.4.simruntime/Contents/Resources/RuntimeRoot/usr/lib/system/libdispatch.dylib : _dispatch_client_callout 0x13e76fb10 - /Library/Developer/CoreSimulator/Volumes/iOS_21E213/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS 17.4.simruntime/Contents/Resources/RuntimeRoot/usr/lib/system/libdispatch.dylib : _dispatch_lane_serial_drain 0x13e770688 - /Library/Developer/CoreSimulator/Volumes/iOS_21E213/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS 17.4.simruntime/Contents/Resources/RuntimeRoot/usr/lib/system/libdispatch.dylib : _dispatch_lane_invoke 0x13e77ba84 - /Library/Developer/CoreSimulator/Volumes/iOS_21E213/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS 17.4.simruntime/Contents/Resources/RuntimeRoot/usr/lib/system/libdispatch.dylib : _dispatch_root_queue_drain_deferred_wlh 0x13e77b0d0 - /Library/Developer/CoreSimulator/Volumes/iOS_21E213/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS 17.4.simruntime/Contents/Resources/RuntimeRoot/usr/lib/system/libdispatch.dylib : _dispatch_workloop_worker_thread 0x13ed67814 - /usr/lib/system/libsystem_pthread.dylib : _pthread_wqthread 0x13ed665d4 - /usr/lib/system/libsystem_pthread.dylib : start_wqthread

Exiting early due to double fault.

To Reproduce

  1. Set up new Avalonia Template solution for cross-platform on the described environment
  2. Launch iOS project in Debug or Release config on an iOS Simulator

Expected behavior

No response

Avalonia version

11.0.10

OS

iOS

Additional context

No response

dgor82 commented 6 months ago

Feel free to reach out to me if you want a screen sharing session to help reproduce or check my environment.

maxkatz6 commented 6 months ago

Please check 11.1.0-beta1 version or latest nightly builds.

StefanKoell commented 5 months ago

I'm seeing the same issue with bate and latest nightly. For me I see the same crashes for 17.2 and 17.01 simulators. Creating a blank MAUI template works flawlessly, btw. Not sure if this helps to pinpoint the issue.

ztl8702 commented 5 months ago

I had a similar crash issue today (sometimes SIGABRT instead of SIGBUS), on an Avalonia-based application codebase.

I haven't built this particular codebase for iOS in a while. I was last able to run it on iOS about two months ago. Since then, multiple variables have changed: .NET SDK version, Avalonia version, XCode's iOS SDK and simulator versions. So I haven't figured out what is the root cause.

Here is one of the macOS crash reports when running on iOS simulator: https://gist.github.com/ztl8702/6b5da929be35b89f46dcdfbef3c73424#file-gistfile1-txt


My workaround is just to use a real iPhone for now.

Dynaruid commented 4 months ago

I've found a temporary workaround for the issue where the app crashes on startup when targeting the iOS simulator. Noting that the app can start on a real device but crashes in the simulator, I tried to build the app based on x64 architecture. Since the arm64 iOS simulator can also run x64 iOS apps, try this command line: dotnet build -t:Run -r iossimulator-x64 -p:_DeviceName=:v2:udid=SIMULATOR_ID.

maxkatz6 commented 4 months ago

Can somebody report this issue to https://github.com/xamarin/xamarin-macios ? Preferably with a minimal repro.

ztl8702 commented 4 months ago

@maxkatz6 I think this might be related to https://github.com/dotnet/runtime/issues/98941 or https://github.com/xamarin/xamarin-macios/issues/20257, apparently fixed in .NET 8.0.5 (I haven't tested personally). But anyway high chance that this is unrelated to Avalonia.

redradist commented 2 months ago

@maxkatz6 I've faced the same issue in iOS Simulator for both 17.4 and 17.5 versions, crashed on start up

maxkatz6 commented 2 months ago

@redradist

  1. Switch to iossimulator-x64, see https://github.com/AvaloniaUI/Avalonia/issues/14933#issuecomment-2179878357. Or pin to latest SDK 8.0.301.
  2. Optional, but likely is required, switch to Metal - https://github.com/xamarin/xamarin-macios/issues/20657#issuecomment-2143514751

Closing this issue, as this problem is tracked in https://github.com/AvaloniaUI/Avalonia/issues/14933

redradist commented 2 months ago

@redradist

1. Switch to iossimulator-x64, see [iOS crashes on iossimulator-arm64 with OpenGLES rendering #14933 (comment)](https://github.com/AvaloniaUI/Avalonia/issues/14933#issuecomment-2179878357). Or pin to latest SDK 8.0.301.

2. Optional, but likely is required, switch to Metal - [Simple net8.0-ios app - native crash at startup (Avalonia XPAT project) xamarin/xamarin-macios#20657 (comment)](https://github.com/xamarin/xamarin-macios/issues/20657#issuecomment-2143514751)

Closing this issue, as this problem is tracked in #14933

@maxkatz6 Why switch to iossimulator-x64 if I work on MacBook M1 Pro ?