Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mac-virtualcam: Fix memory access issues for shared IOSurfaces #8044

Merged
merged 1 commit into from
Jan 16, 2023

Conversation

PatTheMav
Copy link
Member

Description

Fixes #8039.

Motivation and Context

The DAL plugin-based virtualcamera shares data between OBS and the plugin using an IOSurface. IOSurface locks are necessary to ensure race conditions between data generation (OBS side) and consumption (virtual camera side) and also that an IOSurface is not offloaded to GPU memory when it is indeed needed in CPU memory.

Also moves the invalidation of the NSMachPort for the frames to after the IOSurface data has been converted into a pixelbuffer and added to the frame queue of the virtual camera, as an early invalidation will cut off access to the pixel data shared with the DAL plugin.

How Has This Been Tested?

Tested on Intel-based iMac (late 2015) and Mac Studio (2022).

Types of changes

  • Bug fix (non-breaking change which fixes an issue)

Checklist:

  • My code has been run through clang-format.
  • I have read the contributing document.
  • My code is not on the master branch.
  • The code has been tested.
  • All commit messages are properly formatted and commits squashed where appropriate.
  • I have included updates to all appropriate documentation.

The DAL plugin-based virtualcamera shares data between OBS and the
plugin using an IOSurface. IOSurface locks are necessary to ensure
race conditions between data generation (OBS side) and consumption
(virtual camera side) and also that an IOSurface is not offloaded to
GPU memory when it is indeed needed in CPU memory.

Also moves the invalidation of the NSMachPort for the frames to after
the IOSurface data has been converted into a pixelbuffer and added to
the frame queue of the virtual camera, as an early invalidation will
cut off access to the pixel data shared with the DAL plugin.
@PatTheMav PatTheMav added Bug Fix Non-breaking change which fixes an issue macOS Affects macOS labels Jan 11, 2023
@gxalpha gxalpha added this to the OBS Studio 29.0 milestone Jan 11, 2023
@PatTheMav PatTheMav added the Seeking Testers Build artifacts on CI label Jan 11, 2023
@obsproject obsproject deleted a comment from Bella-Tim Jan 14, 2023
@RytoEX RytoEX merged commit 447adfb into obsproject:master Jan 16, 2023
@PatTheMav PatTheMav deleted the macos-virtualcam-fix branch February 21, 2023 21:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Fix Non-breaking change which fixes an issue macOS Affects macOS Seeking Testers Build artifacts on CI
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Virtual Cam on macOS shows a red screen instead of video (again, 29.0.0 regression)
3 participants