drwhut / tabletop-club

An open-source platform for playing tabletop games in a physics-based 3D environment for Windows, macOS, and Linux! Made with the Godot Engine.
MIT License
1.24k stars 49 forks source link

webrtc-native: arm64 library not included. #282

Open belthesar opened 1 year ago

belthesar commented 1 year ago

Describe the bug When launching the macOS build of Tabletop Club, the application fails to start and throws an exception.

To Reproduce Steps to reproduce the behavior:

  1. Download the 0.1.0 macOS build from the releases page
  2. Use xattr -c /path/to/release.zip to clear the quarantine flag (without doing this, launching the extracted bundle reports that application is broken.)
  3. Launch the application

Expected behavior The application launches!

Screenshots n/a

Environment macOS Ventura 13.3.1 on MacBook Pro 18,3 (Apple Silicon, M1 Pro, 10 Core, 14 Core GPU)

Version v0.1.0

Additional context It appears the macOS build is failing Code Signature enforcement. This may be because the build is not made with an active Apple Developer account. When launching the application, the following exception is thrown:

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

Incident Identifier: 51EFA319-9BE6-4DC1-9EB8-3C5440563604
CrashReporter Key:   A3E42A1B-0ACF-B31D-78C3-C68E8E0297BF
Hardware Model:      MacBookPro18,3
Process:             Tabletop Club [86386]
Path:                /Applications/Tabletop Club.app/Contents/MacOS/Tabletop Club
Identifier:          io.itch.drwhut.TabletopClub
Version:             v0.1.0 (v0.1.0)
Code Type:           ARM-64 (Native)
Role:                Default
Parent Process:      launchd [1]
Coalition:           io.itch.drwhut.TabletopClub [14572]

Date/Time:           2023-05-04 00:52:18.1874 -0400
Launch Time:         2023-05-04 00:52:18.1615 -0400
OS Version:          macOS 13.3.1 (22E772610a)
Release Type:        User
Report Version:      104

Exception Type:  EXC_BAD_ACCESS (SIGKILL (Code Signature Invalid))
Exception Subtype: UNKNOWN_0x32 at 0x0000000100d60000
Exception Codes: 0x0000000000000032, 0x0000000100d60000
VM Region Info: 0x100d60000 is in 0x100d60000-0x102bc4000;  bytes after start: 0  bytes before end: 31866879
      REGION TYPE                    START - END         [ VSIZE] PRT/MAX SHRMOD  REGION DETAIL
      UNUSED SPACE AT START
--->  __TEXT                      100d60000-102bc4000    [ 30.4M] r-x/r-x SM=COW  
      __DATA_CONST                102bc4000-102c6c000    [  672K] rw-/rw- SM=COW  
Termination Reason: CODESIGNING 2 Invalid Page

Triggered by Thread:  0

Thread 0 Crashed:
0                                          0x102f321e4 dyld3::MachOFile::forEachLoadCommand(Diagnostics&, void (load_command const*, bool&) block_pointer) const + 52
1                                          0x102f341cc dyld3::MachOFile::forEachSupportedPlatform(void (dyld3::Platform, unsigned int, unsigned int) block_pointer) const + 160
2                                          0x102f85e0c dyld3::MachOFile::isBuiltForSimulator() const + 124
3                                          0x102f358e4 start + 632

Thread 0 crashed with ARM Thread State (64-bit):
    x0: 0x0000000100d60000   x1: 0x000000016f09f808   x2: 0x000000016f09f7b0   x3: 0x0000000102f31e23
    x4: 0x0000000000000070   x5: 0x0000000000000073   x6: 0x0000000000000000   x7: 0x0000000000000aa0
    x8: 0x000000016f09f7e8   x9: 0x0000000102fc3530  x10: 0x0000000102fae000  x11: 0x0000000102fba958
   x12: 0x0000000000000065  x13: 0x0000000000000073  x14: 0x0000000000056250  x15: 0x0000000000000000
   x16: 0x0000000102f3426c  x17: 0x6ae100016f09f7b0  x18: 0x0000000000000000  x19: 0x000000016f09f808
   x20: 0x0000000100d60000  x21: 0x000000016f09f7b0  x22: 0x000000016f09f9e8  x23: 0x000000016f09f9c0
   x24: 0x000000016f09f940  x25: 0x0000000000000000  x26: 0x0000000000000000  x27: 0x0000000000000000
   x28: 0x0000000000000000   fp: 0x000000016f09f7a0   lr: 0xf63a800102f341cc
    sp: 0x000000016f09f710   pc: 0x0000000102f321e4 cpsr: 0x80001000
   far: 0x0000000100d60000  esr: 0x92000006 (Data Abort) byte read Translation fault

