carlosonunez / obs-installer-for-apple-silicon

Conveniently build and install OBS from source on your ultra-fast Apple M1 MacBook or Mac
206 stars 22 forks source link

OBS Crashes on Open #30

Closed BryanHaley closed 2 years ago

BryanHaley commented 3 years ago

Machine info: MacOS Monterey Version 12.0 MacBook Pro (16 inch, 2021) Chip Apple M1 Max Memory 32GB

Crash log:

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

Process:               obs [1133]
Path:                  /Applications/OBS.app/Contents/MacOS/OBS
Identifier:            obs
Version:               ???
Code Type:             ARM-64 (Native)
Parent Process:        launchd [1]
User ID:               501

Date/Time:             2021-10-27 02:16:33.5709 -0700
OS Version:            macOS 12.0 (21A344)
Report Version:        12
Anonymous UUID:        220CCD24-EEB7-400C-8E4D-97E4D748A4A4

Time Awake Since Boot: 170 seconds

System Integrity Protection: enabled

Crashed Thread:        0

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

Termination Reason:    Namespace DYLD, Code 1 Library missing
Library not loaded: /tmp/*/libavcodec.58.dylib
Referenced from: /Applications/OBS.app/Contents/Resources/bin/obs
Reason: tried: '/tmp/*/libavcodec.58.dylib' (no such file), '/usr/local/lib/libavcodec.58.dylib' (no such file), '/usr/lib/libavcodec.58.dylib' (no such file)
(terminated at launch; ignore backtrace)

Application Specific Information:
Library not loaded: /tmp/obsdeps/lib/libavcodec.58.dylib
Referenced from: /Applications/OBS.app/Contents/Resources/bin/obs
Reason: tried: '/tmp/obsdeps/lib/libavcodec.58.dylib' (no such file), '/usr/local/lib/libavcodec.58.dylib' (no such file), '/usr/lib/libavcodec.58.dylib' (no such file)

Thread 0 Crashed:
0   dyld                                   0x1052033dc 0x1051b8000 + 308188
1   dyld                                   0x10520a3dc 0x1051b8000 + 336860
2   dyld                                   0x10520a410 0x1051b8000 + 336912
3   dyld                                   0x1051c28e4 0x1051b8000 + 43236
4   dyld                                   0x1051bdfd4 0x1051b8000 + 24532
5   dyld                                   0x1051bd0d4 0x1051b8000 + 20692

Thread 0 crashed with ARM Thread State (64-bit):
    x0: 0x0000000000000006   x1: 0x0000000000000001   x2: 0x000000016b0a26d0   x3: 0x000000000000006a
    x4: 0x000000016b0a22d0   x5: 0x0000000000000000   x6: 0x0000000000000000   x7: 0x0000000000000000
    x8: 0x0000000000000020   x9: 0x0000000000000009  x10: 0x0000000000000001  x11: 0x000000000000000a
   x12: 0x0000000000000000  x13: 0x0000000000000031  x14: 0x000000026a4c9fe4  x15: 0x0000000000000000
   x16: 0x0000000000000209  x17: 0x00000001051bb168  x18: 0x0000000000000000  x19: 0x0000000000000000
   x20: 0x000000016b0a22d0  x21: 0x000000000000006a  x22: 0x000000016b0a26d0  x23: 0x0000000000000001
   x24: 0x0000000000000006  x25: 0x000000016b0a3038  x26: 0x0000000000000000  x27: 0x000000001f070004
   x28: 0x0000000000000000   fp: 0x000000016b0a22a0   lr: 0x000000010520a3dc
    sp: 0x000000016b0a2260   pc: 0x00000001052033dc cpsr: 0x00000000
   far: 0x0000000105180000  esr: 0x56000080  Address size fault

Binary Images:
       0x1051b8000 -        0x105217fff dyld (*) <c67eec77-8841-3ee4-921e-e3ac712475ad> /usr/lib/dyld

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=6704K resident=0K(0%) swapped_out_or_unallocated=6704K(100%)
Writable regions: Total=9216K written=0K(0%) resident=0K(0%) swapped_out=0K(0%) unallocated=9216K(100%)

                                VIRTUAL   REGION 
REGION TYPE                        SIZE    COUNT (non-coalesced) 
===========                     =======  ======= 
STACK GUARD                       56.0M        1 
Stack                             8176K        1 
VM_ALLOCATE                        1.0G        2 
__DATA                             192K        6 
__DATA_CONST                       224K        6 
__LINKEDIT                        2384K        6 
__TEXT                            4320K        6 
dyld private memory               1024K        1 
===========                     =======  ======= 
TOTAL                              1.1G       29 

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

