Repository navigation
Use the CEF sandbox on macOS (obs-rust/obs-studio#1092) - #12
Merged
Merged
Conversation
On macOS the CEF sandbox works with CEF 7871 (measured for obs-rust/obs-studio#1092 on macOS 26.7.1, Apple Silicon: with the helpers sandboxed, a local page, HTTPS fetch, WebAudio and WebM video all work). Each helper loads libcef_sandbox.dylib from the framework's Libraries; a helper that cannot exits, and no browser source renders. The probe gets macOS facts (macos, sandbox_library) and a mode Seatbelt. sandbox-decision.cpp: with the library, Seatbelt and no warning; without it, off with the fallback warning and its own message (SandboxFallback.Message.NoSandboxLibrary). DecideSandbox() still treats the macOS probe like a Linux one, so 5 of the 6 macOS cases fail. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Each helper now sandboxes itself before the framework loads (CefScopedSandboxContext, as in CEF's sample helper), unless OBS passed --no-sandbox. OBS turns the sandbox on when the framework next to the helpers has Libraries/libcef_sandbox.dylib, where each helper loads it from: ProbeSandbox() on macOS checks <app>/Contents/Frameworks/Chromium Embedded Framework.framework, found from the executable's path. Without the library a sandboxed helper would exit and no browser source would render, so OBS runs without the sandbox then and shows the fallback warning (SandboxFallback.Message.NoSandboxLibrary). sandbox-decision.cpp: all cases pass. Real app on macOS 26.7.1, Apple Silicon, ad-hoc signed, with a page that needs HTTPS fetch, WebAudio and WebM recording and playback: with the library, "CEF sandbox on", all six helpers sandboxed, the page works; with the library moved out, the fallback warning, the helpers run without the sandbox, the page works. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
zackees
approved these changes
Oct 25, 2026
zackees
left a comment
Member
There was a problem hiding this comment.
Reviewed. The macOS helper code stays inside the existing __APPLE__ && !ENABLE_BROWSER_LEGACY block. CefScopedSandboxContext runs before LoadInHelper, as in CEF's sample helper, and --no-sandbox turns it off. The probe and the helper look in the same place (Frameworks/…/Libraries/libcef_sandbox.dylib). RED → GREEN adds 6 macOS decision, fallback and warning cases, and the fallback string is added to en-US.ini. The real-app check covers both the case with the library and the case without it. Linux behaviour is unchanged. LGTM.
MCPVOT
pushed a commit
to MCPVOT/obs-studio
that referenced
this pull request
Oct 25, 2026
…rust#2402) obs-rust/obs-browser#11: on macOS, do not hand BrowserInit() to the Qt main thread once its loop has stopped, so a first browser source created off the main thread while OBS quits no longer hangs it (obs-rust#2391). obs-rust/obs-browser#12: browser sources and panels use the CEF sandbox on macOS, with libcef_sandbox.dylib from the CEF framework; without it, the helpers run unsandboxed and OBS shows the fallback warning (obs-rust#1092). docs/features.md: the sandbox line covers Linux and macOS, the obs-rust#2387 line names the quit case. Fixes obs-rust#2391 Refs obs-rust#1092 Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Refs obs-rust/obs-studio#1092
What and why
On macOS the browser source ran without the CEF sandbox:
browser-sandboxhad no probe for macOS, sosettings.no_sandboxstayed true (#1092). Measured on macOS 26.7.1, Apple Silicon, with CEF 7871: with the helpers sandboxed, browser sources work, including HTTPS fetch, WebAudio, and WebM recording and playback.CefScopedSandboxContext, as in CEF's sample helper), unless OBS passed--no-sandbox.libcef_sandbox.dylibfrom the framework next to it (<app>/Contents/Frameworks/Chromium Embedded Framework.framework/Libraries/).ProbeSandbox()on macOS checks that file, with the framework found from the executable's path, so the probe and the helper agree. (dladdr()oncef_version_info, as on Linux, does not point into the framework on macOS.)Seatbelt, "CEF sandbox on". Without it a sandboxed helper would exit and no browser source would render, so OBS runs without the sandbox and shows the fallback warning (SandboxFallback.Message.NoSandboxLibrary, new string inen-US.ini).Linux is unchanged; Windows still has no probe (obs-rust/obs-studio#2379).
RED → GREEN
820ca85: the probe gets macOS facts (macos,sandbox_library) and the modeSeatbelt;tests/sandbox-decision.cppgets 6 macOS cases (decision, fallback, warning; with and without the library). 5 fail:DecideSandbox()treated the macOS probe like a Linux one.82cab3b: all 28 cases pass.libcef_sandbox.dylib: "CEF sandbox on: libcef_sandbox.dylib is in the CEF framework", all six helpers sandboxed (sandbox_check(): the GPU process, three utility processes, two renderers), the page green;AI note: Claude Code (Claude Opus 5.5) wrote the change, the tests and this text under the submitter's direction, and ran the tests above on the submitter's machine.