Skip to content

linux-v4l2: camera-busy warning: name every holder, Close it / Ignore / Always allow, detect later opens (follow-up of #799) #3724

Open

Description

@zackees

Feature, agreed with the maintainer. Follow-up of #799 / #800, which already detect EBUSY on a V4L2 camera, name the holder (plugins/linux-v4l2/v4l2-busy.c.h), emit source_device_busy and show an app-modal "Camera is in use" box with Force Camera (SIGTERM only).

What changes

A general camera-busy warning for v4l2_input, for any camera and any holder:

  1. Detection. EBUSY on open / VIDIOC_REQBUFS / VIDIOC_STREAMON (the existing signal), and another process opening the device while OBS holds it (inotify IN_OPEN on the device node, on a background thread, never the render or UI thread).
  2. Holders. Scan <proc_root>/<pid>/fd for the device, read comm/exe/cmdline for a display name and the PID, skip OBS's own PID. proc_root is caller supplied so tests use a fixture tree.
  3. Dialog naming the device and the holder(s), with:
    • Close it: SIGTERM, SIGKILL after a short grace if still alive, then the source retries.
    • Ignore: dismiss this occurrence.
    • Always allow: persist the app names in OBS's global (user) config; they never warn again.
      It waits for a click (no countdown, no automatic action), never stacks duplicates for the same device + holder, and re-warning is rate-limited.
  4. Window. A child of the OBS main window (transient parent), not application-modal, no WindowStaysOnTopHint/Tool. In the background it is shown without activating (WA_ShowWithoutActivating, QApplication::alert), never raised over the user's current app. No desktop notifications.
  5. Log line (blog) every time.

Layout

  • rust/obs-camera-busy: pure core (holder scan over a root, dedupe / rate limit / allowlist, texts, what an answer does), Tier 1 tests in the frontend's test category (obs-tests-gpu, as obs-fallback-warning); host calls (kill, inotify) in src/platform/; C ABI in src/ffi, linked through rust/obs-frontend.
  • Frontend: dialog + glue in C++/Qt, replacing OBSBasic::ShowDeviceBusy's blocking exec().
  • Plugin: announce when a source opens / closes its device, so the frontend knows what to watch.

Activity

  1. added
    enhancement
    on Nov 6, 2026
  2. zackees commented on Nov 6, 2026

    @zackees
    MemberAuthor

    /ready

  3. added
    ready
    on Nov 6, 2026
  4. zackees commented on Nov 6, 2026

    @zackees
    MemberAuthor

    Claiming: #3724 (camera-busy warning)

    1. RED: rust/obs-camera-busy with todo!() cores and its Tier 1 tests (holder scan over a fixture /proc, dedupe / rate limit / allowlist, texts, answers, C ABI) in obs-tests-gpu.
    2. GREEN: the core, src/platform/ (kill, liveness, inotify watcher thread), src/ffi, linked through rust/obs-frontend.
    3. Frontend: OBSCameraBusy dialog (child of the main window) + CameraBusy glue replacing the blocking ShowDeviceBusy; Qt test of the dialog's buttons, parent and window flags. Plugin: source_device_opened / source_device_closed announcements. Ledger line.

    One PR, draft today.

    Decisions:

    • SIGKILL. linux-v4l2: recover when the camera is held by another process (EBUSY): name the holder, offer to close it, auto-retry #799 said "never SIGKILL silently". The maintainer has now decided that Close it sends SIGTERM and, if the holder is still alive after a 2 s grace, SIGKILL. It is not silent: the button says it closes the app, and both signals are logged. The properties-panel Force Camera button (linux-v4l2: recover a camera another process holds (EBUSY): name it, Force Camera, auto-retry #800) keeps its SIGTERM-only behaviour; only the popup changes.
    • Same user only. Processes of another user are named but not signalled (the kill would fail with EPERM anyway); the dialog then offers only Ignore / Always allow.
    • Holder name. Basename of exe, else comm, else the basename of cmdline's first word, else ?. The allowlist matches that name exactly.
    • Rate limit. One dialog open per device + holder name at a time; after it is answered the same device + holder does not warn again for 60 s. Every occurrence is still logged, also the suppressed ones.
    • Allowlist storage. User config, [General] CameraBusyAllowlist, names separated by ;.
    • Retry after Close it. The source's existing busy check (linux-v4l2: recover a camera another process holds (EBUSY): name it, Force Camera, auto-retry #800, once a second) reopens the device when the holder is gone; the popup does not call force_camera (that would SIGTERM again).
    • Texts. The Rust core produces the holder list and the log line; the sentence around them is a translated string in en-US.ini, as every other frontend text is.
    • Policy exceptions (testing-policy.md): this is new code with no C original, so Tier 2 (unchanged C tests against a Rust port) and Tier 3 (differential against C) do not apply; existing test_v4l2_busy* C tests stay unchanged and must keep passing. No rust-exports.d / rust-hidden.d fragment: the crate links into the frontend through rust/obs-frontend, not into libobs, exactly like obs-fallback-warning and obs-gpu-status. Tests go into the existing obs-tests-gpu category binary (as obs-fallback-warning's do), so no new test executable.
  5. zackees commented on Nov 6, 2026

    @zackees
    MemberAuthor

    #3725 merged (ecf1816): rust/obs-camera-busy (holders, allowlist, dedupe/rate limit, Close it SIGTERM->SIGKILL, inotify watcher, C ABI), the OBSCameraBusy window parented to the main window, the CameraBusy glue and the linux-v4l2 opened/closed announcements. Left open (Refs, not Fixes): the real app has not been run against a genuinely busy camera on a KDE/Wayland session; the window's parent, type, non-modality and no-activation were verified on Qt's offscreen platform only. Closing this needs that one real run, with the observed log lines posted here.

  6. moved this from In progress to Ready in obs-rust Multiviewon Nov 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementready

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions