Skip to content

[CameraInterface] A reader starts the camera plugin when none is running - #1533

Closed
farbod-nv wants to merge 1 commit into
fm/camera_capture_m0_configfrom
fm/camera_capture_m0_autostart
Closed

farbod-nv wants to merge 1 commit into
fm/camera_capture_m0_configfrom
fm/camera_capture_m0_autostart

Conversation

@farbod-nv

Copy link
Copy Markdown
Contributor

Description

Eleventh pull request of the camera interface, stacked on #1532 (default endpoint and configuration file), whose branch is this one's base.

After #1532 a reader finds a running plugin without being told where it is. With this one it also works when no plugin is running: the reader starts it.

CameraReader reader = CameraReader::open("head");   // starts camera_plugin if nobody answers
  • Starting. When nothing answers on a default endpoint, the reader starts camera_plugin: the one next to the program, or on PATH, or the one named in PluginLocation::executable. It then waits until the plugin serves. A plugin behind an explicit socket path is never started, and start_if_absent = false turns this off.
  • The started plugin belongs to nobody. It is detached from the reader's process: it outlives the reader, serves any other reader that comes along, and leaves no child for the host program to reap. The launcher touches none of the host's signal handlers and, between fork and exec, makes system calls only, because the host may have threads holding locks at that moment.
  • It does not outstay its use. The reader passes --exit-when-idle=SECONDS (30 by default), a new plugin argument: the plugin exits once no reader has been connected for that long. A plugin started by hand, by a service or by the plugin manager is not given it and runs until it is told to stop.
  • Several readers at once. If two readers start a plugin at the same moment, one plugin gets the endpoint (the lock file from [CameraInterface] Add a message socket that carries file descriptors #1523 decides) and serves both; the other finds the endpoint taken and leaves.
  • Failures are reported, not waited for. No executable to start, an executable that cannot be started, and a plugin that starts but has no camera to serve each give an error that says which.
  • The plugin manager can start the plugin from the build tree. The manifest is copied next to the executable, which makes that directory a plugin directory.

Type of change

  • New feature (non-breaking change which adds functionality)

Testing

Three new cases in tests/cpp/plugins/camera/test_camera_plugin.cpp, all with real processes and their own runtime and configuration directories:

  • A reader starts the plugin when none is running: two readers open the group at the same moment with no plugin running; both get frames with every byte as expected, and one socket serves them. After both are gone the plugin exits by itself and its socket file disappears. With starting turned off, or an executable that does not exist, opening fails with a message that says so and nothing is started. With no camera configured, the plugin that was started is reported as having stopped before it served.
  • A plugin told to exit when idle leaves once its readers have: it stays for longer than its idle time while a reader is connected, then exits with code 0 and removes its socket file.
  • The plugin manager can start the camera plugin: found by name from the build tree, started with arguments, read from, and stopped when its handle goes away.

All 80 camera tests pass through CTest, and under AddressSanitizer with UBSan; the reader and plugin suites ran three times each under ThreadSanitizer with no reports. 12 repeated runs of the plugin suite without a failure, and no plugin process left behind.

Built through the repository's own build (BUILD_PLUGINS=ON) with the project warning set promoted to errors. Ubuntu 22.04 x86_64, GCC 11.4, Linux 6.8. clang-format-14 reports no changes; SKIP=check-copyright-year pre-commit run --all-files passes.

Checklist

  • I have read and understood the contribution guidelines
  • I have run the linter and formatter with SKIP=check-copyright-year pre-commit run --all-files
  • I have made corresponding changes to the documentation (the plugin's and the reader's READMEs)
  • I have added tests that prove my fix/feature works (or explained why not)
  • I have signed off all my commits (git commit -s) per the DCO

🤖 Generated with Claude Code

CameraReader::open on a default endpoint no longer fails when no plugin
answers: it starts camera_plugin (the one next to the program, on PATH, or
named in PluginLocation), waits for it, and reads. The plugin is started
detached, so it outlives the reader, serves any other reader that comes
along, and leaves nothing for the host program to reap.

A plugin started this way is passed --exit-when-idle, which makes it exit
once no reader has been connected for that long, so it does not outstay
its use. When several readers start a plugin at the same moment, one plugin
gets the endpoint and serves them all; the others find it taken and leave.
A plugin that starts but cannot serve is reported instead of waited for.

The plugin's manifest is now copied next to its executable, which makes the
build tree a directory the plugin manager can start the plugin from.

Co-Authored-By: Claude <noreply@anthropic.com>
Signed-off-by: Farbod Motlagh <fmotlagh@nvidia.com>
@coderabbitai

coderabbitai Bot commented Nov 14, 2026

Copy link
Copy Markdown
Contributor

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

Run configuration

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • Trigger review
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

@farbod-nv

Copy link
Copy Markdown
Contributor Author

Folded into #1530. The first milestone of the camera interface is now four pull requests instead of twelve: #1521, #1528, #1530 and #1534.

This branch was successfully deployed

1 active deployment
dev — 21787f74 Deployed Nov 14, 2026 by farbod-nv via publish-wheel #6958
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants