Argus hangs with too many consumers

Hello,
I’m trying to build a system with where each CaptureSession will have multiple consumers as shown in the multiStream sample. In this sample, iCaptureSession->createOutputStream() creates several OutputStream that are passed to different FrameConsumers, one for JPEG encoding and another for preview.

In my application, I have a need for more types of consumers, for example, one to encode and save, one to stream, one to preview, one for additional CV processing, one for DL etc. If I create multiple consumers the application will hang during acquireFrame() in the FrameConsumer.
I’ve reproduced a minimal sample by taking the yuvJPEG sample and spawning multiple FrameConsumer threads. 6 consumers work with minimal latency and 7 consumers will completely hang the system. I’ve attached the snippet if anyone wants to reproduce. This is also with a single camera, I’m worried with additional cameras the number of outputstreams will overwhelm argus even faster.

What is the “intended” way to handle my situation? Based on the samples I should be able to spawn multiple consumers per CaptureSession. I can create a single consumer that will push to my own application queue, however that defeats the purpose of the zero-copy EGLStreams. NvMedia provides a way to handle multisend over an eglstream. Is there any way to do that here?

main.cpp (19.7 KB)

Have you update to latest release J4.5 to verify it?

Thanks

On the latest JetPack 4.5.1

I try it on reference sensor ov5693 without problem.
Not sure if it relative with the output resolution.

status 6; 0 missed
0 acquire Frame: 0.019961s
status 8; 0 missed
CONSUMER: Done.
6 acquire Frame: 0.100077s
status 6; 0 missed
1 acquire Frame: 0.020718s
status 8; 0 missed
CONSUMER: Done.
2 acquire Frame: 0.020870s
status 8; 0 missed
CONSUMER: Done.
3 acquire Frame: 0.020495s
status 8; 0 missed
CONSUMER: Done.
4 acquire Frame: 0.019532s
status 8; 0 missed
CONSUMER: Done.
5 acquire Frame: 0.018582s
status 8; 0 missed
CONSUMER: Done.
6 acquire Frame: 0.002240s
status 8; 0 missed
CONSUMER: Done.
PRODUCER: Done -- exiting.

Pardon for making the failure case unclear, I should have changed the printfs before uploading the snippet.
If the consumer was working, it would print the raw bytes as in the original sample as such:

5 acquire Frame: 0.022014s
ever here?
CONSUMER: Acquired Frame: 93, time 24560150309000
4 acquire Frame: 0.023473s
ever here?
CONSUMER: Acquired Frame: 93, time 24560150478000
CONSUMER: 	Sensor Timestamp: 24560108501000, LUX: 206.092545
nbuffers2
3 acquire Frame: 0.026416s
ever here?
CONSUMER: Acquired Frame: 93, time 24560150260000
CONSUMER: 	Sensor Timestamp: 24560108501000, LUX: 206.092545
nbuffers2
Get Frame: 0.002522s
CONSUMER: 	IImage(2D): buffer 0 (1640x1232, 1664 stride), 79 7b 7e 80 80 80 7a 7b 7f 7f 80 7d
CONSUMER: 	Sensor Timestamp: 24560108501000, LUX: 206.092545
nbuffers2
Get Frame: 0.000740s
CONSUMER: 	IImage(2D): buffer 1 (820x616, 1664 stride), 9d 85 9d 85 9c 84 9d 84 9e 83 9d 84
Get Frame: 0.003732s
CONSUMER: 	IImage(2D): buffer 0 (1640x1232, 1664 stride), 79 7b 7e 80 80 80 7a 7b 7f 7f 80 7d
Get Frame: 0.000978s
CONSUMER: 	IImage(2D): buffer 1 (820x616, 1664 stride), 9d 85 9d 85 9c 84 9d 84 9e 83 9d 84
Get Frame: 0.005106s
CONSUMER: 	IImage(2D): buffer 0 (1640x1232, 1664 stride), 79 7b 7e 80 80 80 7a 7b 7f 7f 80 7d

You can switch between the working/failing versions by toggling the flag up top #define ENABLE_THREAD_6 {0,1}

Your current output will only print if acquireFrame() will not return a frame. Without the status and timeout arguments the program will hang.
printf(“status %d; %d missed\n”, status, missedctr);
Status 6 == timeout, until the producer disconnects with status 8 == disconnected.

Hi tfs96h3
For this special case I would suggest usning createNvBuffer() for your case. You can reference to 09_camera_jpeg_capture

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