Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

arm64 .NET missing from macOS export 4.3 #94631

Closed
roonskipp opened this issue Jul 22, 2024 · 9 comments · Fixed by #94680
Closed

arm64 .NET missing from macOS export 4.3 #94631

roonskipp opened this issue Jul 22, 2024 · 9 comments · Fixed by #94680

Comments

@roonskipp
Copy link

Tested versions

  • reproducible in 4.3-beta3

  • tested in 4.2.2 mono where it works with export templates for 4.2.2

System information

MacBook Pro M3 Pro Sonoma 14.3

Issue description

When exporting godot .NET project to macOS the arm dylibs are missing for .NET. Showing package contents, resources folder only contains: x86_64. macos_arm64 is missing.

This gives the following error:
Screenshot 2024-07-22 at 18 51 15

Steps to reproduce

Create a new project in godot 4.3 beta 3 with .NET and attempt to export for macOS. Open the exported .dmg file and run the application.

Minimal reproduction project (MRP)

mrp.zip

@raulsntos
Copy link
Member

Your MRP doesn't contain a C# project or the export preset used to export the project. Also, it may be useful to know the information of your .NET installation (run dotnet --info in a terminal).

For macOS we should be building the C# project for 2 architectures:

if (platform == OS.Platforms.MacOS)
{
publishConfig.Archs.Add("x86_64");
publishConfig.Archs.Add("arm64");
}

Can you share the contents of the .dmg file?

@bruvzg
Copy link
Member

bruvzg commented Jul 23, 2024

Most likely caused by signing issue (try switching to ad-hoc signature) and already fixed by #94518

@roonskipp
Copy link
Author

Your MRP doesn't contain a C# project or the export preset used to export the project. Also, it may be useful to know the information of your .NET installation (run dotnet --info in a terminal).

For macOS we should be building the C# project for 2 architectures:

if (platform == OS.Platforms.MacOS)
{
publishConfig.Archs.Add("x86_64");
publishConfig.Archs.Add("arm64");
}

Can you share the contents of the .dmg file?

Dotnet --info dump:

 Version:           8.0.302
 Commit:            ef14e02af8
 Workload version:  8.0.300-manifests.f6879a9a
 MSBuild version:   17.10.4+10fbfbf2e

Runtime Environment:
 OS Name:     Mac OS X
 OS Version:  14.3
 OS Platform: Darwin
 RID:         osx-arm64
 Base Path:   /usr/local/share/dotnet/sdk/8.0.302/

.NET workloads installed:
There are no installed workloads to display.

Host:
  Version:      8.0.6
  Architecture: arm64
  Commit:       3b8b000a0e

.NET SDKs installed:
  8.0.302 [/usr/local/share/dotnet/sdk]

.NET runtimes installed:
  Microsoft.AspNetCore.App 8.0.6 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 8.0.6 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]

Other architectures found:
  None

Environment variables:
  Not set

global.json file:
  Not found

Learn more:
  https://aka.ms/dotnet/info

@roonskipp
Copy link
Author

roonskipp commented Jul 23, 2024

Most likely caused by signing issue (try switching to ad-hoc signature) and already fixed by #94518

I attempted to change the Codesign to Built in (Ad-Hoc only), and it successfully built for arm64.

I could launch the MRP project.

I produces this error output when launched, but does not crash ( I think. The window is still open, but I have no gameplay in this test project).

Output:

2024-07-23 10:17:53.003 NewTestProject[36249:11857200] WARNING: AVCaptureDeviceTypeExternal is deprecated for Continuity Cameras. Please use AVCaptureDeviceTypeContinuityCamera and add NSCameraUseContinuityCameraDeviceType to your Info.plist.
Failed to create CoreCLR, HRESULT: 0x80004005
ERROR: hostfxr_get_runtime_delegate failed with code: -2147450743
   at: initialize_hostfxr_self_contained (modules/mono/mono_gd/gd_mono.cpp:237)
ERROR: Parameter "load_assembly_and_get_function_pointer" is null.
   at: initialize_hostfxr_and_godot_plugins (modules/mono/mono_gd/gd_mono.cpp:296)
ERROR: Parameter "godot_plugins_initialize" is null.
   at: initialize (modules/mono/mono_gd/gd_mono.cpp:405)

On my actual project it is the same, but it crashes instead on some other signal. Here is the output:

Vulkan 1.2.283 - Forward Mobile - Using Device #0: Apple - Apple M3 Pro

2024-07-23 10:09:42.646 TypeOne[35331:11847404] WARNING: AVCaptureDeviceTypeExternal is deprecated for Continuity Cameras. Please use AVCaptureDeviceTypeContinuityCamera and add NSCameraUseContinuityCameraDeviceType to your Info.plist.
Failed to create CoreCLR, HRESULT: 0x80070008
ERROR: hostfxr_get_runtime_delegate failed with code: -2147450743
   at: initialize_hostfxr_self_contained (modules/mono/mono_gd/gd_mono.cpp:237)
