johnboiles / obs-mac-virtualcam

ARCHIVED! This plugin is officially a part of OBS as of version 26.1. See note below for info on upgrading. 🎉🎉🎉Creates a virtual webcam device from the output of OBS. Especially useful for streaming smooth, composited video into Zoom, Hangouts, Jitsi etc. Like CatxFish/obs-virtualcam but for macOS.
GNU General Public License v2.0
4.06k stars 160 forks source link

obs-mac-virtualcam crashing usb-c ports #127

Closed christopher-wong closed 4 years ago

christopher-wong commented 4 years ago

Describe the bug When I'm using obs-mac-virtualcam, I have an issue where after a few minutes, my USB-C ports stop working. Any devices connected over USB-C fail to respond (webcam freezes, mouse stops working, audio devices fail). It seems weird to me that the plugin would cause this behavior, however, it's only reproducible while running OBS and the virtual cam plugin.

To recover from this, I have to quit OBS, unplug, and replug any devices connected over USB-C.

To Reproduce Steps to reproduce the behavior:

  1. Open OBS, enable virtual camera
  2. Apply Chroma Key effect (not sure if this is relevant).
  3. After a few minutes of using the virtual cam, USB-C ports will stop working.

Expected behavior External USB-C connected devices should not crash

Desktop (please complete the following information):

Additional context My webcam is the 1080p camera built into the LG Ultrafine 5K, connected via USB-C

gxalpha commented 4 years ago

Have you tried if it happens without the webcam and just OBS (maybe put in a text source)? If that works, have you tried the webcam in OBS without the virtualcam plugin?

Please report back.

johnboiles commented 4 years ago

This is a weird one. Also I'm jealous of your monitor.

Both good ideas @gxalpha!

+1 especially to trying to stream the webcam in OBS with this plugin installed (stream to Twitch/Twitter/Youtube). I think that's the best way to determine if the issue is related to this plugin or not. Also take a look at Console.app to see if there are any relevant logs.

You might also want to try switching around your usb-c ports. macOS apparently does weird things when the left usb-c ports get too hot.

christopher-wong commented 4 years ago

Thanks for the suggestions @gxalpha and @johnboiles, I'l give it a try and report back.

christopher-wong commented 4 years ago

Streaming to Twitch directly via OBS with the plugin installed worked perfectly for the full duration of my 30 minute test stream.

When I switched over to Google Chrome + virtualcam input, the Webcam input in OBS kept disappearing until I unplug, replug again. This only occurs while virtualcam is enabled and being used as a source.

I've also switched to using my top-right usb-c port, in the event that it's hardware related. I've also uninstalled the Snapchat Camera app, but not sure if that would be a factor either.

Screen Shot 2020-05-18 at 6 54 59 PM (2)
johnboiles commented 4 years ago

Thanks for confirming this does not happen during normal streaming with OBS!

When you say 'Webcam input in OBS kept disappearing' do you mean the 'OBS Virtual Camera' device would disappear from Chrome or also your normal webcam would disappear? Do you see anything in Console.app that looks relevant when it happens?

If the obs-mac-virtualcam DAL plugin crashes (or if any DAL plugin crashes, including Snapchat) then it will cause all of your webcam devices to not show up in Chrome.

christopher-wong commented 4 years ago

Sorry, let me clarify.

The OBS Virtual Camera input stays selected in Chrome, however my external webcam device disappears from OBS as shown in the image above. At this point my external webcam is no longer available in either OBS or Chrome as it seems to have crashed the USB-C device.

Unplugging and replugging the device makes it selectable again. Is there something specific I should be looking for in Console.app? Nothing under obs-mac-virtualcam

Screen Shot 2020-05-18 at 7 54 33 PM
johnboiles commented 4 years ago

I'm not sure what you're looking for in Console.app necessarily. Maybe search USB? sudo dmesg might also have something useful.

To me this sounds like it could potentially be a power issue of some kind. Do you also have a macbook power adapter connected? According to the Apple store page on the Ultrafine 5k 'for optimal performance on the 16-inch MacBook Pro, connect to power using the MacBook Pro’s 96W adapter.' Presumably whoever added that copy had a reason to mention that on the store page.