Binary Images:
       0x102f30000 -        0x102fbffff  (*) <ac277a36-1808-327a-8761-cca585421212> ???
       0x100d60000 -        0x102bc3fff  (*) <a651132b-7070-3b13-b5a1-1355df5873b4> ???

Error Formulating Crash Report:
dyld_process_snapshot_get_shared_cache failed

EOF

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

{"app_name":"Tabletop Club","timestamp":"2023-05-04 00:52:18.00 -0400","app_version":"v0.1.0","slice_uuid":"a651132b-7070-3b13-b5a1-1355df5873b4","build_version":"v0.1.0","platform":0,"bundleID":"io.itch.drwhut.TabletopClub","share_with_app_devs":1,"is_first_party":0,"bug_type":"309","os_version":"macOS 13.3.1 (22E772610a)","roots_installed":0,"name":"Tabletop Club","incident_id":"51EFA319-9BE6-4DC1-9EB8-3C5440563604"}
{
  "uptime" : 170000,
  "procRole" : "Default",
  "version" : 2,
  "userID" : 501,
  "deployVersion" : 210,
  "modelCode" : "MacBookPro18,3",
  "coalitionID" : 14572,
  "osVersion" : {
    "train" : "macOS 13.3.1",
    "build" : "22E772610a",
    "releaseType" : "User"
  },
  "captureTime" : "2023-05-04 00:52:18.1874 -0400",
  "incident" : "51EFA319-9BE6-4DC1-9EB8-3C5440563604",
  "pid" : 86386,
  "translated" : false,
  "cpuType" : "ARM-64",
  "roots_installed" : 0,
  "bug_type" : "309",
  "procLaunch" : "2023-05-04 00:52:18.1615 -0400",
  "procStartAbsTime" : 4311560013990,
  "procExitAbsTime" : 4311560614024,
  "procName" : "Tabletop Club",
  "procPath" : "\/Applications\/Tabletop Club.app\/Contents\/MacOS\/Tabletop Club",
  "bundleInfo" : {"CFBundleShortVersionString":"v0.1.0","CFBundleVersion":"v0.1.0","CFBundleIdentifier":"io.itch.drwhut.TabletopClub"},
  "storeInfo" : {"deviceIdentifierForVendor":"A953C34E-3695-501A-9FCF-A187741BBBF9","thirdParty":true},
  "parentProc" : "launchd",
  "parentPid" : 1,
  "coalitionName" : "io.itch.drwhut.TabletopClub",
  "crashReporterKey" : "A3E42A1B-0ACF-B31D-78C3-C68E8E0297BF",
  "throttleTimeout" : 2147483647,
  "codeSigningID" : "",
  "codeSigningTeamID" : "",
  "codeSigningFlags" : 16777728,
  "codeSigningValidationCategory" : 0,
  "codeSigningTrustLevel" : 0,
  "wakeTime" : 29059,
  "sleepWakeUUID" : "B6561F3F-DB14-4A0B-B2B1-98A9E2B5AEE2",
  "sip" : "enabled",
  "vmRegionInfo" : "0x100d60000 is in 0x100d60000-0x102bc4000;  bytes after start: 0  bytes before end: 31866879\n      REGION TYPE                    START - END         [ VSIZE] PRT\/MAX SHRMOD  REGION DETAIL\n      UNUSED SPACE AT START\n--->  __TEXT                      100d60000-102bc4000    [ 30.4M] r-x\/r-x SM=COW  \n      __DATA_CONST                102bc4000-102c6c000    [  672K] rw-\/rw- SM=COW  ",
  "exception" : {"codes":"0x0000000000000032, 0x0000000100d60000","rawCodes":[50,4308992000],"type":"EXC_BAD_ACCESS","signal":"SIGKILL (Code Signature Invalid)","subtype":"UNKNOWN_0x32 at 0x0000000100d60000"},
  "termination" : {"flags":0,"code":2,"namespace":"CODESIGNING","indicator":"Invalid Page"},
  "vmregioninfo" : "0x100d60000 is in 0x100d60000-0x102bc4000;  bytes after start: 0  bytes before end: 31866879\n      REGION TYPE                    START - END         [ VSIZE] PRT\/MAX SHRMOD  REGION DETAIL\n      UNUSED SPACE AT START\n--->  __TEXT                      100d60000-102bc4000    [ 30.4M] r-x\/r-x SM=COW  \n      __DATA_CONST                102bc4000-102c6c000    [  672K] rw-\/rw- SM=COW  ",
  "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":2771281,"threadState":{"x":[{"value":4308992000},{"value":6157891592},{"value":6157891504},{"value":4344454691},{"value":112},{"value":115},{"value":0},{"value":2720},{"value":6157891560},{"value":4345050416,"symbolLocation":0,"symbol":"__block_descriptor_tmp.57"},{"value":4344963072,"symbolLocation":4,"symbol":"lsl::Vector<char>::reserveExact(unsigned long) (.cold.1)"},{"value":4345014616},{"value":101},{"value":115},{"value":352848},{"value":0},{"value":4344463980,"symbolLocation":0,"symbol":"invocation function for block in dyld3::MachOFile::forEachSupportedPlatform(void (dyld3::Platform, unsigned int, unsigned int) block_pointer) const"},{"value":7701436843938150320},{"value":0},{"value":6157891592},{"value":4308992000},{"value":6157891504},{"value":6157892072},{"value":6157892032},{"value":6157891904},{"value":0},{"value":0},{"value":0},{"value":0}],"flavor":"ARM_THREAD_STATE64","lr":{"value":17742634423812309452},"cpsr":{"value":2147487744},"fp":{"value":6157891488},"sp":{"value":6157891344},"esr":{"value":2449473542,"description":"(Data Abort) byte read Translation fault"},"pc":{"value":4344455652,"matchesCrashFrame":1},"far":{"value":4308992000}},"frames":[{"imageOffset":8676,"symbol":"dyld3::MachOFile::forEachLoadCommand(Diagnostics&, void (load_command const*, bool&) block_pointer) const","symbolLocation":52,"imageIndex":0},{"imageOffset":16844,"symbol":"dyld3::MachOFile::forEachSupportedPlatform(void (dyld3::Platform, unsigned int, unsigned int) block_pointer) const","symbolLocation":160,"imageIndex":0},{"imageOffset":351756,"symbol":"dyld3::MachOFile::isBuiltForSimulator() const","symbolLocation":124,"imageIndex":0},{"imageOffset":22756,"symbol":"start","symbolLocation":632,"imageIndex":0}]}],
  "usedImages" : [
  {
    "source" : "P",
    "arch" : "arm64e",
    "base" : 4344446976,
    "size" : 589824,
    "uuid" : "ac277a36-1808-327a-8761-cca585421212",
    "name" : ""
  },
  {
    "source" : "P",
    "arch" : "arm64",
    "base" : 4308992000,
    "size" : 31866880,
    "uuid" : "a651132b-7070-3b13-b5a1-1355df5873b4",
    "name" : ""
  }
],
  "vmSummary" : "ReadOnly portion of Libraries: Total=33.2M resident=0K(0%) swapped_out_or_unallocated=33.2M(100%)\nWritable regions: Total=8240K written=0K(0%) resident=0K(0%) swapped_out=0K(0%) unallocated=8240K(100%)\n\n                                VIRTUAL   REGION \nREGION TYPE                        SIZE    COUNT (non-coalesced) \n===========                     =======  ======= \nSTACK GUARD                       56.0M        1 \nStack                             8176K        1 \n__DATA                             128K        3 \n__DATA_CONST                       704K        2 \n__DATA_DIRTY                        16K        1 \n__LINKEDIT                        2352K        2 \n__TEXT                            31.0M        2 \n===========                     =======  ======= \nTOTAL                             98.1M       12 \n",
  "legacyInfo" : {
  "threadTriggered" : {

  }
},
  "logWritingSignature" : "46e6ce7b8b490ad00d5804ed5cae290cbb66f824",
  "trialInfo" : {
  "rollouts" : [
    {
      "rolloutId" : "6297d96be2c9387df974efa4",
      "factorPackIds" : {

      },
      "deploymentId" : 240000008
    },
    {
      "rolloutId" : "5fb4245a1bbfe8005e33a1e1",
      "factorPackIds" : {

      },
      "deploymentId" : 240000021
    }
  ],
  "experiments" : [
    {
      "treatmentId" : "c28e4ee6-1b08-4f90-8e05-2809e78310a3",
      "experimentId" : "6317d2003d24842ff850182a",
      "deploymentId" : 400000012
    },
    {
      "treatmentId" : "6dd670af-0633-45e4-ae5f-122ae4df02be",
      "experimentId" : "64406ba83deb637ac8a04419",
      "deploymentId" : 900000005
    }
  ]
},
  "reportNotes" : [
  "dyld_process_snapshot_get_shared_cache failed"
]
}
drwhut commented 1 year ago

