Argus::CameraProvider behaves like a singleton

• Hardware Platform (Jetson / GPU): Jetson Orin Nano
• JetPack Version: JetPack5 (r35.5), JetPack 6.1 (r36.4.0)
• Issue Type( questions, new requirements, bugs): questions

nvargus entry point (Argus::CameraProvider) object to enumerate cameras seems to behave as a singleton, but this behavior does not appear to be documented.

Both in multi-process (with daemon) and single-process (without daemon) flavors of the library, an application cannot create more than one provider without encountering issues.

In particular:

Multi-process flavor

If using nvargus_socketclient library, creating a second provider results in the following errors:

(NvCameraUtils) Error InvalidState: Mutex already initialized (in Mutex.cpp, function initialize(), line 41)
(Argus) Error InvalidState:  (propagating from src/rpc/socket/client/ClientSocketManager.cpp, function open(), line 54)
(Argus) Error InvalidState:  (propagating from src/rpc/socket/client/SocketClientDispatch.cpp, function openSocketConnection(), line 263)
(Argus) Error InvalidState: Cannot create camera provider (in src/rpc/socket/client/SocketClientDispatch.cpp, function createCameraProvider(), line 107)

Single-process flavor

If using nvargus library, creating a second provider succeeds, but destroying it causes the underlying instance of any other provider to be destroyed as well, resulting in dangling pointers and segmentation fault.


As a consequence the Argus::CameraProvider must be used as a singleton.

This gist illustrates minimal repro case with build instructions.

What’s the reason for creating seconder CameraProvider?

Our application ended up in this state because it had two different components in charge of opening camera streams vs. just enumerating camera properties like serial numbers.

I can also see this happening if e.g. we had two cameras and manage them in such a way two completely independent instances of our classes open each camera.

Anyway, this can easily worked around by wrapping the CameraProvider in a singleton, however I think this should be enforced at Argus API level, rather than discovered by developers with a segfault?

You should use multiple session or multiple source in single session for opening multiple cameras.

Thanks

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.