Skip to content

Warn when the CEF sandbox cannot work - #8

Merged
zackees merged 2 commits into
obs-rust:masterfrom
vpacher:feat/2218-sandbox-warning
Oct 25, 2026
Merged

zackees merged 2 commits into
obs-rust:masterfrom
vpacher:feat/2218-sandbox-warning

Conversation

@vpacher

@vpacher vpacher commented Oct 25, 2026 •

Copy link
Copy Markdown
Member

Refs obs-rust/obs-studio#1092, obs-rust/obs-studio#2218

Uses obs_frontend_warn_fallback() from obs-rust/obs-studio#2238 (merged as 4d7345283), so it builds against obs-studio master from that commit on.

What and why

When the CEF sandbox cannot work, the browser runs without it (#3). As decided on obs-rust/obs-studio#1092, the user is warned, not only the log. This uses the shared fallback warning of obs-rust/obs-studio#2218:

  • SandboxWarningFor(probe, decision, &warning) (pure, in browser-sandbox): warns only for the fallback, with id browser.sandbox, the title "Browser source without the sandbox", the message for the cause, and can_cancel = false (the browser has nothing to stop).
    • As root: "The Chromium sandbox cannot work because OBS runs as root. Browser sources run without the sandbox. To use it, run OBS as a normal user."
    • No user namespaces and no usable chrome-sandbox: what to allow or install instead.
  • UseCefSandbox() passes it to obs_frontend_warn_fallback(). OBS logs the error line (also on stderr) at once and shows the dialog with the 3-second countdown once the main window has loaded. The plugin's own "CEF sandbox off" error line goes, as the shared line replaces it. The info line (sandbox on, or off on a platform without a probe) stays.
  • Three strings in data/locale/en-US.ini, in the wording of docs/fallback-warning.md (obs-studio).

RED → GREEN

  • RED 27b064b: tests/sandbox-decision.cpp checks every probe case for the warning, and that both locale keys exist in en-US.ini (the runner passes the path). 4 of 7 warning cases fail against the stub.
  • GREEN 5a0bc56: all cases pass (uv run --no-project python tests/sandbox_decision.py --output-dir …, macOS and Linux).
  • Real app (Linux, Debian 13, CEF 8078, obs-studio with #2238, OBS as root on Xvfb): the log has [fallback] browser.sandbox: The Chromium sandbox cannot work because OBS runs as root. … once, also on stderr; the dialog shows the message, the countdown and "Accept anyway" (no Cancel), and accepts after 3 seconds; the browser source renders (the test page's green pixel). No new compiler warnings in obs-browser.

AI note: Claude Code (Claude Opus 5.5) wrote the code, the tests, the commit messages and this text under the submitter's direction, and ran the tests above on the submitter's machines.

vpacher and others added 2 commits October 25, 2026 09:41
When the browser runs without the CEF sandbox (the fallback of
obs-rust/obs-studio#1092), it is to warn through the shared fallback
warning (obs-rust/obs-studio#2218, obs_frontend_warn_fallback()), not
only log. SandboxWarningFor() says whether to warn, with the id
"browser.sandbox", the locale keys of the title and of the message for
the cause (as root, or no user namespaces and no usable chrome-sandbox),
and can_cancel false: the browser has nothing to stop.

sandbox-decision.cpp checks every probe case, and that both keys exist in
data/locale/en-US.ini (the runner passes its path). The stub never warns,
so the four fallback cases fail.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
SandboxWarningFor() warns only for the fallback: id "browser.sandbox",
title "Browser source without the sandbox", and the message for the
cause: as root, run OBS as a normal user; else allow unprivileged user
namespaces, or install chrome-sandbox setuid root. can_cancel is false.

UseCefSandbox() passes it to obs_frontend_warn_fallback()
(obs-rust/obs-studio#2218), which logs the error line (also on stderr)
and shows the dialog with the countdown once the main window has loaded.
The plugin's own "CEF sandbox off" error line goes, as the shared one
replaces it; the info line when the sandbox is on, or off on a platform
without a probe, stays.

Needs obs_frontend_warn_fallback() in obs-studio (obs-rust/obs-studio#2238).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@vpacher
vpacher marked this pull request as ready for review October 25, 2026 09:22

@zackees zackees left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Coordinator review: approved.

  • SandboxWarningFor is pure, warns only when SandboxFallback is true, and picks the message for the cause (root, or no namespaces and no usable helper). The test covers all 7 probe cases, including the ones that must not warn, and checks that both locale keys exist in en-US.ini.
  • can_cancel = false with a null callback fits: the browser continues either way. obs_frontend_warn_fallback copies the strings, so the obs_module_text pointers don't need to outlive the call, and it accepts calls from any thread, so it doesn't matter which thread initializes CEF.
  • The plugin's own error line is replaced by the shared [fallback] browser.sandbox: ... line, so the log keeps an error line on stderr. The info line for sandbox on stays.
  • Dependency: this needs obs-studio at or after 4d7345283 (#2238) for the new frontend export, as the description says. The obs-studio submodule bump should come after that commit, which it does on master.

@zackees
zackees merged commit 4583599 into obs-rust:master Oct 25, 2026
1 check passed
chriscoveries pushed a commit to chriscoveries/obsrust-fork that referenced this pull request Oct 25, 2026
…s) (obs-rust#2378)

Moves plugins/obs-browser from 7bab463c9 to 4583599fe, with:

- obs-rust/obs-browser#3: the CEF sandbox where it can work on Linux
  (obs-rust#1092)
- obs-rust/obs-browser#5: os_event_init results checked in module load
  and ExecuteOnBrowser
- obs-rust/obs-browser#6: WebAudio resumes after the audio service dies
  (obs-rust#2328)
- obs-rust/obs-browser#7: browser audio that arrives too late to mix is
  dropped (obs-rust#2335)
- obs-rust/obs-browser#8: the fallback warning when the sandbox can't
  work (obs-rust#2218)

One bump instead of three (obs-rust#2333, obs-rust#2351 and ours), as agreed on obs-rust#2351.
docs/features.md gets the two audio lines from obs-rust#2333 and obs-rust#2351 as they
are, a line for the sandbox, and the browser on the fallback warning
line, which obs-rust#2238 merged on 2026-10-25.

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
@vpacher
vpacher deleted the feat/2218-sandbox-warning branch October 25, 2026 12:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants