Repository navigation
linux-v4l2: camera-busy warning: Close it / Ignore / Always allow, every holder, later opens (#3724) - #3725
Merged
Conversation
…#3724) Tier 1 tests for the decision core of the camera-busy warning: holder scan over a fixture /proc tree, display names, the allowlist, dedupe and rate limit, what an answer does, Close it's SIGTERM -> SIGKILL sequence, the log lines, the inotify watcher and the C ABI. They run as a module of obs-tests-gpu, the frontend's Rust test category, like obs-fallback-warning's. RED: 39 of 40 fail on todo!(); the ffi module aborts the binary (a todo!() cannot unwind out of extern "C").
…3724) The core of the camera-busy warning. Holders come from the fd links of a /proc tree under a caller-supplied root. A holder's name is its exe's file name unless comm disagrees: comm is the exe name cut to 15 bytes, so when it is not a prefix the binary is multicall (NixOS's sleep is coreutils) or it renamed itself, and comm is what ps shows. Nix's .foo-wrapped is foo. One dialog per device and app at a time, then 60 s of quiet after an answer. An open that nobody holds 500 ms later (OBS reopening its own camera, a browser probing every /dev/video*) is not reported. Close it sends SIGTERM, then SIGKILL after 2 s, by the maintainer's decision on #3724 (#799 had said SIGTERM only; the properties-panel Force Camera button keeps that). A zombie counts as gone: an exited child holds no fd. The crate links into the frontend through obs-frontend, not libobs, so it needs no rust-exports.d/rust-hidden.d fragment and Tier 2 never builds it (local-gate.toml exclude). Its platform/mod.rs is a new crate's shared platform boundary (ci/shared-build-files.txt). 46 camera_busy tests pass in obs-tests-gpu.
…ements (#3724) OBSCameraBusy names the device and every holder and waits for a click: Close it, Ignore, Always allow. It is a child of the main window (its transient parent), window type exactly Qt::Dialog, non-modal, never on top. Two traps the Qt test caught: masking out Qt::Tool clears the Dialog type bits too (Tool is a type, not a flag), which made the window a child widget inside the main window; and QDialogButtonBox makes its first AcceptRole button the default on show, so Enter answered Always allow. Always allow is an ActionRole button for that reason, and no button is auto-default. CameraBusy scans /proc off the UI thread, asks rust/obs-camera-busy whether to show, logs every warning and answer, and runs Close it on a worker thread. In the background the window shows without activating and the taskbar entry is alerted; while the main window is hidden or minimized the warning waits for it. The C rollback build keeps #800's popup. linux-v4l2 announces source_device_opened/closed so the frontend can watch the node for other programs opening it while OBS holds it. The existing v4l2 C tests are unchanged; an undeclared signal is a no-op there.
zackees
force-pushed
the
fix/3724-camera-busy
branch
from
November 6, 2026 02:24
aa87deb to
ad674f0
Compare
…_busy fixture tests on Linux only (#3724) The v4l2 C tests create the source with no obs_source_t and libobs not started, and obs_get_signal_handler() dereferences the unstarted core: every test_v4l2_* that opens the fake camera segfaulted (and asan then reported the leaks of the dead process). Check the source first, as there is nobody to tell without one. The /proc fixture tests expect can_close, which needs the owner uid that only the Linux platform reads; macOS has no V4L2 and reported false.
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 #3724 (follow-up of #799 / #800).
A general camera-busy warning for the V4L2 camera source, for any camera and any app holding it.
What it does
source_device_busysignal from linux-v4l2: recover a camera another process holds (EBUSY): name it, Force Camera, auto-retry #800), and another program opening the device while OBS holds it: the plugin now announcessource_device_opened/source_device_closed, and the frontend puts an inotifyIN_OPENwatch on the node, on its own thread. It looks who holds the device 500 ms after an open, so OBS's own reopen and programs that only probe/dev/video*are not reported./proc/<pid>/fd(the root is a parameter, so tests use fixture trees). The name is the exe's file name, orcommwhen they disagree (multicall binaries such as NixOS's coreutilssleep, or apps that renamed themselves); Nix's.foo-wrappedshows asfoo.[General] CameraBusyAllowlist, and never warn again.Qt::Dialog, non-modal, noWindowStaysOnTopHint, notTool. While OBS is in the background it shows withWA_ShowWithoutActivatingandQApplication::alert, so it never takes the focus from the user's current app. While the main window is hidden or minimized the warning waits and shows when the window comes back. No desktop notifications.[camera-busy]blog line for every warning (including the suppressed ones, with the reason), every answer, and every Close it result.Layout
rust/obs-camera-busy: the pure core (holder scan, names, allowlist, dedupe / rate limit, what an answer does, the SIGTERM→SIGKILL sequence over aSignalstrait, texts, log lines).src/platform/holds kill(2), getuid(2) and the inotify/poll watcher thread.src/ffiis the C ABI (frontend/utility/obs-camera-busy.h), linked throughrust/obs-frontend.OBSCameraBusy(the window, its own unity group so the Qt test builds it alone) andCameraBusy(the glue).OBSBasicroutessource_device_busyto it and saves the allowlist.v4l2-input.c.hannounces opened / closed.Commits
todo!()stubs. 39 of 40 fail; the ffi module aborts the binary (atodo!()cannot unwind out ofextern "C").camera_busy::tests inobs-tests-gpupass.test_camera_busy_dialogwas run locally (built by hand against Qt 6.11.1, offscreen platform) before the fixes, and it caught two real bugs:~Qt::Toolalso cleared theDialog/Windowtype bits, which made the dialog a plain child widget inside the main window (isWindow()false).QDialogButtonBoxmade the AcceptRole "Always allow" button the default, so Enter answered it.After the fixes, 10 of 10 pass. They check the parent and
transientParent, the window type and flags, non-modality,WA_ShowWithoutActivating, that nothing answers without a click, and exactly one answer per way out.Tiers and policy
New code with no C original: Tier 2 (unchanged C tests against a Rust port) and Tier 3 (differential) do not apply, as recorded under Decisions: on #3724. The existing
test_v4l2_busy*C tests are unchanged. There is norust-exports.d/rust-hidden.dfragment because the crate links into the frontend, not libobs, like obs-fallback-warning. The crate is excluded from Tier 2 proof inputs (local-gate.toml), and itsplatform/mod.rsis listed inci/shared-build-files.txtas a new crate's boundary. The tests are modules of the existingobs-tests-gpubinary, so there is no new test executable.Test cost: 46 new Rust tests; the whole module runs in 0.47 s (longest is the real-process SIGKILL test, about 0.4 s). Peak RSS is 5.5 MB over 5 runs. There are no proptests. Own threads: the watcher tests start one watcher thread each. The close and watch tests spawn one short
sh/sleepchild each, which is killed and reaped.Not verified
Refs #3724, notFixes.