CoreMediaIO DAL plugins can't do a whole lot, but they can use CPU, which increases heat and power consumption. Chrome also uses a lot of CPU in my experience. The fact that it runs for a few minutes before failing makes me think it could be power or heat related.

christopher-wong commented 4 years ago

Interesting find!

I was powering my 16" MacBook Pro solely via the usb-c cable from the Ultrafine 5K which can only deliver 94w. I've switched to the 96w adapter that comes in the box. 🤞🏻

johnboiles commented 4 years ago

I can't imagine that the power output difference between 94w vs 96w is really what's making the difference. I routinely run my 15" 8-core i9 off of my HPZ27's 65W power and it sometimes drains the battery a tad, but is stable. What I suspect is that there's some glitch when pushing the UltraFine 5k's power to its limits. I'm super interested to hear the results!!

christopher-wong commented 4 years ago

Switching to my other 96w power adapter doesn't appear to have helped. I was able to verify that my MacBook was charging at full speed from the included charger and NOT the Ultrafine 5k, which in theory takes a lot of load off of the display.

During a test run of using OBS + virtualcam in Chrome, my MacBook did kernel panic and I was able to grab the logs.

panic(cpu 2 caller 0xffffff7f895c9d17): @/AppleInternal/BuildRoot/Library/Caches/com.apple.xbs/Sources/IOUSBHostFamily_Drivers/IOUSBHostFamily-800.101.4/AppleUSBXHCI/AppleUSBXHCITransferRing.cpp:139
Backtrace (CPU 2), Frame : Return Address
0xffffffa3f88637f0 : 0xffffff8005f215cd 
0xffffffa3f8863840 : 0xffffff800605a3c5 
0xffffffa3f8863880 : 0xffffff800604bf7e 
0xffffffa3f88638d0 : 0xffffff8005ec7a40 
0xffffffa3f88638f0 : 0xffffff8005f20c97 
0xffffffa3f88639f0 : 0xffffff8005f21087 
0xffffffa3f8863a40 : 0xffffff80066c2c7c 
0xffffffa3f8863ab0 : 0xffffff7f895c9d17 
0xffffffa3f8863ac0 : 0xffffff7f895ac734 
0xffffffa3f8863b00 : 0xffffff7f895c33c8 
0xffffffa3f8863b20 : 0xffffff7f895c9aa5 
0xffffffa3f8863b40 : 0xffffff7f895c93fc 
0xffffffa3f8863b80 : 0xffffff7f898519e4 
0xffffffa3f8863bb0 : 0xffffff8006630048 
0xffffffa3f8863c10 : 0xffffff7f869fcb0e 
0xffffffa3f8863c60 : 0xffffff7f86a30a19 
0xffffffa3f8863c80 : 0xffffff8006630048 
0xffffffa3f8863ce0 : 0xffffff7f86a11d76 
0xffffffa3f8863d30 : 0xffffff8006630048 
0xffffffa3f8863d90 : 0xffffff7f86a0e261 
0xffffffa3f8863db0 : 0xffffff80065ff6f5 
0xffffffa3f8863de0 : 0xffffff8006607023 
0xffffffa3f8863e60 : 0xffffff7f86a1c6bd 
0xffffffa3f8863ea0 : 0xffffff7f86a08c28 
0xffffffa3f8863ec0 : 0xffffff8005f63545 
0xffffffa3f8863f40 : 0xffffff8005f63071 
0xffffffa3f8863fa0 : 0xffffff8005ec713e 
      Kernel Extensions in backtrace:
         com.apple.iokit.IOUSBHostFamily(1.2)[CC813BD5-B83C-3B83-A95E-796D87DE8F81]@0xffffff7f869e3000->0xffffff7f86adcfff
            dependency: com.apple.driver.AppleBusPowerController(1.0)[DEBDD821-1472-371A-896A-BC5C19BD76D0]@0xffffff7f869c9000
            dependency: com.apple.driver.AppleUSBHostMergeProperties(1.2)[19CEF2B0-63C1-34CC-A9CD-BDF842BE5CB3]@0xffffff7f869d1000
            dependency: com.apple.driver.usb.AppleUSBCommon(1.0)[A9FB7951-7658-34C4-9A44-0B6DBE6F7F78]@0xffffff7f869d5000
         com.apple.driver.usb.AppleUSBXHCI(1.2)[08964881-BCC5-3A07-B3CA-DF5B3512B740]@0xffffff7f89593000->0xffffff7f895eafff
            dependency: com.apple.iokit.IOACPIFamily(1.4)[9D1FF279-C4A2-3344-902F-E0B22B508689]@0xffffff7f86908000
            dependency: com.apple.iokit.IOUSBHostFamily(1.2)[CC813BD5-B83C-3B83-A95E-796D87DE8F81]@0xffffff7f869e3000
            dependency: com.apple.driver.usb.AppleUSBCommon(1.0)[A9FB7951-7658-34C4-9A44-0B6DBE6F7F78]@0xffffff7f869d5000
         com.apple.driver.usb.AppleUSBXHCIPCI(1.2)[5B0343A2-9C4B-3A81-81C3-03601B394CED]@0xffffff7f89849000->0xffffff7f8987dfff
            dependency: com.apple.iokit.IOACPIFamily(1.4)[9D1FF279-C4A2-3344-902F-E0B22B508689]@0xffffff7f86908000
            dependency: com.apple.iokit.IOPCIFamily(2.9)[1B1F3BBB-9212-3CF9-94F8-8FEF0D3ACEC4]@0xffffff7f86911000
            dependency: com.apple.iokit.IOUSBHostFamily(1.2)[CC813BD5-B83C-3B83-A95E-796D87DE8F81]@0xffffff7f869e3000
            dependency: com.apple.driver.usb.AppleUSBCommon(1.0)[A9FB7951-7658-34C4-9A44-0B6DBE6F7F78]@0xffffff7f869d5000
            dependency: com.apple.driver.usb.AppleUSBXHCI(1.2)[08964881-BCC5-3A07-B3CA-DF5B3512B740]@0xffffff7f89593000

