runtime: Starting App on iOS fails with System.ExecutingEngineException
From @jhimes144 on Sun, 08 Jan 2023 04:51:56 GMT
This is an issue I have raised over in Avalonia here https://github.com/AvaloniaUI/Avalonia/issues/9934
To the best of our knowledge, the below method GetStringNative should not have any problem with AOT, and everything works fine on Android with AOT enabled. So far I’ve reproduced this on two separate code bases.
Steps to Reproduce
- Create a new dotnet solution using the Avalonia xplat template. See https://github.com/AvaloniaUI/avalonia-dotnet-templates
- Insert needed
CodesignKeyin project file for the ios project - Build and run the ios project on a physical ios device
Expected Behavior
The app runs
Actual Behavior
The following exception is raised on app startup
System.ExecutionEngineException: Attempting to JIT compile method '(wrapper managed-to-native) intptr Avalonia.OpenGL.GlBasicInfoInterface:wrapper_native_indirect_0x283931e40 (intptr&,int)' while running in aot-only mode. See https://docs.microsoft.com/xamarin/ios/internals/limitations for more information.
at Avalonia.OpenGL.GlBasicInfoInterface.GetStringNative(Int32 v) in /_/src/Avalonia.OpenGL/DevGenerators/Generator.GetProcAddressInitializationGenerator/globalAvalonia.OpenGL.GlBasicInfoInterface.cs:13
at Avalonia.OpenGL.GlBasicInfoInterface.GetString(Int32 v) in /_/src/Avalonia.OpenGL/GlBasicInfoInterface.cs:27
at Avalonia.OpenGL.GlBasicInfoInterface.GetExtensions() in /_/src/Avalonia.OpenGL/GlBasicInfoInterface.cs:43
at Avalonia.OpenGL.GlInterface.GlContextInfo.Create(GlVersion version, Func`2 getProcAddress) in /_/src/Avalonia.OpenGL/GlInterface.cs:33
at Avalonia.OpenGL.GlInterface..ctor(GlVersion version, Func`2 getProcAddress) in /_/src/Avalonia.OpenGL/GlInterface.cs:48
at Avalonia.iOS.GlContext..ctor() in /_/src/iOS/Avalonia.iOS/EaglDisplay.cs:30
at Avalonia.iOS.EaglFeature..ctor() in /_/src/iOS/Avalonia.iOS/EaglDisplay.cs:17
at Avalonia.iOS.Platform.Register() in /_/src/iOS/Avalonia.iOS/Platform.cs:34
at at Avalonia.Controls.AppBuilderBase`1[[Avalonia.AppBuilder, Avalonia.Controls, Version=11.0.0.0, Culture=neutral, PublicKeyToken=c8d484a7012f9a8b]].Setup()
at at Avalonia.Controls.AppBuilderBase`1[[Avalonia.AppBuilder, Avalonia.Controls, Version=11.0.0.0, Culture=neutral, PublicKeyToken=c8d484a7012f9a8b]].SetupWithLifetime(IApplicationLifetime lifetime)
at at Avalonia.iOS.AvaloniaAppDelegate`1[[testapp.App, testapp, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].FinishedLaunching(UIApplication application, NSDictionary launchOptions)
I have tried adding <ResolveAssemblyConflicts>true</ResolveAssemblyConflicts>, different linker settings, and downgrading the project to .net 6. All attempts failed with same error.
Environment
Visual Studio Community 2022 for Mac
Version 17.4.2 (build 17)
Installation UUID: 04eb36b5-8ade-4881-9f2c-f51e231033e1
Runtime
.NET 6.0.12 (64-bit)
Architecture: X64
Roslyn (Language Service)
4.4.0-6.22578.12+3c6ab8e1715e5b080fb7bb77070810ab71e09387
NuGet
Version: 6.3.1.1
.NET SDK (x64)
SDK: /usr/local/share/dotnet/sdk/7.0.101/Sdks
SDK Versions:
7.0.101
6.0.404
MSBuild SDKs: /Applications/Visual Studio.app/Contents/MonoBundle/MSBuild/Current/bin/Sdks
.NET Runtime (x64)
Runtime: /usr/local/share/dotnet/dotnet
Runtime Versions:
7.0.1
6.0.12
Xamarin.Profiler
Version: 1.8.0.19
Location: /Applications/Xamarin Profiler.app/Contents/MacOS/Xamarin Profiler
Updater
Version: 11
Xamarin.Android
Version: 13.1.0.1 (Visual Studio Community)
Commit: xamarin-android/d17-4/13ba222
Android SDK: /Users/jhimes/Library/Developer/Xamarin/android-sdk-macosx
Supported Android versions:
13.0 (API level 33)
SDK Command-line Tools Version: 7.0
SDK Platform Tools Version: 33.0.2
SDK Build Tools Version: 32.0.0
Build Information:
Mono: a96bde9
Java.Interop: xamarin/java.interop/d17-4@fcc33ce2
SQLite: xamarin/sqlite/3.39.3@23e1ae7
Xamarin.Android Tools: xamarin/xamarin-android-tools/main@0be567a
Microsoft Build of OpenJDK
Java SDK: /Library/Java/JavaVirtualMachines/microsoft-11.jdk
11.0.12
Android Designer EPL code available here:
https://github.com/xamarin/AndroidDesigner.EPL
Eclipse Temurin JDK
Java SDK: /Library/Java/JavaVirtualMachines/temurin-8.jdk
1.8.0.302
Android Designer EPL code available here:
https://github.com/xamarin/AndroidDesigner.EPL
Android SDK Manager
Version: 17.4.0.54
Hash: 6eabb9e
Branch: remotes/origin/d17-4
Build date: 2022-12-13 04:22:32 UTC
Android Device Manager
Version: 0.0.0.1206
Hash: 886af39
Branch: 886af39
Build date: 2022-12-13 04:22:32 UTC
Apple Developer Tools
Xcode 14.2 (21534)
Build 14C18
Xamarin.Mac
Version: 9.0.0.27 (Visual Studio Community)
Hash: 933c6c2c9
Branch: xcode14.1
Build date: 2022-11-22 02:00:36-0500
Xamarin.iOS
Version: 16.1.1.27 (Visual Studio Community)
Hash: 933c6c2c9
Branch: xcode14.1
Build date: 2022-11-22 02:00:37-0500
Xamarin Designer
Version: 17.4.0.136
Hash: d49c9ff6d3
Branch: remotes/origin/d17-4
Build date: 2022-12-13 04:22:27 UTC
Build Information
Release ID: 1704020017
Git revision: 7ef5413f2eec3351ce648085f619fc29fd8cb647
Build date: 2022-12-13 04:20:10+00
Build branch: release-17.4
Build lane: release-17.4
Operating System
Mac OS X 12.6.1
Darwin 21.6.0 Darwin Kernel Version 21.6.0
Thu Sep 29 20:12:57 PDT 2022
root:xnu-8020.240.7~1/RELEASE_X86_64 x86_64
Copied from original issue xamarin/xamarin-macios#17159
About this issue
- Original URL
- State: closed
- Created a year ago
- Comments: 38 (19 by maintainers)
Commits related to this issue
- [mono][aot] Generate 'native-indirect' wrappers in full-aot mode. Fixes https://github.com/dotnet/runtime/issues/80853. — committed to vargaz/runtime by vargaz a year ago
- [mono][aot] Generate 'native-indirect' wrappers in full-aot mode. Fixes https://github.com/dotnet/runtime/issues/80853. — committed to vargaz/runtime by vargaz a year ago
- [mono][aot] Generate 'native-indirect' wrappers in full-aot mode. Fixes https://github.com/dotnet/runtime/issues/80853. — committed to vargaz/runtime by vargaz a year ago
- [mono][aot] Generate 'native-indirect' wrappers in full-aot mode. Fixes https://github.com/dotnet/runtime/issues/80853. — committed to vargaz/runtime by vargaz a year ago
- [mono][aot] Generate 'native-indirect' wrappers in full-aot mode. Fixes https://github.com/dotnet/runtime/issues/80853. — committed to vargaz/runtime by vargaz a year ago
- [mono][aot] Generate 'native-indirect' wrappers in full-aot mode. (#85923) Fixes https://github.com/dotnet/runtime/issues/80853. — committed to dotnet/runtime by vargaz a year ago
- [mono][aot] Generate 'native-indirect' wrappers in full-aot mode. (#85923) Fixes https://github.com/dotnet/runtime/issues/80853. — committed to kunalspathak/runtime by vargaz a year ago
- [mono][aot] Generate 'native-indirect' wrappers in full-aot mode. Fixes https://github.com/dotnet/runtime/issues/80853. — committed to dotnet/runtime by vargaz a year ago
- [release/7.0-staging] [mono][aot] Generate 'native-indirect' wrappers in full-aot mode. (#86934) * [mono][aot] Generate 'native-indirect' wrappers in full-aot mode. Fixes https://github.com/dotnet... — committed to dotnet/runtime by github-actions[bot] a year ago
@DrWenz One workaround is to use the mono interpreter.
This worked for me to get my Avalonia iOS app running on real devices. Interpreter is slower sometimes than AOT so be sure to performance test your app.
It could be backported, it should be low risk.
Based on above comments and backported PR merging, closing this issue. Please re-open if you still encounter the crashes.
Thx @slater1 works like charm 😃 saved my day!
I came here from the linked issue in Avalonia. This issue is blocking my development of an iOS app using Avalonia. I’m stuck on NET 7 for now so a backport would be appreciated.
@vargaz Thank you so much for looking into this.
I could find time at some point this week to attempt to get the daily build of .net to work with Avalonia to see if the issue is resolved. I’m also a huge fan of a backport. Thanks!
@SamMonoRT should we consider backporting https://github.com/dotnet/runtime/pull/85923 to 7.0?
This looks fixable, will look into it.
@maxkatz6 Tagging you here
FYI, this makes ‘hello world’ on iOS fail. For me, this implies that .NET on iOS isn’t anyone’s priority, given that the most basic of apps fails to launch and it’s not being investigated.