This change fixes a memory leak in the mac-virtualcam plugin that causes
OBS to not release the CVPixelBuffers (and underlying IOSurfaces)
it emits to the virtual camera consumers.
Pull request https://github.com/obsproject/obs-studio/pull/6573 (Avoid
transcoding where possible) updated the mac-virtualcam to share the
virtual camera feed with other processes via IOSurfaces.
Although the changes work correctly, users have observed that OBS memory
usage keeps increasing when the virtual camera is active until OBS runs
out of memory or the consuming application is closed.
See the report by @SciTechNick for more information:
https://github.com/obsproject/obs-studio/pull/6573#issuecomment-1161979765
After some debugging, I have found that the plugin is leaking Mach ports
associated with IOSurfaces, preventing them from being re-used. The
previous approach using `NSMachPort` does not seem to properly release
the Mach port allocated via `CVPixelBufferGetIOSurface` and
`IOSurfaceLookupFromMachPort`. Instead, we must explicitly deallocate
the port using `mach_port_deallocate`.
I have tested the changes on a Macbook Pro (M1) running macOS Monterey with
Google Chrome, Zoom, and Cameo. OBS shows no signs of memory leakage
after multiple minutes.
This change fixes an issue with the CMIO DAL plugin where the CMIO
subsystem would log multiple errors when starting the virtual camera,
due to certain properties that could not be set (frame rate and format).
For now, we just ignore the assignment, but mark the property as
settable to suppress the error messages that are reported by the CMIO
subsystem.
This change fixes an issue in the Mach server exposed by the macOS
virtual camera for OBS, where it would not invalidate ports that were
disconnected by the remote application, causing sporadic crashes.
These crashes can be reproduced in the previous builds by opening the
virtual camera in a remote application and closing the application
(without stopping the virtual camera).
This change updates the implementation of the mac-virtualcam plugin to
not use any global state and instead rely on the state object that is
passed by the OBS module system.
This approach is similar to the virtual camera implementations for Linux
and Windows.
This change removes the unused CMSampleBuffer utility functions that
were still left from the previous implementation. Since we construct the
CMSampleBuffer directly from an IOSurface, we do not need any custom
construction logic anymore, since that is now performed by the OBS
plugin.
This change updates the mac-virtualcam implementation to conditionally
enable conversion of the output video format. Previously, the output
video was always converted into UYVY. However, this conversion exhibits
high CPU usage, as reported in:
https://github.com/johnboiles/obs-mac-virtualcam/issues/102
Therefore, we disable conversion when the selected output format (e.g.,
NV12) is natively supported by CoreVideo's pixel buffers.
This change updates the plugin to support video formats that contain
multiple planes (such as NV12). Such functionality is necessary to
prevent transcoding the raw video data, which is often delivered in a
planar format.
This change updates the mac-virtualcam implementation to pool the
CVPixelBuffers used to share the output frames. This allows the plugin
to recycle the pixel buffers used by the plugin.
This change updates the virtual camera implementation on macOS to
utilize IOSurface to share the output feed with the virtual cameras.
By using IOSurface, we remove the need for copying the frames across
multiple buffers, since they can be shared across Mach connections using
zero-copy.
This change fixes an issue where the DAL plugin would not load due to
not supporting the architecture arm64e. We update the build
configuration to build a universal binary that includes arm64e as well.
See https://github.com/obsproject/obs-studio/issues/6285 for more
information regarding this issue.
Status output related to OBS configuration is prefixed with the string
"OBS" and added padding for enabled and disabled features. This padding
was not aligned between platforms.
By moving the padding and prefix decoration into its own function,
both elements are controlled in a single place. CMake scripts were
changed to use this new function `obs_status` instead of using CMake's
`message` function directly.
Hides the DLog and DLogFunc macros behind the -DDEBUG flag, causing the
logs to only appear in testing environments.
On production build, calls to these macros will result in nothing
happening.
Co-authored-by: lvsti <lvsti@users.noreply.github.com>
Co-authored-by: Sebastian Beckmann <beckmann.sebastian@outlook.de>
Co-authored-by: Stefan Huber <sh@signalwerk.ch>
Co-authored-by: Ryohei Ikegami <iofg2100@gmail.com>
Co-authored-by: Colin Dean <colin.dean@target.com>
Co-authored-by: Wolfgang Ladermann <extern.ladermann_wolfgang@allianz.de>
Co-authored-by: Simon Eves <simon.eves@omnisci.com>
Co-authored-by: Colin Nelson <colnnelson@google.com>
Co-authored-by: Yoshimasa Niwa <niw@niw.at>
Co-authored-by: Michael Karliner <mike@modern-industry.com>
Co-authored-by: Jason Grout <jgrout6@bloomberg.net>
Co-authored-by: Alfredo Inostroza <jadenguy@gmail.com>
Co-authored-by: Daniel Kennett <daniel@cascable.se>
Co-authored-by: Gary Ewan Park <gep13@gep13.co.uk>
Co-authored-by: José Carlos Cieni Júnior <cienijr@outlook.com>