Skip to content
This repository has been archived by the owner on Dec 15, 2020. It is now read-only.

Support for DAL plugin built as a universal binary #240

Merged
merged 14 commits into from
Nov 26, 2020

Conversation

johnboiles
Copy link
Owner

This change separates out the dal-plugin build from x86-only obs-plugin build so that the dal-plugin can work on M1 Macs in universal applications.

@obelisk
Copy link

obelisk commented Nov 26, 2020

Have you tested this :D? I was looking into this for the last couple days but got stuck at the OBS libs, which I assumed needed to be compiled for arm64, which meant OBS needed to be compiled for arm64, which meant QT5 needed to be (where I got stuck with trying to find which patches I needed).

@johnboiles
Copy link
Owner Author

To run the OBS plugin as arm64 yes, you'd need OBS and all of OBS's dependencies to support arm64. BUT that's probably not what you want, you probably just want the DAL plugin compiled as universal so that it can run inside other universal apps as arm64. So you'd still have OBS running as x86 under Rosetta, but it could communicate to a DAL plugin compiled as a universal binary.

But no I haven't tested this! I don't have an M1 Mac yet. Just trying to create a binary so folks like you and @MatteAce in #239 can test. I can build something locally, and it looks right to me:

file src/dal-plugin/obs-mac-virtualcam.plugin/Contents/MacOS/obs-mac-virtualcam
src/dal-plugin/obs-mac-virtualcam.plugin/Contents/MacOS/obs-mac-virtualcam: Mach-O universal binary with 2 architectures: [x86_64:Mach-O 64-bit bundle x86_64] [arm64:Mach-O 64-bit bundle arm64]
src/dal-plugin/obs-mac-virtualcam.plugin/Contents/MacOS/obs-mac-virtualcam (for architecture x86_64):	Mach-O 64-bit bundle x86_64
src/dal-plugin/obs-mac-virtualcam.plugin/Contents/MacOS/obs-mac-virtualcam (for architecture arm64):	Mach-O 64-bit bundle arm64

@obelisk
Copy link

obelisk commented Nov 26, 2020

I am typing this on an M1 machine and will be first in line to let you know!

mkdir obs-mac-virtualcam/build
cd obs-mac-virtualcam/build

cmake -DLIBOBS_INCLUDE_DIR:STRING=$GITHUB_WORKSPACE/obs-studio/libobs \
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is what I'm worried about, don't these also need to be compiled arm64?

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nah, not for the dal plugin to work

@johnboiles
Copy link
Owner Author

Hmm I'm struggling to get the GitHub build to work, but you could try compiling yourself using these instructions

https://github.com/johnboiles/obs-mac-virtualcam/wiki/Developing

Except use this to compile the dal-plugin:

cmake -DLIBOBS_INCLUDE_DIR:STRING=$OBS_DIR/libobs -DLIBOBS_LIB:STRING=$OBS_DIR/build/libobs/libobs.dylib -DOBS_FRONTEND_LIB:STRING=$OBS_DIR/build/UI/obs-frontend-api/libobs-frontend-api.dylib -DQTDIR:STRING=$QTDIR -D CMAKE_OSX_ARCHITECTURES="arm64;x86_64" ..
make -j dal-plugin

@obelisk
Copy link

obelisk commented Nov 26, 2020

On it!

@obelisk
Copy link

obelisk commented Nov 26, 2020

Brew is pretty broken on M1 machines, I've got it running in experimental mode but lots of formulas fail (which is why I was trying to built QT from scratch). Do I need to install all those deps from the document?

Running the cmake command seems to fail looking for QT which is why I ask.

I'll update here if I have any success!

@johnboiles
Copy link
Owner Author

Hmmm I see. All those dependencies aren't required for the dal-plugin target, but maybe CMake will fail without them. I wonder if there's a way to tell CMake to ignore everything but a specific target, in which case you can probably leave all those flags about OBS and QT blank.

@johnboiles
Copy link
Owner Author

You could always hack up the CMakeLists.txt files to remove the obs-plugin build all together

@obelisk
Copy link

obelisk commented Nov 26, 2020

Hahaha, I literally tried that seconds before you commented. The build did succeed then. I'm testing it now.

@obelisk
Copy link

obelisk commented Nov 26, 2020

I tried replacing the plugin in /Library/CoreMediaIO/Plug-Ins/obs-mac-virtualcam.plugin with the new one but Safari still doesn't pick it, even after a reboot. I did resign it with my own developer key as well to try and give it more system credence.

@johnboiles
Copy link
Owner Author

johnboiles commented Nov 26, 2020

Do you mean /Library/CoreMediaIO/Plug-Ins/DAL/obs-mac-virtualcam.plugin?

Any logs in Console.app about it? What if you run file /Library/CoreMediaIO/Plug-Ins/DAL/obs-mac-virtualcam.plugin/Contents/MacOS/obs-mac-virtualcam

@obelisk
Copy link

obelisk commented Nov 26, 2020

