Skip to content

frontend: Shared fallback warning with a countdown (obs_frontend_warn_fallback) - #2238

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

zackees merged 17 commits into
obs-rust:masterfrom
vpacher:feat/2218-fallback-warning

Conversation

@vpacher

@vpacher vpacher commented Oct 24, 2026 •

Copy link
Copy Markdown
Member

Fixes #2218

The shared warning for fallbacks that lower security, as decided on #1092 (#1092 (comment)): OBS logs the fallback at error level (also on stderr), and warns the user with a 3-second countdown that accepts "Accept anyway" by itself, with "This may become an error in a future version of OBS." Plugins call obs_frontend_warn_fallback(). The callers follow in their own PRs: obs-browser (sandbox fallback, #1092) and the RTMPS fallback (#2205).

What changed

  • Rust core rust/obs-fallback-warning: show or accept (a visible main window, once per id per session), what each end means (accepted(end, can_cancel)), the countdown, the log line, and the C ABI.
  • Frontend staticlib: obs-gpu-status-frontend is renamed rust/obs-frontend, the frontend's one staticlib with both C ABIs. It is built whenever cargo is available (OBS_FRONTEND_RUST). Without cargo (the OBS_LIBOBS_BACKEND=C rollback) the frontend configures without it, and fallback warnings only log and accept.
  • Dialog frontend/dialogs/OBSFallbackWarning: the caller's title and message, the future-error sentence, a progress bar, "Accept anyway" and, when the caller can stop, "Cancel" as the default button. Not modal. It takes all texts from its caller, so it builds without the frontend (own unity group).
  • Queue frontend/utility/FallbackWarning: logs at once on any thread; then, on the UI thread and never inside the call, shows the dialog or accepts, and calls the caller back once. Warnings wait for the main window, one dialog shows at a time, and at exit the open dialog closes and the rest accept.
  • Modal dialogs: a warning does not show while another modal dialog is open, and its countdown pauses when one opens over it. The live run below found this: OBS queues the first-run wizard right after the main window has loaded, and a warning behind it accepted unseen.
  • API obs_frontend_warn_fallback(id, title, message, can_cancel, cb, param) in obs-frontend-api.h. Without the OBS frontend (another host) it logs and calls cb(param, true) inside the call.
  • OBSBasic hands itself and the translated texts to the queue after OBS_FRONTEND_EVENT_FINISHED_LOADING, and answers every warning in closeWindow() before the scripts shut down and the scene data is cleared.
  • Docs: docs/fallback-warning.md (rules, standard wording, usage, code map), the API reference, and the features ledger. New strings: FallbackWarning.AcceptAnyway, FallbackWarning.FutureError.

RED → GREEN

Part RED GREEN Test
Rust core c9f5d00 (19 of 24 fail) 75e0c51 obs-tests-gpu: 171 of 171
Dialog 5338a06 (8 of 8 fail) 04ae04e test_fallback_warning_dialog
Queue 1da1a52 (8 of 8 fail) ed7d262 test_fallback_warning_queue (real Rust staticlib, own blog())
API, no frontend c113d57 (2 of 2 fail) 0cab603 test_frontend_warn_fallback
Wait for a modal dialog 4cf8d38 (1 fails) b5add4d test_fallback_warning_queue
Countdown pauses under a modal dialog 0558c89 (1 fails) 41a5471 test_fallback_warning_dialog
  • Linux (Debian 13, Qt 6.8.2, offscreen, ASan + UBSan): dialog 9 of 9, queue 9 of 9, API 2 of 2; 10 of 10 reruns of each Qt test. The queue test also passes 9 of 9 in a rollback build without cargo (no Rust symbols linked). The full obs-studio target builds without new warnings.
  • clang-format, gersemi, ci/test_build_groups.py, ci/platform_ifdef_ratchet.py, the cmocka and Tier 2 input checks, clippy and rustfmt pass. 075262d1f keeps the crate name out of the test CMake, so Tier 2 still does not build it (ci/test_tier2_proof_inputs.py).
  • Real app: the installed build on Linux (Xvfb, own config dir) with a probe plugin that warns from obs_module_load(), from a plugin thread, and again with the same id. All three log lines come at once, at error level. The first-run wizard opens over the first dialog: nothing is answered while it is open. After Escape closes it, dialog 1 comes to the front, counts down and accepts. On dialog 2 Return cancels it (Cancel is the default button), so the caller gets accepted=0. The same id again accepts without a dialog. Every answer runs on the UI thread. The browser sandbox run follows with the obs-browser caller.