BSD process name corresponding to current thread: kernel_task
Boot args: chunklist-security-epoch=0 -chunklist-no-rev2-dev

Mac OS version:
19E287

Kernel version:
Darwin Kernel Version 19.4.0: Wed Mar  4 22:28:40 PST 2020; root:xnu-6153.101.6~15/RELEASE_X86_64
Kernel UUID: AB0AA7EE-3D03-3C21-91AD-5719D79D7AF6
Kernel slide:     0x0000000005c00000
Kernel text base: 0xffffff8005e00000
__HIB  text base: 0xffffff8005d00000
System model name: MacBookPro16,1 (Mac-E1008331FDC96864)
System shutdown begun: NO

System uptime in nanoseconds: 7187311190878
last loaded kext at 4883826502538: >usb.IOUSBHostHIDDevice  1.2 (addr 0xffffff7f89ade000, size 45056)
last unloaded kext at 5280746922663: >usb.IOUSBHostHIDDevice    1.2 (addr 0xffffff7f89ade000, size 45056)
loaded kexts:
@kext.AMDRadeonX6000    3.0.8
@kext.AMDRadeonServiceManager   3.0.8
>!AGraphicsDevicePolicy 5.1.16
@fileutil   20.036.15
@AGDCPluginDisplayMetrics   5.1.16
>!AHV   1
|IOUserEthernet 1.0.1
|IO!BSerialManager  7.0.4f6
>AGPM   111.4.4
>!APlatformEnabler  2.7.0d0
>X86PlatformShim    1.0.0
>!AUpstreamUserClient   3.6.8
>pmtelemetry    1
>AGDCBacklightControl   5.1.16
>!A!IKBLGraphics    14.0.5
@Dont_Steal_Mac_OS_X    7.0.0
>BridgeAudioCommunication   6.70.3
>!AThunderboltIP    3.1.4
@macos.driver.!UEthernetHost    8.1.1
>!ABridgeAudio!C    6.70.3
>!AMCCSControl  1.11
>!AAVEBridge    6.1
>!AGFXHDA   100.1.426
>!ATopCaseHIDEventDriver    3430.1
>!A!IPCHPMC 2.0.1
>!AHIDALSService    1
>!A!ICFLGraphicsFramebuffer 14.0.5
>!AMuxControl2  5.1.16
>!A!ISlowAdaptiveClocking   4.0.0
@filesystems.autofs 3.0
>usb.!UHostBillboardDevice  1.0
>usb.realtek8153patcher 5.0.0
>BCMWLANFirmware4355.Hashstore  1
>BCMWLANFirmware4364.Hashstore  1
>BCMWLANFirmware4377.Hashstore  1
>!ABCMWLANBusInterfacePCIe  1
@filesystems.hfs.kext   522.100.5
@BootCache  40
@!AFSCompression.!AFSCompressionTypeDataless    1.0.0d1
@!AFSCompression.!AFSCompressionTypeZlib    1.0.0
>!AVirtIO   1.0
@filesystems.apfs   1412.101.1
@private.KextAudit  1.0
>!ASmartBatteryManager  161.0.0
>!AACPIButtons  6.1
>!ASMBIOS   2.1
>!AACPIEC   6.1
>!AAPIC 1.7
$!AImage4   1
@nke.applicationfirewall    303
$TMSafetyNet    8
@!ASystemPolicy 2.0.0
|EndpointSecurity   1
>!A!BHIDKeyboard    209
@kext.AMDRadeonX6100HWLibs  1.0
@kext.AMDRadeonX6000HWServices  3.0.8
|IOAVB!F    840.3
>!ASSE  1.0
>!ABacklightExpert  1.1.0
@kext.AMDRadeonX6000Framebuffer 3.0.8
@!AGPUWrangler  5.1.16
>!UAudio    322.2
|IO!BHost!CUARTTransport    7.0.4f6
|IO!BHost!CTransport    7.0.4f6
>!A!ILpssUARTv1 3.0.60
>!A!ILpssUARTCommon 3.0.60
>!AOnboardSerial    1.0
>X86PlatformPlugin  1.0.0
>!ASMBus!C  1.0.18d1
|IONDRVSupport  575.1
>!AActuatorDriver   3440.1
>!AHS!BDriver   3430.1
>IO!BHIDDriver  7.0.4f6
>!AMultitouchDriver 3440.1
>!AInputDeviceSupport   3440.8
>IOPlatformPlugin!F 6.0.0d8
>!AHIDKeyboard  209
@kext.AMDSupport    3.0.8
|IOAccelerator!F2   438.4.5
@!AGraphicsDeviceControl    5.1.16
|IOGraphics!F   575.1
>!AGraphicsControl  5.1.16
@plugin.IOgPTPPlugin    840.3
|IOEthernetAVB!C    1.1.0
|IOSlowAdaptiveClocking!F   1.0.0
@kext.triggers  1.0
>usb.cdc.ncm    5.0.0
>usb.cdc    5.0.0
>usb.networking 5.0.0
>usb.!UHostCompositeDevice  1.2
>usb.!UHub  1.2
>!AThunderboltDPOutAdapter  6.2.6
>!AThunderboltPCIUpAdapter  2.5.4
>!ABCMWLANCore  1.0.0
>mDNSOffloadUserClient  1.0.1b8
>IOImageLoader  1.0.0
|IO80211!FV2    1200.12.2b1
>corecapture    1.0.4
|IOSkywalk!F    1
|IOSurface  269.11
@filesystems.hfs.encodings.kext 1
|IOAudio!F  300.2
@vecLib.kext    1.2.0
|IOSerial!F 11
>usb.!UVHCIBCE  1.2
>usb.!UVHCI 1.2
>usb.!UVHCICommonBCE    1.0
>usb.!UVHCICommon   1.0
>!AEffaceableNOR    1.0
|IOBufferCopy!C 1.1.0
|IOBufferCopyEngine!F   1
|IONVMe!F   2.1.0
>!AThunderboltPCIDownAdapter    2.5.4
>!AThunderboltDPInAdapter   6.2.6
>!AThunderboltDPAdapter!F   6.2.6
>!AHPM  3.4.4
>!A!ILpssI2C!C  3.0.60
>!A!ILpssDmac   3.0.60
>!A!ILpssI2C    3.0.60
>!AThunderboltNHI   5.8.6
|IOThunderbolt!F    7.6.0
>usb.!UXHCIPCI  1.2
>usb.!UXHCI 1.2
|IOUSB!F    900.4.2
>!AEFINVRAM 2.1
>!AEFIRuntime   2.1
>!ASMCRTC   1.0
|IOSMBus!F  1.1
|IOHID!F    2.0.0
$quarantine 4
$sandbox    300.0
@kext.!AMatch   1.0.0d1
>!AKeyStore 2
>!UTDM  489.101.1
|IOSCSIBlockCommandsDevice  422.101.1
>!ACredentialManager    1.0
>KernelRelayHost    1
>!ASEPManager   1.0.1
>IOSlaveProcessor   1
>!AFDEKeyStore  28.30
>!AEffaceable!S 1.0
>!AMobileFileIntegrity  1.0.5
@kext.CoreTrust 1
|CoreAnalytics!F    1
|IOTimeSync!F   840.3
|IONetworking!F 3.4
>DiskImages 493.0.0
|IO!B!F 7.0.4f6
|IO!BPacketLogger   7.0.4f6
|IOUSBMass!SDriver  157.101.3
|IOSCSIArchitectureModel!F  422.101.1
|IO!S!F 2.1
|IOUSBHost!F    1.2
>usb.!UCommon   1.0
>!UHostMergeProperties  1.2
>!ABusPower!C   1.0
|IOReport!F 47
>!AACPIPlatform 6.1
>!ASMC  3.1.9
>watchdog   1
|IOPCI!F    2.9
|IOACPI!F   1.4
@kec.pthread    1
@kec.corecrypto 1.0
@kec.Libm   1
johnboiles commented 4 years ago

Wow so full kernel panic and restart? So that establishes its at least not entirely my plugin's fault! Obviously nothing done at the DAL plugin level (in user space) should be able to crash the kernel. You got any low level Apple engineers nearby that could help interpret a stack trace or give us some next steps to investigate?

johnboiles commented 4 years ago

Have you tried using a lower resolution from your webcam and a lower output resolution from OBS to see if that changes anything? Might be an interesting data point

christopher-wong commented 4 years ago

Wow so full kernel panic and restart? So that establishes its at least not entirely my plugin's fault! Obviously nothing done at the DAL plugin level (in user space) should be able to crash the kernel. You got any low level Apple engineers nearby that could help interpret a stack trace or give us some next steps to investigate?

Full panic and restart 😱 - I'll ask around for some help reading this stack trace.....

Have you tried using a lower resolution from your webcam and a lower output resolution from OBS to see if that changes anything? Might be an interesting data point

I've actually been running the webcam using the OBS 1280x720 preset. My primary use case is video conferencing and going above that didn't seem necessary to me due to all the compression on services like Google Meets and Webex anyway

johnboiles commented 4 years ago

@christopher-wong any update here? I'm fascinated by this one

christopher-wong commented 4 years ago

The stack trace ended up just being a generic error with not much extra detail.

I've switched to using the virtual-cam in Firefox and as long as I don't have any devices drawing power beyond my external mic and display everything works just fine. It seems to be vaguely a power related issue, even when using the stock power brick.

johnboiles commented 4 years ago

Wild. I'm going to close this as it seems very specific to your setup, but I'd be super interested to hear if you figure it out definitively.

johnboiles commented 4 years ago

And if you happen to know anyone at Apple considering the future of CoreMediaIO DAL plugins I'd love to chat with them. It seems like macOS could run DAL plugins in a separate process provided by the OS and then communicate with that process transparently in the AVFoundation APIs. Then it wouldn't be a security risk for apps to support DAL plugins.

This is kinda what Chrome does to make DAL plugins secure.