Camera liveview cannot show up again after repeated open/close the liveview for several times

Hi All,

If we just repeated open/close the liveview with the same camera, the liveview will never show up again until restart the pipeline.

Test Environment:
-Jetson TX2
-Jetpack 4.4 L4T 32.4.3
-gst-launch-1.0

Test Condition:

  1. init camera
  2. preview for 1 sec
  3. stop preview
  4. repeat step 2 ~ 3

The expectation:
Open/close liveview without dropping the recording or restarting the pipeline.

Test source code:
gst_sample.tgz (31.1 KB)

Does it USB cam?
Can you try gst-launch-1.0 to check if can repo the issue?

Hi,
We did not use the USB cameras in our ODM system unit.
In order to clarify this issue, I have changed the source from the camera to the “videotestsrc” embedded in the Nvidia TX2 module.
So, we can ignore the problem of what kinds of camera firstly. After testing my attached program in Nvidia TX2 EVK, we can observe the same issue like as live view will crash at the 128th opens every time in the our ODM system unit and show the error messages below. (we can’t really use command line to test as we can’t add/remove the elements dynamically in command line.)
Please help to highlight this issue and put this test program to NV developer forum again. And we hope that you also contact NV’s sales and let them find resources to debug this issue asap.
Thanks.

Test Environment:

-Jetson TX2 EVK
-Jetpack 4.4 L4T 32.4.3
-gst-launch-1.0

Test Program:

./a.out
gst_sample.tgz (170 KB)

Error messages:

cannot map dumb buffer
cannot create dumb buffer
Cannot create frame buffer

If clarify the problem didn’t relative with nvidia camera driver I am sorry to tell you may need take time to narrow down the problem first.

Hi,

We have found the sources of the error messages like as the list below. We also attach the source code “NvDrmRenderer.cpp” of the item1 and item2 for your reference. Please contact NV’s sales and request the resource to debug.
Thanks.
NvDrmRenderer.cpp (28.7 KB)

  1. Error message: cannot map dumb buffer

/usr/src/jetson_multimedia_api/samples/common/classes/NvDrmRenderer.cpp: COMP_ERROR_MSG(“cannot map dumb buffer\n”);

Binary file ./lib/aarch64-linux-gnu/gstreamer-1.0/libgstnvdrmvideosink.so matches

  1. Error message: cannot create dumb buffer

/usr/src/jetson_multimedia_api/samples/common/classes/NvDrmRenderer.cpp: COMP_ERROR_MSG(“cannot create dumb buffer\n”);

/usr/src/jetson_multimedia_api/samples/common/classes/NvDrmRenderer.cpp: COMP_ERROR_MSG("cannot create dumb buffer ");

Binary file ./lib/aarch64-linux-gnu/gstreamer-1.0/libgstnvdrmvideosink.so matches

  1. Error message: Cannot create frame buffer

Binary file /usr/lib/aarch64-linux-gnu/gstreamer-1.0/libgstnvdrmvideosink.so matches

Hi,

Can you clarify what is the exact steps to hit the error? I am not quite sure why we have gstreamer sample in the first comment and then we now have DRM sample in the latest comment.

These two have no connection.

Also, please stop asking us to find NV sales. Just try to describe your problem clearly first.

Hi,

Attached are the logs of the trace error messages and live view execution crash log for reference.
Please help to check.
execute_test_program_at_128th_live_view_crash.log (34.0 KB)
trace_error_messages.log (1.0 KB)

Thanks.

Can you just tell us

  1. How many issues do we have here? 1 or 2? I see you have a gstreamer and a NvDrmRenderer error, so there are 2 issues?

  2. What is your exact steps hit this error?

Hi,

  1. We have two issues on this topic. We found that as we called the “NvDrmRenderer”, it always failed at the 128th open, so please help to check this. After the 128th open failure issue is solved on the
    “NvDrmRenderer”, , it will be retested and check if the other issue is solved synchronously.

  2. Please refer to the below steps:
    • Boot the Nvidia Jetson TX2 EVK.
    • Execute the “a.out” test program in my attached folder
    • This error will happen at every 128th open.

Thanks.

Is this issue also happened to default DRM renderer? I mean why do you post your code? What modification did you do?

Hi,
In gst_sample.tgz, it switches to NULL state without EoS notification. This may not be good. We suggest send EoS and wait for it, switch to NULL state, unrefer and re-initialize the pipeline.

Here is a sample of sending EoS:
GStreamer freeze when using qtmux and NVIDIA-accelerated h264/h265 encoding - #7 by DaneLLL

Hi,

After following the suggestion to modify our original code, I observe that there are error messages like as my attached .txt file when we execute the a.out in Nvidia Jetson TX2 EVK.
error_log.txt (1.2 KB)

I also try to put the suggesting code in different locations of our original code. However, it also shows different error messages after rebuilding and executing the a.out.
gst_sample.tgz (180 KB)

Thanks.

Hi,
We try to run a simple python to check if the issue is in nvdrmvideosink:

$ python3 nvdrmvideosink.py

nvdrmvideosink.py (964 Bytes)

We run twice and do not observe the issue. It passes 600 times.

Could you also try the sample and check if you still observe the issue? See if we can align on this first.

Hi ,

After testing the simple nvdrmvideosink.py code of python on my Jetson TX2 EVK, got the error messages as the below figure. And the program would be hung at the first loop.
Please help to check. Thanks.

Hi,
For using DRM renderer you would need to disable X11. Please refer to steps in
gstreamer user guide:

1.Stop the display manager:
sudo systemctl stop gdm
sudo loginctl terminate-seat seat0

Hi,

We followed NV’s suggestion to stop the display manager then tested the provided simple python code. And it could pass 600 times of testing. Could NV provide the related sample code in C or C++?
Thanks.

Hi,
Please check this sample:

#include <cstdlib>
#include <cstring>
#include <sstream>
#include <gst/gst.h>

using namespace std;

#define USE(x) ((void)(x))

static GstPipeline *gst_pipeline = nullptr;
static string launch_string;

GstClockTime usec = 1000000;

int main(int argc, char** argv) {
    USE(argc);
    USE(argv);

    gst_init (&argc, &argv);

    GMainLoop *main_loop;
    main_loop = g_main_loop_new (NULL, FALSE);
    ostringstream launch_stream;
    GstBus* bus;

    launch_stream
    << "videotestsrc is-live=1 ! "
    << "video/x-raw,width=1920,height=1080,format=YUY2 ! "
    << "nvvidconv ! video/x-raw(memory:NVMM),format=NV12 ! nvdrmvideosink ";

    launch_string = launch_stream.str();

    g_print("Using launch string: %s\n", launch_string.c_str());

    GError *error = nullptr;
for(guint i=0; i<300; i++) {
    g_print("loop= %d \n", i);
    gst_pipeline  = (GstPipeline*) gst_parse_launch(launch_string.c_str(), &error);

    if (gst_pipeline == nullptr) {
        g_print( "Failed to parse launch: %s\n", error->message);
        return -1;
    }
    if(error) g_error_free(error);

    gst_element_set_state((GstElement*)gst_pipeline, GST_STATE_PLAYING); 
    g_usleep(5*usec);
    gst_element_send_event ((GstElement*)gst_pipeline, gst_event_new_eos ());
    // Wait for EOS message
    bus = gst_pipeline_get_bus(GST_PIPELINE(gst_pipeline));
    gst_bus_poll(bus, GST_MESSAGE_EOS, GST_CLOCK_TIME_NONE);
    gst_element_set_state((GstElement*)gst_pipeline, GST_STATE_NULL);

    gst_object_unref(GST_OBJECT(gst_pipeline));
    g_usleep(1*usec);
}
    g_main_loop_unref(main_loop);

    g_print("going to exit \n");
    return 0;
}

Hi,

We tested the sample code that the algorithm closes the whole pipeline can test passed 600 times.
Is there any way not to close the pipeline and keeps the function works?

Thanks.