Deepstream reconnection has a chance to trigger blocking

Please provide complete information as applicable to your setup.

• Hardware Platform (Jetson / GPU) GPU
• DeepStream Version5.1
• JetPack Version (valid for Jetson only)
• TensorRT Version 7.2
• NVIDIA GPU Driver Version (valid for GPU only) 440
• Issue Type( questions, new requirements, bugs) bug
• How to reproduce the issue ? (This is for bugs. Including which sample app is using, the configuration files content, the command line used and other details for reproducing)
This is a blocking situation.

This is the code, gst_element_set_state (src_bin->bin,
GST_STATE_NULL) triggering a block.

reset_source_pipeline (gpointer data)
  NvDsSrcBin *src_bin = (NvDsSrcBin *) data;
  GstState state, pending;
  GstStateChangeReturn ret;
    NVGSTDS_INFO_MSG_V ("1111111111111111111");
    NVGSTDS_INFO_MSG_V ("1111111111111111111.5");
  gettimeofday (&src_bin->last_buffer_time, NULL);
  gettimeofday (&src_bin->last_reconnect_time, NULL);
    NVGSTDS_INFO_MSG_V ("1111111111111111111.6");
    NVGSTDS_INFO_MSG_V ("2222222222222222");
  if (gst_element_set_state (src_bin->bin,
      NVGSTDS_INFO_MSG_V ("22222222.5");
    GST_ERROR_OBJECT (src_bin->bin, "Can't set source bin to NULL");
    return FALSE;
    NVGSTDS_INFO_MSG_V ("3333333333333333");
  NVGSTDS_INFO_MSG_V ("Resetting source %d", src_bin->bin_id);

  GST_CAT_INFO (NVDS_APP, "Reset source pipeline %s %p\n,", __func__, src_bin);
  if (!gst_element_sync_state_with_parent (src_bin->bin)) {
    GST_ERROR_OBJECT (src_bin->bin, "Couldn't sync state with parent");

  ret = gst_element_get_state (src_bin->bin, &state, &pending, 0);

  GST_CAT_DEBUG (NVDS_APP, "Bin %d %p: state:%s pending:%s ret:%s",
          src_bin->bin_id, src_bin, gst_element_state_get_name(state),

    if (!src_bin->async_state_watch_running)
      g_timeout_add (20, watch_source_async_state_change, src_bin);
    src_bin->async_state_watch_running = TRUE;
    src_bin->reconfiguring = TRUE;
  } else if (ret == GST_STATE_CHANGE_SUCCESS && state == GST_STATE_PLAYING) {
    src_bin->reconfiguring = FALSE;
  return FALSE;

Can you have a try with latest version DS 6.0?

I compared 6.0 to the reset_source_pipeline function without any changes

Can you share more about your use case?

I use deepstream-test5 through “./deepstream-test5-app -c configs/test5_config_file_src_infer.txt” command.
No other changes.

Can you run below command line before run your test application to get some log?

$ export GST_DEBUG=3

I have upgraded to 6.0.
This question may involve a change of mine. I tried to use unlink_element_from_streammux_sink_pad(bin->streammux, bin->sub_bins[i].bin) to delete the stream dynamically and blocked.And then the reconnection is blocked.

Can you refer below for dynamical add/remove source?

deepstream_reference_apps/deepstream_test_rt_src_add_del.c at master · NVIDIA-AI-IOT/deepstream_reference_apps (

Yes, I already did.
But there was another problem.
I added stop_release_source to deepstream_test5_app_main,c, it is work.
But it cannot be called in the bus_callback function, otherwise it would block.