<html><head><meta http-equiv="Content-Type" content="text/html; charset=us-ascii"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class="">Hi all!<div class=""><br class=""></div><div class="">We are developing a streaming application on Nvidia Jetson Nano platform, where we use GStreamer pipelines for part of the processing. We experienced a very strange behaviour when running the pipeline as a systemd service, when we try to stop the service the pipeline is stopped but it does not cleans up after itself which will result an error in the nvargus-daemon. We have multiple pipelines running simultaneously so a fail in the nvargus-daemon will cause errors in all of the pipelines.</div><div class=""><br class=""></div><div class="">Strange thing is that if we start the pipeline from a terminal session and hit CTRL-C or kill the process from and other session using 'kill -SIGINT <pid>' the pipeline cleans up after itself properly and I can start and stop it anytime without issues.</div><div class=""><br class=""></div><div class="">We have this pipeline:</div><div class=""><br class=""></div><blockquote style="margin: 0 0 0 40px; border: none; padding: 0px;" class=""><div class="">gst-launch-1.0 -e\</div><div class=""><div class=""> nvarguscamerasrc sensor-id="0" sensor-mode=0 gainrange="1 16" ispdigitalgainrange="1 1" name="camera_pipeline_overrides_0"\</div></div><div class=""><div class=""> ! "video/x-raw(memory:NVMM), width=(int)1920, height=(int)1080, format=(string)NV12, framerate=(fraction)30/1"\</div></div><div class=""><div class=""> ! nvvidconv ! nvivafilter cuda-process=true customer-lib-name="libdcd_overlay_1080p.so" ! 'video/x-raw(memory:NVMM), format=(string)NV12'\</div></div><div class=""><div class=""> ! nvvidconv ! nvv4l2vp8enc bitrate="8000000" control-rate=1 ! rtpvp8pay mtu=1400\</div></div><div class=""><div class=""> ! udpsink auto-multicast=true clients="127.0.0.1:56000,127.0.0.1:56001"</div></div></blockquote><div class=""><br class=""></div><div class="">But I was able to reproduce the issue with much more simple setup:</div><div class=""><br class=""></div><div class="">service definition:</div><blockquote style="margin: 0 0 0 40px; border: none; padding: 0px;" class=""><div class=""><div class="">$ cat /etc/systemd/system/dcd_camerasource_0.service</div></div><div class=""><div class="">[Unit]</div></div><div class=""><div class="">Description=Dual Channel Dashcam Camera Source</div></div><div class=""><div class="">After=network.target syslog.target dcd.service dcd_gps.service dcd_radar.service nvargus-daemon.service</div></div><div class=""><div class="">StartLimitIntervalSec=5</div></div><div class=""><div class=""><br class=""></div></div><div class=""><div class="">[Service]</div></div><div class=""><div class="">Type=simple</div></div><div class=""><div class="">Restart=always</div></div><div class=""><div class="">RestartSec=5</div></div><div class=""><div class="">User=dcd</div></div><div class=""><div class="">Group=dcd</div></div><div class=""><div class="">WorkingDirectory=/opt/dcd</div></div><div class=""><div class="">ExecStart=/bin/bash /opt/dcd/bin/dcd_camerasource.sh 0</div></div><div class=""><div class="">ExecStop=/bin/kill -s SIGINT -$MAINPID </div></div><div class=""><div class="">TimeoutStopSec=3</div></div><div class=""><div class=""><br class=""></div></div><div class=""><div class="">[Install]</div></div><div class=""><div class="">WantedBy=multi-user.target</div></div></blockquote><div class=""><br class=""></div>wrapper script for the pipeline:<blockquote style="margin: 0 0 0 40px; border: none; padding: 0px;" class=""><div class="">$ cat /opt/dcd/bin/dcd_camerasource.sh</div><div class="">#!/bin/bash</div><div class=""><div class=""><br class=""></div></div><div class=""><div class="">gst-launch-1.0 nvarguscamerasrc sensor-id="$1" sensor-mode=0 ! fakesink</div></div><div class=""><br class=""></div></blockquote>which can reproduce the issue. If I start the script itself I can start and stop it as many times I wish and the pipeline cleans up after itself. But if I use:<blockquote style="margin: 0 0 0 40px; border: none; padding: 0px;" class=""><div class="">systemctl start dcd_camerasource_0</div><div class="">systemctl stop dcd_camerasource_0</div></blockquote><div class=""><br class=""></div><div class="">Then I get similar errors:</div><blockquote style="margin: 0 0 0 40px; border: none; padding: 0px;" class=""><div class="">Jan 28 16:07:30 dcd-398f9dee nvargus-daemon[4998]: === gst-launch-1.0[6785]: Connection closed (7F77AB11D0)=== gst-launch-1.0[6785]: WARNING: CameraProvider was not destroyed before client connection terminated.=== gst-launch-1.0[6785]: The client may have abnormally terminated. Destroying CameraProvider...=== gst-launch-1.0[6785]: CameraProvider destroyed (0x7f70b5c4c0)=== gst-launch-1.0[6785]: WARNING: Cleaning up 1 outstanding requests...=== gst-launch-1.0[6785]: WARNING: Cleaning up 1 outstanding streams...SCF: Error InvalidState: 5 buffers still pending during EGLStreamProducer destruction (propagating from src/services/gl/EGLStreamProducer.cpp, function freeBuffers(), line 306 )</div><div class="">Jan 28 16:07:30 dcd-398f9dee nvargus-daemon[4998]: SCF: Error InvalidState: (propagating from src/services/gl/EGLStreamProducer.cpp, function ~EGLStreamProducer(), line 50)</div><div class="">Jan 28 16:07:30 dcd-398f9dee nvargus-daemon[4998]: === gst-launch-1.0[6785]: WARNING: Cleaning up 1 outstanding stream settings...=== gst-launch-1.0[6785]: WARNING: Cleaning up 1 outstanding sessions...(NvCameraUtils) Error InvalidState: Mutex not initialized (/dvs/git/dirty/git-master_linux/camera/core_scf/src/services/gl/EGLStreamProducer.cpp:498) (in Mutex.cpp, function lock(), line 79)</div><div class="">Jan 28 16:07:30 dcd-398f9dee nvargus-daemon[4998]: SCF: Error BadParameter: Buffer is not pending (in src/services/gl/EGLStreamProducer.cpp, function presentBufferInternal(), line 502)</div><div class="">Jan 28 16:07:30 dcd-398f9dee nvargus-daemon[4998]: (NvCameraUtils) Error InvalidState: Mutex has not been initialized (in Mutex.cpp, function unlock(), line 88)</div><div class="">Jan 28 16:07:30 dcd-398f9dee nvargus-daemon[4998]: SCF: Error BadParameter: (propagating from src/services/gl/EGLStreamProducer.cpp, function presentBuffer(), line 487)</div><div class="">Jan 28 16:07:30 dcd-398f9dee nvargus-daemon[4998]: SCF: Error BadParameter: (propagating from src/components/CaptureContainerImpl.cpp, function returnBuffer(), line 447)</div><div class="">Jan 28 16:07:30 dcd-398f9dee nvargus-daemon[4998]: SCF: Error BadParameter: (propagating from src/components/stages/BufferReturnStage.h, function doExecute(), line 43)</div><div class="">Jan 28 16:07:30 dcd-398f9dee nvargus-daemon[4998]: SCF: Error BadParameter: Sending critical error event (in src/api/Session.cpp, function sendErrorEvent(), line 990)</div><div class="">Jan 28 16:07:30 dcd-398f9dee nvargus-daemon[4998]: (NvCameraUtils) Error InvalidState: Mutex not initialized (/dvs/git/dirty/git-master_linux/camera/core_scf/src/services/gl/EGLStreamProducer.cpp:498) (in Mutex.cpp, function lock(), line 79)</div><div class="">Jan 28 16:07:30 dcd-398f9dee nvargus-daemon[4998]: (NvCameraUtils) Error InvalidState: Mutex has not been initialized (in Mutex.cpp, function unlock(), line 88)</div></blockquote><div class=""><br class=""></div><div class="">Do you have any idea what can be the difference between the two cases? Or what am I messing up when I starting it as a service?</div><div class=""><br class=""></div><div class="">Thank you for the help!</div><div class=""><br class=""></div><div class="">Bests,</div><div class="">Peter<br class=""><div class=""><div class=""><br class=""></div></div></div></body></html>