➜  build git:(bfc405a) ✗ file /Library/CoreMediaIO/Plug-Ins/DAL/obs-mac-virtualcam.plugin/Contents/MacOS/obs-mac-virtualcam
/Library/CoreMediaIO/Plug-Ins/DAL/obs-mac-virtualcam.plugin/Contents/MacOS/obs-mac-virtualcam: Mach-O universal binary with 2 architectures: [x86_64:Mach-O 64-bit bundle x86_64] [arm64:Mach-O 64-bit bundle arm64]
/Library/CoreMediaIO/Plug-Ins/DAL/obs-mac-virtualcam.plugin/Contents/MacOS/obs-mac-virtualcam (for architecture x86_64):	Mach-O 64-bit bundle x86_64
/Library/CoreMediaIO/Plug-Ins/DAL/obs-mac-virtualcam.plugin/Contents/MacOS/obs-mac-virtualcam (for architecture arm64):	Mach-O 64-bit bundle arm64
➜  build git:(bfc405a) ✗ lipo -archs /Library/CoreMediaIO/Plug-Ins/DAL/obs-mac-virtualcam.plugin/Contents/MacOS/obs-mac-virtualcam
x86_64 arm64
➜  build git:(bfc405a) ✗

Checking console now

@johnboiles
Copy link
Owner Author

I wonder if there's something we need to add to the Info.plist to mark that it's universal

@obelisk
Copy link

obelisk commented Nov 26, 2020

I just tried Firefox (x86_64) and the the virtual camera does show up there still which may be useful to know.

@johnboiles
Copy link
Owner Author

Ok! So the universal binary didn't break both architectures at least. That's good.

This doc mentions setting LSRequiresNativeExecution or LSArchitecturePriority to tell the system it definitely should use arm64. But doesn't seem like it should be necessary.

What universal browser are you testing in? Does Chrome have a universal build?

@obelisk
Copy link

obelisk commented Nov 26, 2020

Ha! I found something at least, it works in Chrome (Universal, going to confirm its running arm64), it does not work in Safari.

@johnboiles
Copy link
Owner Author

johnboiles commented Nov 26, 2020

Awesome!!! I bet Safari just disabled plugins all-together and Apple didn't feel like it was worth it to implement plugins correctly and just disabled them instead.