ERROR: Parameter "load_assembly_and_get_function_pointer" is null.
   at: initialize_hostfxr_and_godot_plugins (modules/mono/mono_gd/gd_mono.cpp:296)
ERROR: Parameter "godot_plugins_initialize" is null.
   at: initialize (modules/mono/mono_gd/gd_mono.cpp:405)

================================================================
handle_crash: Program crashed with signal 11
Engine version: Godot Engine v4.3.beta3.mono.official (82cedc83c9069125207c128f9a07ce3d82c317cc)
Dumping the backtrace. Please include this when reporting the bug to the project developer.
[1] invoke_previous_action(sigaction*, int, __siginfo*, void*, bool)
[2] 2   libsystem_platform.dylib            0x0000000181b05a24 _sigtramp + 56
[3] Object* ClassDB::creator<MobileVRInterface>()
[4] Object* ClassDB::creator<MobileVRInterface>()
[5] JSON::get_data() const
[6] JSON::get_data() const
[7] JSON::get_data() const
[8] JSON::get_data() const
[9] RendererCompositorRD::_create_current()
[10] RendererCompositorRD::_create_current()
[11] 11  dyld                                0x00000001817550e0 start + 2360
-- END OF BACKTRACE --
================================================================

Edit: updated with error logs for the MRP

@roonskipp
Copy link
Author

Your MRP doesn't contain a C# project or the export preset used to export the project. Also, it may be useful to know the information of your .NET installation (run dotnet --info in a terminal).

For macOS we should be building the C# project for 2 architectures:

if (platform == OS.Platforms.MacOS)
{
publishConfig.Archs.Add("x86_64");
publishConfig.Archs.Add("arm64");
}

Can you share the contents of the .dmg file?

Here is a zip with the c# project

TestFolderGodot copy.zip

Since my game crashes and the MRP does not after building with the Built in ad-hoc only Codesign, perhaps the three errors are not critical?

@roonskipp
Copy link
Author

roonskipp commented Jul 23, 2024

The DMG Contents when zipped is 111MB, cannot upload it. Let me know if there are other details that are useful.

I will try to make a backup of my actual project, and convert it to godot 4.2.2 where it exported successfully previously and see if it runs without the errors I posted above.

Edit: Could not convert it back to 4.2.2, a scene was corrupted. I did however check out the previous commit where I upgraded to 4.3, and it had the same errors when exporting and running.

I have successfully exported and ran the 4.2.2 before, so my gut feeling is that this is an issue with a part of my .NET code and 4.3.

I am loading JSON files using classes like this:

[JsonSerializable(typeof(ShopModel))]
internal partial class ShopModelContext : JsonSerializerContext
{
}

and

	var sourceGenOptions = new JsonSerializerOptions
		{
			TypeInfoResolver = ShopModelContext.Default
		};
		var shop = JsonSerializer.Deserialize<ShopModel>(file.GetAsText(), options: sourceGenOptions);

I also know that I attempt to load some json files on launch, so it could be related to this as that is what the last logs are before the crash. It all works on iOS exports though.

@raulsntos
Copy link
Member

The hostfxr errors mean the .NET runtime could not be initialized, so the project won't be able to use C#. That's why in a project with C# scripts it crashes. These errors can't be ignored.

Specifically, the error code -2147450743 means a failure initializing CoreCLR. You shared 2 outputs with different CoreCLR errors:

  • HRESULT: 0x80004005 is E_FAIL, an unspecified failure, so I don't know what went wrong. Try setting the environment variable COREHOST_TRACE to 1. This enables some verbose logging that may give more information about what went wrong when initializing CoreCLR.

  • HRESULT: 0x80070008 is undocumented, but it seems to be constructed from a WIN32 error which maps to ERROR_NOT_ENOUGH_MEMORY. So I guess make sure you have enough memory to initialize the .NET runtime. I don't know if macOS limits the available memory to the Godot process, in which case there may be a way to allow the process to use more memory.

It all works on iOS exports though

Godot exports to the iOS platform use NativeAOT which is a completely different .NET runtime, the issue you are having seems specific to the CoreCLR runtime.

@bruvzg
Copy link
Member

bruvzg commented Jul 23, 2024

The error seems to be caused by missing com.apple.security.cs.allow-jit entitlement (which should be auto set for .NET version, but seems like it's not detected correctly).

Screenshot 2024-07-23 at 23 18 49

It should not even show it in the list, but I guess if (Engine::get_singleton()->has_singleton("GodotSharp")) { checks stop working for some reason.

@bruvzg
Copy link
Member

bruvzg commented Jul 23, 2024

So it is regression from #91557, has_singleton("GodotSharp") is still used in multiple places in the engine (not only export code).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Release Blocker
Development

Successfully merging a pull request may close this issue.

5 participants