Checklist

  • Base is master
  • I claimed the issue, or no one else has an open PR for it
  • Characterization test (if the unit had none), then RED, then GREEN commits: new code, RED then GREEN for each part
  • User-visible change: line in docs/features.md (Scenes and UI, pending merge)
  • (Optional) Local gate passed and the pushed head is stamped; otherwise PR CI runs the full suite
  • Warning or flag changes (-W..., ratchets): none
  • Intentional differences from C listed in the parity test header and rust/README.md (ports): not a port; rust/README.md lists the crate

Notes:

  • macOS and Windows: the Qt tests are Linux only, like test_properties_dialog_refresh; PR CI builds the frontend on both.
  • The whole ci/test_*.py suite on macOS fails the same 13 tests as master (environment), and no new ones.

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 6 commits October 25, 2026 08:42
…#2218)

Add rust/obs-fallback-warning with its safe API as stubs, the C ABI shim
the frontend will call (types only, it delegates), and the tests:

- show: the first warning with a visible main window shows the dialog;
  the same id shows it once per session; another id shows its own; with
  no visible window it accepts now and is not remembered; an empty id is
  never remembered.
- end: the countdown and "Accept anyway" accept; Cancel and Close stop a
  caller that can stop, and accept when there is nothing to stop.
- progress: 3 s, 0 to 100, and 100 after the end.
- log line: "[fallback] <id>: <message> This may become an error in a
  future version of OBS."
- ffi: the same through the C ABI, with null strings.

The tests run in obs-gpu-status's obs-tests-gpu (one test executable per
category, ci/test_binary_cap.py; both crates are the frontend's Rust).
Tier 2 does not build the crate, so local-gate.toml drops it from the
tier2-linux inputs, as it does obs-gpu-status (ci/test_tier2_proof_inputs.py).

19 of 24 fail against the stubs.

Refs obs-rust#2218

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The safe core of the warning that the maintainer decided on obs-rust#1092 for
fallbacks that lower security:

- Session::begin: a dialog only with a visible main window, once per id
  per session; no window means log only and accept, and is not
  remembered; an empty id is never remembered.
- accepted: the countdown and "Accept anyway" accept; Cancel and Close
  stop a caller that can stop, and accept otherwise.
- progress_percent: 0 to 100 over COUNTDOWN_MS (3 s), then 100.
- log_line: "[fallback] <id>: <message> " + FUTURE_ERROR.

obs-tests-gpu: 171 of 171 pass, with the 24 fallback-warning tests.

Refs obs-rust#2218

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The frontend's one Rust staticlib gets a general name, as decided on
obs-rust#2218: two staticlibs in one binary would duplicate the Rust std symbols,
so later frontend crates (first obs-fallback-warning) join this one. Only
the name changes; the GPU status light builds and behaves as before (still
with ENABLE_GPU_STATUS, still OFF in the Flatpak).

The crate directory, its package and library name (libobs_frontend.a),
frontend/cmake/feature-gpu-status.cmake, ci.toml, local-gate.toml,
ci/test_rust_cargo_build_order.py, rust/obs-build, rust/README.md and the
docs follow. naming.md lists the kind "Frontend staticlib: obs-frontend".
The CI evidence records in docs/ci-evidence/ keep the old name.

Refs obs-rust#2218

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…#2218)

As decided on obs-rust#2218, the frontend's Rust staticlib no longer depends on
the GPU light:

- frontend/cmake/frontend-rust.cmake imports and links rust/obs-frontend
  whenever cargo is available, and defines OBS_FRONTEND_RUST. Without
  cargo (the OBS_LIBOBS_BACKEND=C rollback build) it configures without
  it and says so.
- feature-gpu-status.cmake now only switches the light: ENABLE_GPU_STATUS
  and the staticlib, as before. The Flatpak still sets it OFF.
- obs-frontend re-exports obs-fallback-warning's C ABI next to
  obs-gpu-status's.

Refs obs-rust#2218

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…st#2218)

The window of the shared fallback warning: the caller's texts, a
countdown that accepts by itself, "Accept anyway" and, when the caller
can stop, "Cancel". It takes every text from its caller, so it builds
without the frontend, in its own unity group.

test_fallback_warning_dialog builds it on Qt's offscreen platform and
checks that the countdown, both buttons, Escape and the window close
each end the dialog exactly once, with the End value of the C ABI of
rust/obs-fallback-warning, and that the window then deletes itself.

The window does nothing yet, so the tests fail.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
)

The window shows the caller's title, message and future-error sentence,
a progress bar for the countdown, "Accept anyway" and, with a cancel
text, "Cancel" as the default button (the safe choice; the countdown
accepts anyway). It is not modal and deletes itself on close.

Every way out (countdown, either button, Escape, window close) goes
through one finish() that reports only the first end, and closeEvent()
does not call QDialog::closeEvent(), which would call reject() and keep
the visible window open.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@vpacher
vpacher force-pushed the feat/2218-fallback-warning branch from 530f3cd to 04ae04e Compare October 25, 2026 07:51
vpacher and others added 11 commits October 25, 2026 08:55
The glue between callers of the shared fallback warning and its window,
with frontend/utility/obs-fallback-warning.h, the C ABI of
rust/obs-fallback-warning. Its own unity group; built always, and with
the C header when the frontend's Rust is built.

FallbackWarning::Warn() runs on any thread and logs the warning at error
level at once. Then, on the UI thread and never inside the call, it
shows OBSFallbackWarning or accepts, as the Rust session decides, and
calls the caller back once. Warnings wait until the main window hands
over itself and the translated texts (SetMainWindow), so the glue does
not use App() or OBSBasic. One dialog shows at a time. SetMainWindow
(nullptr) at shutdown closes the open dialog and accepts the rest.
Without the frontend's Rust it only logs and accepts.

test_fallback_warning_queue builds the glue and the window with the real
Rust staticlib when it is built (else it checks the rollback path), with
its own blog() to check the log line.

The glue does nothing yet, so the tests fail.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Warn() logs the line from rust/obs-fallback-warning (the same line in
C++ on the rollback build) at error level, then queues the warning to the
UI thread. The queue runs once the main window is set, until a warning
shows a dialog: the Rust session decides from the id and whether the
main window is visible. The dialog's end goes through the Rust
accepted() to the caller, and the next warning runs after it closed. A
dialog deleted without an end (its main window went away first) answers
as closed. SetMainWindow(nullptr) closes the open dialog and accepts the
rest. Without the frontend's Rust every warning accepts.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…bs-rust#2218)