{"app_name":"obs","timestamp":"2021-10-27 02:16:33.00 -0700","app_version":"","slice_uuid":"8f807ca4-0b21-3b80-9a5e-9d5ac26bbff2","build_version":"","platform":1,"share_with_app_devs":0,"is_first_party":1,"bug_type":"309","os_version":"macOS 12.0 (21A344)","incident_id":"FCA5C9F5-4523-4D61-9912-7303AC0B73AE","name":"obs"}
{
  "uptime" : 170,
  "procLaunch" : "2021-10-27 02:16:33.5321 -0700",
  "procRole" : "Default",
  "version" : 2,
  "userID" : 501,
  "deployVersion" : 210,
  "modelCode" : "MacBookPro18,2",
  "procStartAbsTime" : 4180151931,
  "coalitionID" : 1032,
  "osVersion" : {
    "train" : "macOS 12.0",
    "build" : "21A344",
    "releaseType" : "User"
  },
  "captureTime" : "2021-10-27 02:16:33.5709 -0700",
  "incident" : "FCA5C9F5-4523-4D61-9912-7303AC0B73AE",
  "bug_type" : "309",
  "pid" : 1133,
  "procExitAbsTime" : 4181075480,
  "translated" : false,
  "cpuType" : "ARM-64",
  "procName" : "obs",
  "procPath" : "\/Applications\/OBS.app\/Contents\/MacOS\/OBS",
  "parentProc" : "launchd",
  "parentPid" : 1,
  "coalitionName" : "com.obsproject.obs-studio",
  "crashReporterKey" : "220CCD24-EEB7-400C-8E4D-97E4D748A4A4",
  "sip" : "enabled",
  "isCorpse" : 1,
  "exception" : {"codes":"0x0000000000000000, 0x0000000000000000","rawCodes":[0,0],"type":"EXC_CRASH","signal":"SIGABRT"},
  "termination" : {"code":1,"flags":518,"namespace":"DYLD","indicator":"Library missing","details":["(terminated at launch; ignore backtrace)"],"reasons":["Library not loaded: \/tmp\/*\/libavcodec.58.dylib","Referenced from: \/Applications\/OBS.app\/Contents\/Resources\/bin\/obs","Reason: tried: '\/tmp\/*\/libavcodec.58.dylib' (no such file), '\/usr\/local\/lib\/libavcodec.58.dylib' (no such file), '\/usr\/lib\/libavcodec.58.dylib' (no such file)"]},
  "asi" : {"dyld":["Library not loaded: \/tmp\/obsdeps\/lib\/libavcodec.58.dylib","Referenced from: \/Applications\/OBS.app\/Contents\/Resources\/bin\/obs","Reason: tried: '\/tmp\/obsdeps\/lib\/libavcodec.58.dylib' (no such file), '\/usr\/local\/lib\/libavcodec.58.dylib' (no such file), '\/usr\/lib\/libavcodec.58.dylib' (no such file)"]},
  "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":11285,"threadState":{"x":[{"value":6},{"value":1},{"value":6090794704},{"value":106},{"value":6090793680},{"value":0},{"value":0},{"value":0},{"value":32},{"value":9},{"value":1},{"value":10},{"value":0},{"value":49},{"value":10373341156},{"value":0},{"value":521},{"value":4380668264},{"value":0},{"value":0},{"value":6090793680},{"value":106},{"value":6090794704},{"value":1},{"value":6},{"value":6090797112},{"value":0},{"value":520552452},{"value":0}],"flavor":"ARM_THREAD_STATE64","lr":{"value":4380992476},"cpsr":{"value":0},"fp":{"value":6090793632},"sp":{"value":6090793568},"esr":{"value":1442840704,"description":" Address size fault"},"pc":{"value":4380963804,"matchesCrashFrame":1},"far":{"value":4380426240}},"frames":[{"imageOffset":308188,"imageIndex":0},{"imageOffset":336860,"imageIndex":0},{"imageOffset":336912,"imageIndex":0},{"imageOffset":43236,"imageIndex":0},{"imageOffset":24532,"imageIndex":0},{"imageOffset":20692,"imageIndex":0}]}],
  "usedImages" : [
  {
    "source" : "P",
    "arch" : "arm64e",
    "base" : 4380655616,
    "size" : 393216,
    "uuid" : "c67eec77-8841-3ee4-921e-e3ac712475ad",
    "path" : "\/usr\/lib\/dyld",
    "name" : "dyld"
  }
],
  "sharedCache" : {
  "base" : 7383023616,
  "size" : 3046227968,
  "uuid" : "bf8bef8d-8074-3dd6-8c9b-cc48eb279f34"
},
  "vmSummary" : "ReadOnly portion of Libraries: Total=6704K resident=0K(0%) swapped_out_or_unallocated=6704K(100%)\nWritable regions: Total=9216K written=0K(0%) resident=0K(0%) swapped_out=0K(0%) unallocated=9216K(100%)\n\n                                VIRTUAL   REGION \nREGION TYPE                        SIZE    COUNT (non-coalesced) \n===========                     =======  ======= \nSTACK GUARD                       56.0M        1 \nStack                             8176K        1 \nVM_ALLOCATE                        1.0G        2 \n__DATA                             192K        6 \n__DATA_CONST                       224K        6 \n__LINKEDIT                        2384K        6 \n__TEXT                            4320K        6 \ndyld private memory               1024K        1 \n===========                     =======  ======= \nTOTAL                              1.1G       29 \n",
  "legacyInfo" : {
  "threadTriggered" : {

  }
},
  "trialInfo" : {
  "rollouts" : [
    {
      "rolloutId" : "601d9415f79519000ccd4b69",
      "factorPackIds" : {
        "SIRI_TEXT_TO_SPEECH" : "61704e71b6f6b8421579caf9"
      },
      "deploymentId" : 240000293
    },
    {
      "rolloutId" : "5ffde50ce2aacd000d47a95f",
      "factorPackIds" : {

      },
      "deploymentId" : 240000064
    },
    {
      "rolloutId" : "602ad4dac86151000cf27e46",
      "factorPackIds" : {
        "SIRI_DICTATION_ASSETS" : "6169fcae436117010456880f"
      },
      "deploymentId" : 240000238
    },
    {
      "rolloutId" : "5fc94383418129005b4e9ae0",
      "factorPackIds" : {

      },
      "deploymentId" : 240000145
    },
    {
      "rolloutId" : "60da5e84ab0ca017dace9abf",
      "factorPackIds" : {

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

  ]
}
}

Model: MacBookPro18,2, BootROM 7429.30.65, proc 10:8:2 processors, 32 GB, SMC 
Graphics: Apple M1 Max, Apple M1 Max, Built-In
Display: Color LCD, 3456 x 2234 Retina, Main, MirrorOff, Online
Memory Module: LPDDR5
AirPort: Wi-Fi, wl0: Aug 27 2021 17:35:57 version 20.56.3.0.8.7.104 FWID 01-58984411
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.

Seems that it can't find libavcodec. Strangely, copying libavcodec* from /opt/homebrew/lib/ over to /usr/local/lib/ where it's supposedly looking for it makes no difference; it will crash with the same output.

tjhorner commented 3 years ago

I get this too. Here's a temporary workaround until this gets resolved:

export DYLD_LIBRARY_PATH="/opt/homebrew/lib"
# might need to change the below to wherever your OBS.app is
/Applications/OBS.app/Contents/Resources/bin/obs

Note that this will technically be running inside of whatever terminal emulator you use, so you'll need to grant that access to accessibility, screen recording, etc.

BryanHaley commented 3 years ago

That worked to get it to open, but I've run into another strange issue:

 $ /Applications/OBS.app/Contents/Resources/bin/obs
error: Failed to load locale
info: == Profiler Results =============================
info: run_program_init: 11732.4 ms
info:  ┗OBSApp::AppInit: 8568.46 ms
info:    ┗OBSApp::InitLocale: 8566.16 ms
info: =================================================
info: == Profiler Time Between Calls ==================
info: =================================================
info: Number of memory leaks: 1
Screen Shot 2021-10-31 at 1 48 00 PM

I looked and confirmed that OBS.app/Contents/Resources/data/obs-plugins/obs-outputs/locale/en-US.ini exists and is identical to the version shipped with the Intel app.

Very strange that the application seems to be having issues finding files. Could this maybe be related to new file-access permissions in Monterey?

ntelementary commented 3 years ago

Can concur, I get the same "locale/en-US" issue as @BryanHaley after a fresh build when using the DYLD trick above.

One thought was that this was related to the com.apple.quarantine "xattrs" feature on the compiled package (you can see a note about this on the obs-deps GitHub page), but running a few xattr -p com.apple.quarantine checks on the Resources/data/...etc/...locale direction didn't show anything interesting.

File permissions seem correct in the package as well. Maybe this is a side-effect of the DYLD launch trick coming from a different terminal-process sandbox? (Wanton speculation here).

adamalbers commented 3 years ago

I just ran this script on my 2020 13" Macbook Pro M1 and had no errors. OBS seems much faster running natively with this build.

My terminal app (iTerm 2) has Full Disk Access and I had previously installed some prereqs described in a reddit post about compiling OBS for Apple Silicon.

brew install akeru-inc/tap/xcnotary cmake cmocka ffmpeg jack mbedtls@2 qt@5 swig vlc

https://www.reddit.com/r/MacOS/comments/mycoul/obs_for_m1/

Full Disk Access

BryanHaley commented 3 years ago

No dice with giving terminal full disk access and installing those things through brew.

adamalbers commented 3 years ago

Curiously, if I run /Applications/OBS.app/Contents/Resources/bin/obs from a terminal, I get the same locale/en-US error. But when I run from double clicking OBS.app in Finder, it opens without error.

This is all out of my wheelhouse as I'm not a programmer, but want to contribute what I can.

***EDIT: Have to change working directory then launch OBS in terminal to avoid the locale error.

cd /Applications/OBS.app/Contents/Resources/bin ./obs

BryanHaley commented 3 years ago

I deleted the OBS.app and ran the script fresh. This time, OBS works as expected; no need to launch it from the terminal.

Not sure what exactly changed between the first attempt and the most recent one. I don't think setting the DYLD_LIBRARY_PATH in my bash_profile would affect launching an app via finder. That just leaves running brew install akeru-inc/tap/xcnotary cmake cmocka ffmpeg jack mbedtls@2 qt@5 swig vlc before install. I thought the build script installs everything it needs before building, but maybe it's missing one of these? Or perhaps setting the DYLD_LIBRARY_PATH before building changes something?

ntelementary commented 3 years ago

Same here, after the suggestions I also tried a different build and — success!

It turns out I already had the packages installed that @adamalbers suggested. I do not have DLYD path overrides in my bash profile.

The only change I made before my rebuild was to grant Full Disk Access to Terminal in Preferences > Security.

After another build with the script, OBS is now running successfully on Apple-M1 architecture. It uses far less CPU than the Intel version, even when idle (from 100% on one core, down to ~72% CPU). And when actively streaming to twitch, it consumes drastically less CPU. The Intel version would peak at ~245% CPU, whereas the native version stayed around 140% or below in my testing.

Hopefully OBS will have native M1 builds soon, they're noticeably quicker to launch (~2 seconds versus 5-10 seconds), and saves tons of CPU.

The only downside is that Apple identifies the app as 'sh' (The application "sh" would like screen recording access), but this is a minor triviality.

BryanHaley commented 3 years ago

I also enabled full disk access for terminal before the build; forgot about that. Hopefully we'll get hardware encoding soon, but I suspect we'll have to wait for movement from the OBS team for that.

If anybody is reading this in the future looking for a solution, try the following:

  1. Grant your terminal app Full Disk Access in Security & Privacy, then run the build script again.
  2. If that doesn't work, try installing these libraries: brew install akeru-inc/tap/xcnotary cmake cmocka ffmpeg jack mbedtls@2 qt@5 swig vlc
  3. If that still doesn't work, try exporting the library path and opening OBS from the terminal.
    export DYLD_LIBRARY_PATH="/opt/homebrew/lib"
    # might need to change the below to wherever your OBS.app is
    cd /Applications/OBS.app/Contents/Resources/bin && ./obs
  4. If that still doesn't work, delete the generated OBS.app and try the build script over again.
tjhorner commented 3 years ago

Shouldn't we keep this issue open until the workaround is no longer needed?

carlosonunez commented 3 years ago

Hey, @BryanHaley ! Thanks for opening this issue. I apologize that you're running into this.

Which version of OBS are you trying to compile? I can't replicate this with OBS 27.0.1 on my M1 Pro MacBook.

You shouldn't need to enable FDA for OBS.

Also, can you show me your output from running ./install.sh?

carlosonunez commented 2 years ago

Closing due to staleness. Re-open and submit logs per the comment above if needed.