d3d11screencapturesrc: Creating multiple pipelines causes a crash
Describe your issue
Having multiple pipelines with d3d11screencapturesrc
causes a crash within the gstd3d11screencapture.cpp
. This was discovered while trying to integrate the d3d11screencapturesrc
with an existing application that spawns various GStreamer pipelines. I have provided a minimal code sample below that reproduces the exact same crash when ran with the GST_DEBUG
environment variable set to 3 or higher.
Expected Behavior
Multiple pipelines with d3d11screencapturesrc
should work without crashing.
Observed Behavior
Multiple pipelines with d3d11screencapturesrc
crashes when enabling Gstreamer log output.
Setup
- Operating System: Windows 10 21H1 and above
- Device: Desktop Computer
- GStreamer Version: 1.20.0
Steps to reproduce the bug
A minimal complete code sample based on GStreamer Hello World example is written below. Running this with GST_DEBUG
set to 3 or higher should reproduce the crash.
Code Example
#include <gst/gst.h>
int
main(int argc, char* argv[])
{
GstElement* pipeline1, *pipeline2;
GstBus* bus1, *bus2;
GstMessage* msg1, *msg2;
gst_init(&argc, &argv);
pipeline1 =
gst_parse_launch
("d3d11screencapturesrc ! fakesink", NULL);
pipeline2 =
gst_parse_launch
("d3d11screencapturesrc ! fakesink", NULL);
gst_element_set_state(pipeline1, GST_STATE_PLAYING);
gst_element_set_state(pipeline2, GST_STATE_PLAYING);
bus1 = gst_element_get_bus(pipeline1);
bus2 = gst_element_get_bus(pipeline2);
while (true)
{
msg1 =
gst_bus_timed_pop_filtered(bus1, 16 * GST_MSECOND, (GstMessageType)(GST_MESSAGE_STATE_CHANGED | GST_MESSAGE_ERROR | GST_MESSAGE_EOS | GST_MESSAGE_DURATION));
msg2 =
gst_bus_timed_pop_filtered(bus2, 16 * GST_MSECOND, (GstMessageType)(GST_MESSAGE_STATE_CHANGED | GST_MESSAGE_ERROR | GST_MESSAGE_EOS | GST_MESSAGE_DURATION));
if ((msg1 != NULL && GST_MESSAGE_TYPE(msg1) == GST_MESSAGE_ERROR) || (msg2 != NULL && GST_MESSAGE_TYPE(msg2) == GST_MESSAGE_ERROR)) {
break;
}
}
gst_message_unref(msg2);
gst_message_unref(msg1);
gst_object_unref(bus2);
gst_object_unref(bus1);
gst_element_set_state(pipeline2, GST_STATE_NULL);
gst_element_set_state(pipeline1, GST_STATE_NULL);
gst_object_unref(pipeline2);
gst_object_unref(pipeline1);
return 0;
}
How reproducible is the bug?
Always when running the code sample above with GST_DEBUG of 3 or greater.
Screenshots if relevant
Debugging from Visual Studio, this is the call stack when it breaks: