godotengine / godot

Godot Engine – Multi-platform 2D and 3D game engine
https://godotengine.org
MIT License
88.34k stars 20.01k forks source link

Crashes on exported builds for macOS, when using C# (NuGet) packages #61313

Open ghostbutter-games opened 2 years ago

ghostbutter-games commented 2 years ago

Godot version

3.4.4.stable.mono

System information

macOS 12.4, MacBook Pro M1, GLES3

Issue description

When I use C# packages via the NuGet package manager, then export the game, I get crashes. I had some discussions about this with people in the Godot Discord/C# channel, and it was pointed out to me that currently, Godot does not properly bundle external C# dependencies when building - especially when those are native libraries.

Some NuGet packages, such as the popular QuestPDF library, require native dependencies themselves. This can at least be worked around, when testing in the editor, by copy-pasting the native .dylib file from the hidden NuGet folder into the Godot Project folder root and including <CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies> in the .csproj file.

It all breaks down, however, when exporting the project and trying to run it - it just crashes.

On another note, AOT compilation on macOS/Godot Mono is also currently broken, when exporting I get: Could not find a part of the path '/Users/MyUserName/New Game Project/osx-x86_64'. Maybe I should open a separate issue for that?

Steps to reproduce

Method A

  1. Download Godot Mono 3.4.4 on the latest version of macOS 12.4
  2. Create a new, empty project
  3. Import the NuGet package Newtonsoft.Json (the most popular and common NuGet package)
  4. Paste this sample code into any node script:
    
    string json = @"{
    'CPU': 'Intel',
    'PSU': '500W',
    'Drives': [
     'DVD read/writer'
     /*(broken)*/,
     '500 gigabyte hard drive',
     '200 gigabyte hard drive'
    ]
    }";

JsonTextReader reader = new JsonTextReader(new StringReader(json)); while (reader.Read()) { if (reader.Value != null) { Console.WriteLine("Token: {0}, Value: {1}", reader.TokenType, reader.Value); } else { Console.WriteLine("Token: {0}", reader.TokenType); } }

5. Build the project
6. Export the project with default settings and try to run it.

**Method B:**
1. Download Godot Mono 3.4.4 on the latest version of macOS 12.4
2. Create a new, empty project
3. Import the NuGet package `QuestPDF`
4. Import the NuGet package `SkiaSharp.NativeAssets.macOS` ([this is required as per the QuestPDF documentation](https://www.questpdf.com/documentation/patterns-and-practices.html#support-for-custom-environments-cloud-linux))
5. Paste this sample code into any node script:
```cs
Document.Create(container =>
    {
        container.Page(page =>
        {
            page.Size(PageSizes.A4);
            page.Margin(2, Unit.Centimetre);
            page.PageColor(Colors.White);
            page.DefaultTextStyle(x => x.FontSize(20));

            page.Header()
                .Text("Hello, World!")
                .SemiBold().FontSize(36).FontColor(Colors.Yellow.Medium);

            page.Content()
                .PaddingVertical(1, Unit.Centimetre)
                .Column(x =>
                {
                    x.Spacing(20);

                    x.Item().Text(Placeholders.LoremIpsum());
                    x.Item().Image(Placeholders.Image(200, 100));
                });

            page.Footer()
                .AlignCenter()
                .Text(x =>
                {
                    x.Span("Page ");
                    x.CurrentPageNumber();
                });
        });
    })
    .GeneratePdf("hello.pdf");
  1. Try to run the project from within the editor: This crashes Godot.
  2. Paste the file libSkiaSharp.dylib from the folder ~/.nuget/packages/skiasharp.nativeassets.macos/2.88.1-preview.1/runtimes/osx/native/ into your Godot project folder.
  3. Now, the project should run from within the editor.
  4. Export the project.
  5. The project should crash when executed.

Minimal reproduction project

No response

raulsntos commented 2 years ago

Maybe a duplicate of #60167 and/or #22787

neikeq commented 2 years ago

Can you check if there's any error or exception in the terminal when you run the exported game?

On another note, AOT compilation on macOS/Godot Mono is also currently broken, when exporting I get: Could not find a part of the path '/Users/MyUserName/New Game Project/osx-x86_64'. Maybe I should open a separate issue for that?

Godot 3.x only supports AOT compilation on iOS, on other platforms it's not working. Godot 4.x will support AOT compilation on all or most platforms (NativeAOT on desktop or Mono AOT on mobile).

neikeq commented 2 years ago

Did you also copy the dylib to the output folder when you exported the project, or only to the Godot project folder?

jolexxa commented 2 years ago

I can offer https://github.com/chickensoft-games/GameTemplate as another minimum reproduction sample.

It's a simple C# project that uses Steamworks.NET. Steamworks.NET itself depends on the native steam_api in libsteam_api.dylib being present in the final build. The repo linked above will run fine in the editor on both macOS and Windows.

The Godot macOS build doesn't include the native dependency. I was able to make it work on macOS without code-signing by doing the following, but for production builds I will have to figure out how to code-sign an existing .app file (or if it can be done), which is a bit new for me.

Steps:

  1. Export a .app file in a .dmg with codesigning turned off (uncheck the box as in the picture below).

Screen Shot 2022-05-23 at 5 25 47 PM

Builds with code signing don't seem to be modifiable (by design). I tried, just to be sure, and it does not work.

  1. From the Steam example repo, copy libsteam_api.dylib from addons/go_dot_steam/Steamworks/OSX-Linux-x64/steam_api.bundle/Contents/MacOS/libsteam_api.dylib to the built app's Contents/Resources/GodotSharp/Mono/lib folder.

  2. Add the following line to the built app's Contents/Resources/GodotSharp/Mono/etc/mono/config file:

<dllmap dll="steam_api" target="$mono_libdir/libsteam_api.dylib" os="osx" />

That allows non-code-signed builds to find the dylib copied in step 2.

  1. Lastly, since that demo uses Steam, you'll need to copy steam_appid.txt to GameTemplate.app/Contents/MacOS/steam_appid.txt

Open questions:

ghostbutter-games commented 2 years ago

Godot 3.x only supports AOT compilation on iOS, on other platforms it's not working. Godot 4.x will support AOT compilation on all or most platforms (NativeAOT on desktop or Mono AOT on mobile).

That's great to hear! I guess all my problems and then some will be fixed in 4.0 haha 🤞

Did you also copy the dylib to the output folder when you exported the project, or only to the Godot project folder?

Yes, I copied the dylib pretty much everywhere, to try if anything worked: Project root folder, Output/Export folder, into multiple places inside the Output .app folder. Nothing worked.

Can you check if there's any error or exception in the terminal when you run the exported game?

When I start the game (Newtonsoft example project), it just crashes with "... quit unexpectedly". Here is the full error report, maybe there's something interesting in there?

-------------------------------------
Translated Report (Full Report Below)
-------------------------------------

Process:               New Game Project [51129]
Path:                  /Users/USER/*/New Game Project.app/Contents/MacOS/New Game Project
Identifier:            com.ghostbutter.test
Version:               1.0 (1.0)
Code Type:             ARM-64 (Native)
Parent Process:        New Game Project [51124]
Responsible:           New Game Project [51124]
User ID:               501

Date/Time:             2022-05-24 09:19:00.9961 +0900
OS Version:            macOS 12.4 (21F79)
Report Version:        12
Anonymous UUID:        C5386DB3-BFC2-D84E-7ABD-678B75A19607

Sleep/Wake UUID:       9A205125-93DE-4400-A50C-9AEA405B905A

Time Awake Since Boot: 170000 seconds
Time Since Wake:       11004 seconds

System Integrity Protection: enabled

Crashed Thread:        0  Dispatch queue: com.apple.main-thread

Exception Type:        EXC_CRASH (SIGABRT)
Exception Codes:       0x0000000000000000, 0x0000000000000000
Exception Note:        EXC_CORPSE_NOTIFY

Application Specific Information:
*** multi-threaded process forked ***
crashed on child side of fork pre-exec

Thread 0 Crashed::  Dispatch queue: com.apple.main-thread
0   libsystem_kernel.dylib                 0x19594ad98 __pthread_kill + 8
1   libsystem_pthread.dylib                0x19597fee0 pthread_kill + 288
2   libsystem_c.dylib                      0x1958ba340 abort + 168
3   libc++abi.dylib                        0x19593ab08 abort_message + 132
4   libc++abi.dylib                        0x19592a938 demangling_terminate_handler() + 312
5   libobjc.A.dylib                        0x195820330 _objc_terminate() + 160
6   libc++abi.dylib                        0x195939ea4 std::__terminate(void (*)()) + 20
7   libc++abi.dylib                        0x195939e40 std::terminate() + 64
8   libsystem_c.dylib                      0x19586bb74 exit + 44
9   New Game Project                       0x10299c990 0x102770000 + 2279824
10  New Game Project                       0x102822300 0x102770000 + 729856
11  New Game Project                       0x1028169ec 0x102770000 + 682476
12  New Game Project                       0x102821760 0x102770000 + 726880
13  libsystem_platform.dylib               0x1959974a4 _sigtramp + 56
14  libsystem_pthread.dylib                0x19597fee0 pthread_kill + 288
15  libsystem_c.dylib                      0x1958ba340 abort + 168
16  libc++abi.dylib                        0x19593ab08 abort_message + 132
17  libc++abi.dylib                        0x19592a938 demangling_terminate_handler() + 312
18  libobjc.A.dylib                        0x195820330 _objc_terminate() + 160
19  libc++abi.dylib                        0x195939ea4 std::__terminate(void (*)()) + 20
20  libc++abi.dylib                        0x195939e40 std::terminate() + 64
21  libsystem_c.dylib                      0x19586bb74 exit + 44
22  New Game Project                       0x102d94ff0 0x102770000 + 6442992

Thread 0 crashed with ARM Thread State (64-bit):
    x0: 0x0000000000000000   x1: 0x0000000000000000   x2: 0x0000000000000000   x3: 0x0000000000000000
    x4: 0x000000019593e0c8   x5: 0x000000016d68ce10   x6: 0x0000000000000074   x7: 0x000000016d68d1c8
    x8: 0x638f49198465da95   x9: 0x638f491881675f15  x10: 0x0000000000000200  x11: 0x000000000000002d
   x12: 0x000000000000002d  x13: 0x000000014612bf98  x14: 0x000000019593e0f2  x15: 0x000000000000115a
   x16: 0x0000000000000148  x17: 0x00000001efa0b680  x18: 0x0000000000000000  x19: 0x0000000000000006
   x20: 0x0000000105028580  x21: 0x0000000000000303  x22: 0x0000000105028660  x23: 0x0000000000000001
   x24: 0x0000000000000008  x25: 0x00000001ee849000  x26: 0x0000000000000010  x27: 0x000000000000000f
   x28: 0x000000000000000f   fp: 0x000000016d68cd80   lr: 0x000000019597fee0
    sp: 0x000000016d68cd60   pc: 0x000000019594ad98 cpsr: 0x40001000
   far: 0x00000001ebb037f0  esr: 0x56000080  Address size fault

Binary Images:
       0x195941000 -        0x195978fff libsystem_kernel.dylib (*) <03f48dc5-caa7-3678-af61-1a3c7fa8b06e> /usr/lib/system/libsystem_kernel.dylib
       0x195979000 -        0x195985fff libsystem_pthread.dylib (*) <42166a2c-89a9-3c38-a215-f028544cea23> /usr/lib/system/libsystem_pthread.dylib
       0x195840000 -        0x1958c1fff libsystem_c.dylib (*) <86746b94-88e3-342d-b2b2-54303404e492> /usr/lib/system/libsystem_c.dylib
       0x195929000 -        0x195940fff libc++abi.dylib (*) <59de363f-98cf-36dc-becc-4d8f5f4f3a0e> /usr/lib/libc++abi.dylib
       0x1957ff000 -        0x19583cfff libobjc.A.dylib (*) <6ffccf84-5e0f-34b2-bcbb-bcf98407ea05> /usr/lib/libobjc.A.dylib
       0x102770000 -        0x104b13fff com.ghostbutter.test (1.0) <63dd7ee4-1512-3fd5-85c8-fe3b809e08c5> /Users/USER/*/New Game Project.app/Contents/MacOS/New Game Project
       0x195993000 -        0x19599afff libsystem_platform.dylib (*) <d7aba99f-ba00-36e9-945d-48acf57fc568> /usr/lib/system/libsystem_platform.dylib

External Modification Summary:
  Calls made by other processes targeting this process:
    task_for_pid: 0
    thread_create: 0
    thread_set_state: 0
  Calls made by this process:
    task_for_pid: 0
    thread_create: 0
    thread_set_state: 0
  Calls made by all processes on this machine:
    task_for_pid: 0
    thread_create: 0
    thread_set_state: 0

VM Region Summary:
ReadOnly portion of Libraries: Total=870.5M resident=0K(0%) swapped_out_or_unallocated=870.5M(100%)
Writable regions: Total=1.3G written=0K(0%) resident=0K(0%) swapped_out=0K(0%) unallocated=1.3G(100%)

                                VIRTUAL   REGION 
REGION TYPE                        SIZE    COUNT (non-coalesced) 
===========                     =======  ======= 
Accelerate framework               384K        3 
CG backing stores                 3520K        4 
CG image                            80K        1 
ColorSync                          496K       24 
CoreAnimation                       16K        1 
CoreUI image data                  160K        1 
Foundation                          16K        1 
Kernel Alloc Once                   32K        1 
MALLOC                           309.4M       57 
MALLOC guard page                  192K       10 
MALLOC_MEDIUM (reserved)         568.0M        5         reserved VM address space (unallocated)
MALLOC_NANO (reserved)           384.0M        1         reserved VM address space (unallocated)
OpenGL GLSL                        256K        3 
STACK GUARD                       56.0M        1 
Stack                             14.8M       11 
Stack Guard                        160K       10 
VM_ALLOCATE                       33.2M       43 
VM_ALLOCATE (reserved)            9808K        2         reserved VM address space (unallocated)
__AUTH                            1862K      165 
__AUTH_CONST                      10.8M      320 
__CTF                               756        1 
__DATA                            8641K      310 
__DATA_CONST                      11.6M      325 
__DATA_DIRTY                       717K      112 
__FONT_DATA                          4K        1 
__GLSLBUILTINS                    5176K        1 
__LINKEDIT                       579.7M        7 
__OBJC_CONST                      1491K      139 
__OBJC_RO                         83.0M        1 
__OBJC_RW                         3152K        1 
__TEXT                           290.8M      341 
__UNICODE                          592K        1 
dyld private memory               1024K        1 
mapped file                       82.1M       18 
shared memory                      480K       22 
===========                     =======  ======= 
TOTAL                              2.4G     1945 
TOTAL, minus reserved VM space     1.5G     1945 

-----------
Full Report
-----------

{"app_name":"New Game Project","timestamp":"2022-05-24 09:19:01.00 +0900","app_version":"1.0","slice_uuid":"63dd7ee4-1512-3fd5-85c8-fe3b809e08c5","build_version":"1.0","platform":1,"bundleID":"com.ghostbutter.test","share_with_app_devs":0,"is_first_party":0,"bug_type":"309","os_version":"macOS 12.4 (21F79)","incident_id":"84B66708-13D9-4986-8AE8-CCCD037EC0FA","name":"New Game Project"}
{
  "uptime" : 170000,
  "procLaunch" : "2022-05-24 09:19:00.9938 +0900",
  "procRole" : "Unspecified",
  "version" : 2,
  "userID" : 501,
  "deployVersion" : 210,
  "modelCode" : "MacBookPro18,4",
  "procStartAbsTime" : 4294375531638,
  "coalitionID" : 63818,
  "osVersion" : {
    "train" : "macOS 12.4",
    "build" : "21F79",
    "releaseType" : "User"
  },
  "captureTime" : "2022-05-24 09:19:00.9961 +0900",
  "incident" : "84B66708-13D9-4986-8AE8-CCCD037EC0FA",
  "bug_type" : "309",
  "pid" : 51129,
  "procExitAbsTime" : 4294375579176,
  "translated" : false,
  "cpuType" : "ARM-64",
  "procName" : "New Game Project",
  "procPath" : "\/Users\/USER\/*\/New Game Project.app\/Contents\/MacOS\/New Game Project",
  "bundleInfo" : {"CFBundleShortVersionString":"1.0","CFBundleVersion":"1.0","CFBundleIdentifier":"com.ghostbutter.test"},
  "storeInfo" : {"deviceIdentifierForVendor":"8CF528C8-1748-5D85-BF43-CBE3761662B0","thirdParty":true},
  "parentProc" : "New Game Project",
  "parentPid" : 51124,
  "coalitionName" : "com.ghostbutter.test",
  "crashReporterKey" : "C5386DB3-BFC2-D84E-7ABD-678B75A19607",
  "responsiblePid" : 51124,
  "responsibleProc" : "New Game Project",
  "wakeTime" : 11004,
  "sleepWakeUUID" : "9A205125-93DE-4400-A50C-9AEA405B905A",
  "sip" : "enabled",
  "isCorpse" : 1,
  "exception" : {"codes":"0x0000000000000000, 0x0000000000000000","rawCodes":[0,0],"type":"EXC_CRASH","signal":"SIGABRT"},
  "asi" : {"CoreFoundation":["*** multi-threaded process forked ***"],"libsystem_c.dylib":["crashed on child side of fork pre-exec"]},
  "extMods" : {"caller":{"thread_create":0,"thread_set_state":0,"task_for_pid":0},"system":{"thread_create":0,"thread_set_state":0,"task_for_pid":0},"targeted":{"thread_create":0,"thread_set_state":0,"task_for_pid":0},"warnings":0},
  "faultingThread" : 0,
  "threads" : [{"triggered":true,"id":1624275,"threadState":{"x":[{"value":0},{"value":0},{"value":0},{"value":0},{"value":6804463816},{"value":6130552336},{"value":116},{"value":6130553288},{"value":7174033105368767125},{"value":7174033101023567637},{"value":512},{"value":45},{"value":45},{"value":5470601112},{"value":6804463858},{"value":4442},{"value":328},{"value":8315254400},{"value":0},{"value":6},{"value":4379018624,"symbolLocation":0,"symbol":"_main_thread"},{"value":771},{"value":4379018848,"symbolLocation":224,"symbol":"_main_thread"},{"value":1},{"value":8},{"value":8296632320,"symbolLocation":688,"symbol":"usual"},{"value":16},{"value":15},{"value":15}],"flavor":"ARM_THREAD_STATE64","lr":{"value":6804733664},"cpsr":{"value":1073745920},"fp":{"value":6130552192},"sp":{"value":6130552160},"esr":{"value":1442840704,"description":" Address size fault"},"pc":{"value":6804516248,"matchesCrashFrame":1},"far":{"value":8249161712}},"queue":"com.apple.main-thread","frames":[{"imageOffset":40344,"symbol":"__pthread_kill","symbolLocation":8,"imageIndex":0},{"imageOffset":28384,"symbol":"pthread_kill","symbolLocation":288,"imageIndex":1},{"imageOffset":500544,"symbol":"abort","symbolLocation":168,"imageIndex":2},{"imageOffset":72456,"symbol":"abort_message","symbolLocation":132,"imageIndex":3},{"imageOffset":6456,"symbol":"demangling_terminate_handler()","symbolLocation":312,"imageIndex":3},{"imageOffset":135984,"symbol":"_objc_terminate()","symbolLocation":160,"imageIndex":4},{"imageOffset":69284,"symbol":"std::__terminate(void (*)())","symbolLocation":20,"imageIndex":3},{"imageOffset":69184,"symbol":"std::terminate()","symbolLocation":64,"imageIndex":3},{"imageOffset":179060,"symbol":"exit","symbolLocation":44,"imageIndex":2},{"imageOffset":2279824,"imageIndex":5},{"imageOffset":729856,"imageIndex":5},{"imageOffset":682476,"imageIndex":5},{"imageOffset":726880,"imageIndex":5},{"imageOffset":17572,"symbol":"_sigtramp","symbolLocation":56,"imageIndex":6},{"imageOffset":28384,"symbol":"pthread_kill","symbolLocation":288,"imageIndex":1},{"imageOffset":500544,"symbol":"abort","symbolLocation":168,"imageIndex":2},{"imageOffset":72456,"symbol":"abort_message","symbolLocation":132,"imageIndex":3},{"imageOffset":6456,"symbol":"demangling_terminate_handler()","symbolLocation":312,"imageIndex":3},{"imageOffset":135984,"symbol":"_objc_terminate()","symbolLocation":160,"imageIndex":4},{"imageOffset":69284,"symbol":"std::__terminate(void (*)())","symbolLocation":20,"imageIndex":3},{"imageOffset":69184,"symbol":"std::terminate()","symbolLocation":64,"imageIndex":3},{"imageOffset":179060,"symbol":"exit","symbolLocation":44,"imageIndex":2},{"imageOffset":6442992,"imageIndex":5}]}],
  "usedImages" : [
  {
    "source" : "P",
    "arch" : "arm64e",
    "base" : 6804475904,
    "size" : 229376,
    "uuid" : "03f48dc5-caa7-3678-af61-1a3c7fa8b06e",
    "path" : "\/usr\/lib\/system\/libsystem_kernel.dylib",
    "name" : "libsystem_kernel.dylib"
  },
  {
    "source" : "P",
    "arch" : "arm64e",
    "base" : 6804705280,
    "size" : 53248,
    "uuid" : "42166a2c-89a9-3c38-a215-f028544cea23",
    "path" : "\/usr\/lib\/system\/libsystem_pthread.dylib",
    "name" : "libsystem_pthread.dylib"
  },
  {
    "source" : "P",
    "arch" : "arm64e",
    "base" : 6803423232,
    "size" : 532480,
    "uuid" : "86746b94-88e3-342d-b2b2-54303404e492",
    "path" : "\/usr\/lib\/system\/libsystem_c.dylib",
    "name" : "libsystem_c.dylib"
  },
  {
    "source" : "P",
    "arch" : "arm64e",
    "base" : 6804377600,
    "size" : 98304,
    "uuid" : "59de363f-98cf-36dc-becc-4d8f5f4f3a0e",
    "path" : "\/usr\/lib\/libc++abi.dylib",
    "name" : "libc++abi.dylib"
  },
  {
    "source" : "P",
    "arch" : "arm64e",
    "base" : 6803156992,
    "size" : 253952,
    "uuid" : "6ffccf84-5e0f-34b2-bcbb-bcf98407ea05",
    "path" : "\/usr\/lib\/libobjc.A.dylib",
    "name" : "libobjc.A.dylib"
  },
  {
    "source" : "P",
    "arch" : "arm64",
    "base" : 4336320512,
    "CFBundleShortVersionString" : "1.0",
    "CFBundleIdentifier" : "com.ghostbutter.test",
    "size" : 37371904,
    "uuid" : "63dd7ee4-1512-3fd5-85c8-fe3b809e08c5",
    "path" : "\/Users\/USER\/*\/New Game Project.app\/Contents\/MacOS\/New Game Project",
    "name" : "New Game Project",
    "CFBundleVersion" : "1.0"
  },
  {
    "source" : "P",
    "arch" : "arm64e",
    "base" : 6804811776,
    "size" : 32768,
    "uuid" : "d7aba99f-ba00-36e9-945d-48acf57fc568",
    "path" : "\/usr\/lib\/system\/libsystem_platform.dylib",
    "name" : "libsystem_platform.dylib"
  }
],
  "sharedCache" : {
  "base" : 6801408000,
  "size" : 3136077824,
  "uuid" : "513553bb-5ca5-3b9e-a613-b0603ffe3038"
},
  "vmSummary" : "ReadOnly portion of Libraries: Total=870.5M resident=0K(0%) swapped_out_or_unallocated=870.5M(100%)\nWritable regions: Total=1.3G written=0K(0%) resident=0K(0%) swapped_out=0K(0%) unallocated=1.3G(100%)\n\n                                VIRTUAL   REGION \nREGION TYPE                        SIZE    COUNT (non-coalesced) \n===========                     =======  ======= \nAccelerate framework               384K        3 \nCG backing stores                 3520K        4 \nCG image                            80K        1 \nColorSync                          496K       24 \nCoreAnimation                       16K        1 \nCoreUI image data                  160K        1 \nFoundation                          16K        1 \nKernel Alloc Once                   32K        1 \nMALLOC                           309.4M       57 \nMALLOC guard page                  192K       10 \nMALLOC_MEDIUM (reserved)         568.0M        5         reserved VM address space (unallocated)\nMALLOC_NANO (reserved)           384.0M        1         reserved VM address space (unallocated)\nOpenGL GLSL                        256K        3 \nSTACK GUARD                       56.0M        1 \nStack                             14.8M       11 \nStack Guard                        160K       10 \nVM_ALLOCATE                       33.2M       43 \nVM_ALLOCATE (reserved)            9808K        2         reserved VM address space (unallocated)\n__AUTH                            1862K      165 \n__AUTH_CONST                      10.8M      320 \n__CTF                               756        1 \n__DATA                            8641K      310 \n__DATA_CONST                      11.6M      325 \n__DATA_DIRTY                       717K      112 \n__FONT_DATA                          4K        1 \n__GLSLBUILTINS                    5176K        1 \n__LINKEDIT                       579.7M        7 \n__OBJC_CONST                      1491K      139 \n__OBJC_RO                         83.0M        1 \n__OBJC_RW                         3152K        1 \n__TEXT                           290.8M      341 \n__UNICODE                          592K        1 \ndyld private memory               1024K        1 \nmapped file                       82.1M       18 \nshared memory                      480K       22 \n===========                     =======  ======= \nTOTAL                              2.4G     1945 \nTOTAL, minus reserved VM space     1.5G     1945 \n",
  "legacyInfo" : {
  "threadTriggered" : {
    "queue" : "com.apple.main-thread"
  }
},
  "trialInfo" : {
  "rollouts" : [
    {
      "rolloutId" : "61af99aeda72d16a4beb7756",
      "factorPackIds" : {

      },
      "deploymentId" : 240000176
    },
    {
      "rolloutId" : "607844aa04477260f58a8077",
      "factorPackIds" : {
        "SIRI_MORPHUN_ASSETS" : "6103050cbfe6dc472e1c982a"
      },
      "deploymentId" : 240000066
    }
  ],
  "experiments" : [

  ]
}
}

Model: MacBookPro18,4, BootROM 7459.121.3, proc 10:8:2 processors, 32 GB, SMC 
Graphics: Apple M1 Max, Apple M1 Max, Built-In
Display: Color LCD, 3024 x 1964 Retina, Main, MirrorOff, Online
Memory Module: LPDDR5
AirPort: Wi-Fi, wl0: Apr  6 2022 05:55:54 version 20.90.45.0.8.7.118 FWID 01-e7138ff2
Bluetooth: Version (null), 0 services, 0 devices, 0 incoming serial ports
Network Service: Wi-Fi, AirPort, en0
USB Device: USB31Bus
USB Device: USB31Bus
USB Device: USB31Bus
Thunderbolt Bus: MacBook Pro, Apple Inc.
Thunderbolt Bus: MacBook Pro, Apple Inc.
Thunderbolt Bus: MacBook Pro, Apple Inc.
ghostbutter-games commented 2 years ago

@definitelyokay Thanks for that in-depth example!

I did some fiddling with my Newtonsoft.Json example project and realized that the crash on export might be caused by something else - I did put a System.IO.File.WriteAllText() in there to save some JSON to a file - which, again, worked in the editor but did not work on the exported game. Somehow, when working in the editor, the paths are all relative, but in the exported project, they are not. When I removed that call, my exported game at least did not crash on start.

Anyways, that does mean, however, that simple, non-native NuGet packages might in fact work when exported, even on macOS - at least in this example. Still, the problem remains that native libraries are such a huge pain and required by a great amount of use cases, especially commercial ones where codesigning is definitely a requirement as well.

As it stands right now, it is basically a nightmare to publish a Godot Mono 3.X game to Steam (when using the Steam native libraries). It requires crazy workarounds that are also undocumented, so this might be or have already been a huge blocker for some people that are trying to launch their games on Steam.

Would be really great if a fix for this was possible, even for Godot 3.X.

neikeq commented 2 years ago

We can make this work in Godot 3.x as well, at least on the desktop. On mobile, there's a huge asterisk because some packages only work well when the target framework is Xamarin.iOS/Android which Godot 3.x doesn't target. Currently I'm very busy with 4.0 but once I have some time I'll try to implement this. Godot taking care of these dependencies may also fix code signing.

ghostbutter-games commented 1 year ago

We can make this work in Godot 3.x as well, at least on the desktop. On mobile, there's a huge asterisk because some packages only work well when the target framework is Xamarin.iOS/Android which Godot 3.x doesn't target. Currently I'm very busy with 4.0 but once I have some time I'll try to implement this. Godot taking care of these dependencies may also fix code signing.

Hi @neikeq , first off: Thanks for the great work on the dotnet6 side! :)

Has there been any opportunity yet to maybe look into this for 4.0?

It would be greatly appreciated, as currently we have to manually go into exported builds and patch them by hand, then codesign them (when on macOS, also manually), which is a struggle.