Yeah, I currently do not own certificates for Windows or macOS - but it is still possible to run the game on macOS by right-clicking the application and clicking "Open" (this may need to be done twice the first time around, and it should be possible even with the quarantine flag). Let me know if this works for you!

MaximilianSiess commented 1 year ago

Unfortunately the Problem remains, even when removing the flag and adding an exception, as far as I can tell. The error changes to "Tabletop Club quit unexpectedly", but the Report I get is identical to that posted by OP.

If I find the time I'll compile the Godot fork and try to take a look what the issue might be.

drwhut commented 1 year ago

Darn. Yeah, any help with getting the standalone macOS build working on other machines would be appreciated :+1: For those on macOS I recommend playing the game through the Itch app for the time being until this is fixed.

doc-halo commented 1 year ago

I have a mid 2014 Macbook pro with Big Sur. It opens and runs fine when you right-click and choose open. I would assume this problem only occurs with newer apple products then.

jminor commented 1 year ago

It fails to launch on M1/M2 based Macs because the application binary is universal (x86_64 and arm64) but the bundled libwebrtc_native.osx.release.64.dylib library is x86_64 only. You can force it to run under Rosetta, by selecting the app icon in the Finder, pressing Cmd-I to open the inspector and then checking the "Open using Rosetta" checkbox. After that it will run properly. Such a cool project! Thanks for making it :)

drwhut commented 1 year ago

It fails to launch on M1/M2 based Macs because the application binary is universal (x86_64 and arm64) but the bundled libwebrtc_native.osx.release.64.dylib library is x86_64 only.

Ahh, that explains why the game works on older systems, but not newer ones!

Looking at the official webrtc-native library, it does look like there is an arm64 version of the library, but it is in a separate file:

[gd_resource type="GDNativeLibrary" format=2]

[resource]

singleton = true

reloadable = false

entry/OSX.64 = "res://webrtc/lib/libwebrtc_native.osx.release.64.dylib"

entry/OSX.arm64 = "res://webrtc/lib/libwebrtc_native.osx.release.arm64.dylib"

Since the main binary is universal, here's my initial solutions from nicest to not nicest:

I'll do some research on how to solve this in the near future, I can't be the only one who's had this problem surely?

jminor commented 1 year ago

I believe the command line tool lipo can combine two separate x86_64 and arm64 binaries into one universal one. Something like this should work: lipo foo_intel.dylib foo_arm.dylib -output foo_universal.dylib -create

drwhut commented 1 year ago

I've been tinkering with this today - I initially attempted to merge the two dynamic libraries together, but failed when I realised there is no second library 🤦 Even though the .tres file references an arm64 library, only the x86_64 one exists: libwebrtc_native.osx.release.64.dylib.

So I attempted to build it from source on my MacBook, and lo and behold, I can't get it to even compile for x86_64, let alone arm64 😭 There's several issues with building the original WebRTC library in the same branch that the rest of the platforms use.

However, that's all for version 0.5 of the library (the current stable version) - at the time of writing, there is a v1.0.0-rc1 release that includes both x86_64 and arm64 libraries for both Godot 4 and 3. I was planning to use it for v0.2.0 of the game since it will use Godot 3.5.2, but I may attempt to use it for v0.1.x to get this error fixed, even if it says Godot 3.4.x is not officially supported.

Will keep you all updated on this 👍 I'm really hoping I can get the game working on ARM sooner rather than later...

drwhut commented 1 year ago

No such luck with the v1.0.0-rc1 build... the library loads fine on macOS (after correcting a spelling error), and it sends offers, answers and candidates to my Linux machine, but it just... doesn't establish the connection:

Joining game with room code IVDG...
Connecting to master server at 'wss://tabletop-club.duckdns.org:9080' with room code 'IVDG'...
Connected to the room as peer 236816019.
Peer 1 has connected.
Creating a connection for peer 1...
Joined room IVDG.
Received offer from peer 1.
Created answer for peer 1.
Received candidate from peer 1.
Received candidate from peer 1.
Received candidate from peer 1.

Unless someone can find a fix for this, I'm not sure if I am able to include an arm64 version of the WebRTC library until the game uses Godot 3.5 (which will be in v0.2.0) - until then, it looks like you can run the x86_64 version via Rosetta.

belthesar commented 1 year ago

Thanks for all of the information. Looking forward to v0.2.0!

drwhut commented 4 months ago

How do you do, fellow macOS users? :grin:

I've been working on the new multiplayer back-end for v0.2.0, using an updated version of the WebRTC library that includes the arm64 architecture for M1 and M2 processors.

I wanted to confirm that using the newer library actually works, so I've made a very, very, very alpha build of the update so far based on the latest commit of the 0.2-rewrite branch, 11608b3534de5005e4183daaa156abcaea6f2ecb.

I've confirmed that it works on Intel, but I need help confirming if, on ARM, you guys are able to do the following:

NOTE: The in-game UI is very lacking at the moment, so you will probably need to run the build via the terminal, or at the very least, get the terminal output, to confirm that the networking is working as expected.

Any help with testing this is greatly appreciated! If you've got any questions, don't hesitate to ask. Download (100MB): https://drive.google.com/file/d/1hP-5QspoP7_YKFGb9RTi1mz5kWn-aU9V/view?usp=sharing SHA512: 18f8532e41dac587d73cde31729187bcff29075bb815a868c49a53bf673d6942876fd57a26282157205835d9a62acf2b67e3a81e669b1bf65f0b53d818bf6708