obs_frontend_warn_fallback(id, title, message, can_cancel, cb, param) for
plugins that fall back to a less safe mode: the browser source without
its sandbox (obs-rust#1092), RTMPS to RTMP (obs-rust#2205). The caller translates title
and message. OBS logs at error level, warns with the countdown, and
calls cb once on the UI thread with whether to continue in the fallback
mode. Declared in obs-frontend-api.h, a new method of
obs_frontend_callbacks, and stubs in the API library and OBSStudioAPI.

test_frontend_warn_fallback: with no frontend (no callbacks) the API
library logs the line at error level and accepts at once, inside the
call, without the "no callbacks" error.

The stubs do nothing yet, so the test fails.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…-rust#2218)

With the OBS frontend, OBSStudioAPI hands the warning to
FallbackWarning::Warn(). Without a frontend (no callbacks) the API library
logs the line of rust/obs-fallback-warning at error level and accepts at
once, inside the call: there is nobody to warn and no UI thread to wait
for. It does not log the "no callbacks" error, as this is not a mistake
of the caller.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
obs-rust#2218)

OBSBasic hands itself and the translated texts to FallbackWarning once it
has loaded, right after OBS_FRONTEND_EVENT_FINISHED_LOADING, so warnings
from plugins that loaded with the scene collection show then. At exit,
before the scripts shut down and the scene data is cleared, it answers
every warning, also the queued ones, while their callers still exist.

New strings: FallbackWarning.AcceptAnyway and FallbackWarning.FutureError
(Cancel is the existing string).

docs/fallback-warning.md gives the rules for every fallback (decision on
obs-rust#1092) and how a plugin uses obs_frontend_warn_fallback(). The API
reference and the features ledger have their entries.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
obs-rust#2218)

ci/test_tier2_proof_inputs.py finds the crates Tier 2 builds by their
names in test/cmocka's CMake files, so the comment that named
rust/obs-fallback-warning made it a Tier 2 root, which it is not (Tier 2
builds without the frontend). Say "the C ABI" instead.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…st#2218)

A live run showed it: OBS's first-run wizard opens right after the main
window has loaded, so a warning that runs then shows behind the wizard,
takes no input while it is open, and accepts unseen when the countdown
ends.

waits_while_another_dialog_is_modal: with a modal dialog open, a warning
shows nothing and answers nobody; after it closes, the warning shows (it
was not yet counted as shown) and Cancel stops the caller. Without the
frontend's Rust it accepts as before.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
)

While another modal dialog is open over the visible main window (the
first-run wizard opens right after the main window has loaded), the
queue does not run: it looks again every 250 ms. It looks before the
Rust session counts the warning as shown, so the warning still shows
once the dialog has closed. With a hidden main window, at shutdown and
without the frontend's Rust, warnings accept as before.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…log (obs-rust#2218)

The live run showed the second half: OBS queues the first-run wizard
right after the main window has loaded, so a warning that started just
before it is covered by it, takes no input, and accepts unseen when the
countdown ends. Waiting before a warning shows does not cover a modal
dialog that opens later.

countdown_pauses_while_another_dialog_is_modal: while another modal
dialog is open the countdown does not move and the warning does not end;
after it closes the countdown goes on and accepts.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…bs-rust#2218)

Each tick adds the time since the last one only while no other modal
dialog is active; under one the countdown pauses. When that dialog has
closed, the warning comes to the front and counts on. So a modal dialog
that opens after the warning (the first-run wizard, queued right after
the main window has loaded) no longer lets it accept unseen.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The policy doc gets the standard words that obs-rust#2218 asks for: the title
says what runs without what, the message says what failed, what OBS does
instead and what the user can do, "sandbox" and "unencrypted" as terms,
"Accept anyway" and "Cancel" as buttons, and the id format. New
fallbacks use the helper instead of their own dialogs.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@vpacher
vpacher marked this pull request as ready for review October 25, 2026 08:53
@vpacher
vpacher requested a review from zackees as a code owner October 25, 2026 08:53
@vpacher vpacher changed the title rust: obs-fallback-warning, the core of the shared fallback warning frontend: Shared fallback warning with a countdown (obs_frontend_warn_fallback) Oct 25, 2026

@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.

Checked:

  • API: obs_frontend_warn_fallback is a new additive export in obs-frontend-api.h (decided on #1092), and no existing declaration changes. The no-frontend path logs the same line and accepts, so other hosts keep working.
  • Threading: Warn() copies the strings, logs on the calling thread and hands the request to the UI thread through invokeMethod(..., QueuedConnection). All queue state is UI-thread only. Every way out of the dialog ends in finish(), which reports only the first end, and the destroyed handler covers a dialog that dies without one. So cb runs exactly once per warning that reaches the queue.
  • Modal handling: the pump defers while another modal dialog is up, and tick() pauses the countdown under one. That's the first-run-wizard case the live run found.
  • Shutdown: SetMainWindow(nullptr) plus sendPostedEvents in closeWindow() answers everything while the callers still exist.
  • Rust core: the C ABI only converts types, null strings become empty, and the log line strips NULs. The crate is named obs-<area>, the features ledger has a line, and there are Tier 1 tests plus the cmocka queue, dialog and API tests.

Nits (non-blocking):

  1. docs/fallback-warning.md says cb is "never inside the call", but without the OBS frontend obs_frontend_warn_fallback calls it inside the call, as the PR body and the rst say. One sentence would align them.
  2. A Warn() that arrives after closeWindow() has flushed the posted events (for example from a source's destroy during shutdown) is queued to an event loop that no longer runs, so its cb never fires. Callers that free param in cb would leak, not crash. You could accept at once when the queue has shut down, or document it.

Merged via the queue into obs-rust:master with commit 4d73452 Oct 25, 2026
37 checks passed
zackees pushed a commit to obs-rust/obs-browser that referenced this pull request Oct 25, 2026
* test: RED warning when the CEF sandbox cannot work

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>

* feat: warn when the CEF sandbox cannot work

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>

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
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>
@obs-rust-project-manager obs-rust-project-manager Bot moved this from In progress to Done in obs-rust Multiview Oct 25, 2026
@vpacher
vpacher deleted the feat/2218-fallback-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.

frontend: Shared warning with an "Accept anyway" countdown for fallbacks that lower security

2 participants