(I've seen reports they did that for QuickTime in Big Sur)

@obelisk
Copy link

obelisk commented Nov 26, 2020

I bet you that's it.

@johnboiles
Copy link
Owner Author

Ok so why isn't the GH action working? :)

@obelisk
Copy link

obelisk commented Nov 26, 2020

I ran Chrome manually using arch -arch arm64 /Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome so I'm quite sure. Bummer about Safari but what you going to do eh?

@MatteAce
Copy link

hey!! sorry for being late, but I wouldn't have been much of an help here, since I have a background in web developing and know nothing about compiling! :)
I'm dowloading the plugins right now, I'll test and check back! thank you so much for your help!!

@obelisk
Copy link

obelisk commented Nov 26, 2020

Gives what looks like a notarization error

@obelisk
Copy link

obelisk commented Nov 26, 2020

Screen Shot 2020-11-26 at 6 17 44 PM

@MatteAce
Copy link

Same for me, I've been able to bypass it in the Security & Privacy pane, but it still won't show up

@obelisk
Copy link

obelisk commented Nov 26, 2020

Here is the issue I think:

First the the artifact downloaded, second is the old version. Tl;dr, not signed with a developer certificate

➜  DAL codesign -dvvv obs-mac-virtualcam.plugin
Executable=/Library/CoreMediaIO/Plug-Ins/DAL/obs-mac-virtualcam.plugin/Contents/MacOS/obs-mac-virtualcam
Identifier=com.johnboiles.obs-mac-virtualcam.dal-plugin
Format=bundle with Mach-O universal (x86_64 arm64)
CodeDirectory v=20100 size=1949 flags=0x2(adhoc) hashes=55+3 location=embedded
Hash type=sha256 size=32
CandidateCDHash sha256=b09aaed152fd282a19ed3517c06f038b86ad886b
CandidateCDHashFull sha256=b09aaed152fd282a19ed3517c06f038b86ad886b5372217b53ccb7d0ecdc2759
Hash choices=sha256
CMSDigest=b09aaed152fd282a19ed3517c06f038b86ad886b5372217b53ccb7d0ecdc2759
CMSDigestType=2
CDHash=b09aaed152fd282a19ed3517c06f038b86ad886b
Signature=adhoc
Info.plist entries=13
TeamIdentifier=not set
Sealed Resources version=2 rules=13 files=0
Internal requirements count=0 size=12


➜  DAL codesign -dvvv obs-mac-virtualcam.plugin
Executable=/Library/CoreMediaIO/Plug-Ins/DAL/obs-mac-virtualcam.plugin/Contents/MacOS/obs-mac-virtualcam
Identifier=com.johnboiles.obs-mac-virtualcam.dal-plugin
Format=bundle with Mach-O thin (x86_64)
CodeDirectory v=20200 size=1964 flags=0x0(none) hashes=55+3 location=embedded
Hash type=sha256 size=32
CandidateCDHash sha256=310a54efc1504b13b4cf0eb8487c30fafabe4e8f
CandidateCDHashFull sha256=310a54efc1504b13b4cf0eb8487c30fafabe4e8f15fe1d03a11c620769059094
Hash choices=sha256
CMSDigest=310a54efc1504b13b4cf0eb8487c30fafabe4e8f15fe1d03a11c620769059094
CMSDigestType=2
CDHash=310a54efc1504b13b4cf0eb8487c30fafabe4e8f
Signature size=8971
Authority=Developer ID Application: John Boiles (62G85M9ZN5)
Authority=Developer ID Certification Authority
Authority=Apple Root CA
Timestamp=Oct 21, 2020 at 2:44:39 PM
Info.plist entries=13
TeamIdentifier=62G85M9ZN5
Sealed Resources version=2 rules=13 files=0
Internal requirements count=1 size=204
➜  DAL

@johnboiles
Copy link
Owner Author

Ok! I'll go ahead and make a release-y build so all the notarization stuff happens.

@MatteAce still won't show up where? What app are you using to try it?

@johnboiles johnboiles merged commit 17c9d8c into master Nov 26, 2020
@johnboiles johnboiles deleted the john/universal-binary branch November 26, 2020 23:21
johnboiles added a commit that referenced this pull request Nov 26, 2020
* Separate universal dal-plugin build from x86-only obs-plugin build

* Try building on macOS Big Sur instead

* Temporarily use MACOSX_DEPLOYMENT_TARGET 10.015

* Try the CPATH fix

* Try a different CPATH

* Also try LIBRARY_PATH

* Dump cmake version because I'm curious

* Try newer cmake

* Sanity check -- only build x86

* Continue to beat my head against the wall

* Bring back arm64 now with updated cmake

* Try big sur again with updated cmake

* Use setup-xcode to update xcode (hopefully)

* Don't blow away obs plugin
@johnboiles johnboiles changed the title [Needs testers] Support for DAL plugin built as a universal binary Support for DAL plugin built as a universal binary Nov 26, 2020
@MatteAce
Copy link

Ok! I'll go ahead and make a release-y build so all the notarization stuff happens.

@MatteAce still won't show up where? What app are you using to try it?

Chrome Universal Binary, on streamyard.com

@johnboiles
Copy link
Owner Author

Ok try the notarized .pkg version here.

@MatteAce
Copy link

Ok try the notarized .pkg version here.

still not showing up... should I reboot?

@johnboiles
Copy link
Owner Author

johnboiles commented Nov 26, 2020 via email

@MatteAce
Copy link

Yeah try that

nope. but I think something happened with chrome x86... when I launched it, it told me about obs virtualcam being from an unknown dev. inside the browser, the virtualcam plugin is showing black, not the usual blue test screen that appears before you start the virtual cam from OBS. I'll try and uninstall everything and then reinstall the pkg

@obelisk
Copy link

obelisk commented Nov 26, 2020

Works for me with the small caveat I had to manually remove the old version first.

@obelisk
Copy link

obelisk commented Nov 26, 2020

@MatteAce are you running on an M1? If so you want to be running it arm64 mode, not x86_64 which will run through rosetta2.

@MatteAce
Copy link

@MatteAce are you running on an M1? If so you want to be running it arm64 mode, not x86_64 which will run through rosetta2.

yeah I know, but since the universal app wasn't working, I tried the x86 app as well

@MatteAce
Copy link

Works for me with the small caveat I had to manually remove the old version first.

YES!! it works now! I just removed the old files from the DAL folder!

@johnboiles
Copy link
Owner Author

Ok! That's probably because I haven't bumped the version in master yet. It seems like the pkg installer won't overwrite what exists unless it is an older version. Ok! I'll cut a real release!

@MatteAce
Copy link

MatteAce commented Nov 26, 2020

Ok! That's probably because I haven't bumped the version in master yet. It seems like the pkg installer won't overwrite what exists unless it is an older version. Ok! I'll cut a real release!

just FYI, the old x86 plugin won't work together with the new Universal plugin. I've put the old plugin back in the DAL folder, renamed as obs-mac-virtualcam-x86.plugin and it just shows a black screen
UPDATE: the Universal plugin won't work either if the old x86 version exists in the folder

@obelisk
Copy link

obelisk commented Nov 26, 2020

Because the binary is universal, it should work in both, testing now.

Edit: Confirmed, starting chrome in x86_64, it still works.

@MatteAce
Copy link

Because the binary is universal, it should work in both, testing now.

Edit: Confirmed, starting chrome in x86_64, it still works.

you're right! my bad, it works for both

@MatteAce
Copy link

confirmed working on Firefox-x86 too

@johnboiles
Copy link
Owner Author

Yep confirmed on my Intel Mac too. Still works just fine for me.

@MatteAce
Copy link

Yep confirmed on my Intel Mac too. Still works just fine for me.

thank you John for your precious work! you're a lifesaver!

@johnboiles
Copy link
Owner Author

OK done! https://github.com/johnboiles/obs-mac-virtualcam/releases/tag/v1.3.0

@obelisk
Copy link

obelisk commented Nov 26, 2020

Thanks @johnboiles! I second @MatteAce's comment

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants