Qml VideoItem Crashes on Stream Start using Gstreamer
-
Hi everyone and thank you in advance for your support, I've been struggling with something for a while now.
I'm developing an application that displays 4 udp video streams on qml side simultaneously using Qtgstreamer on the backend, the problem is that when I send the video stream AFTER launching the application it suddenly crashes.
I will provide an example of the structure of the application regarding the video handling and a backtrace of the SIGSEV.Videostream class handles pipeline creation and manipulation
here's the part where the pipeline is created and the sink initialized//Class Ctor VideoStream::VideoStream(const QGst::ElementPtr & sink) : QObject(parent) { /* ... */ setVideoSink(sink); setPipeline(); } logger->log(logger->DEBUG, "VideoStream instance created."); } // Set the sink object where the stream should be displayed void VideoStream::setVideoSink(const QGst::ElementPtr & sink) { m_videoSink = sink; // Set synk to false in order to reduce latency and freezing m_videoSink->setProperty("sync", false); logger->log(logger->DEBUG, "VideoStream video sink set"); } // Set the gstreamer pipeline based on the object configuration void VideoStream::setPipeline() { if (m_pipeline) { // Stop the pipeline m_pipeline->setState(QGst::StateNull); // Clear the pointer, destroying the pipeline as its reference count drops to zero. m_pipeline.clear(); logger->log(logger->DEBUG, "VideoStream Pipeline cleared"); } // Create a new pipeline m_pipeline = QGst::Pipeline::create(); // Create a new udpsrc element QGst::ElementPtr udpsrc = QGst::ElementFactory::make("udpsrc"); udpsrc->setProperty("address", iniReader->getAddressStream().toLatin1().constData()); udpsrc->setProperty("port", static_cast<int>(iniReader->getPilotPort())); // Create the remaining elements of the pipeline QGst::ElementPtr desc = QGst::Bin::fromDescription("tsdemux ! queue flush-on-eos=true ! h264parse ! avdec_h264 ! videoconvert ! video/x-raw,format=RGB ! videoconvert"); // Add all the elements to the pipeline m_pipeline->add(udpsrc); m_pipeline->add(desc); // Add the outpit video sink to the pipeline m_pipeline->add(m_videoSink); // Link the udpser element with all the other if(udpsrc->link(desc) == false) { logger->log(logger->ERR, "VideoStream Description link failed"); } // Link the pipeline output to the video sink if(desc->link(m_videoSink) == false) { logger->log(logger->ERR, "VideoStream Video Sink link failed"); } // Watch the bus for messages QGst::BusPtr bus = m_pipeline->bus(); bus->addSignalWatch(); QGlib::connect(bus, "message", this, &VideoStream::onBusMessage); logger->log(logger->DEBUG, "VideoStream Pipeline set"); // Play the pipeline m_pipeline->setState(QGst::StatePlaying); }
main.cpp - example of one of the four streams the others are created in the same way
QGst::Quick::VideoSurface *surfaceMain = new QGst::Quick::VideoSurface(); VideoStream *playerMain = new VideoStream(surfaceMain->videoSink()); engine.rootContext()->setContextProperty(QLatin1String("videoSurfaceMain"), surfaceMain); engine.rootContext()->setContextProperty(QLatin1String("playerMain"), playerMain);
main.qml - VideoItem to display the stream
VideoItem { id: video1 x: (parent.width - width ) / 2 y: (parent.height - height) / 2 width: w1 height: h1 surface: videoSurfaceMain }
SIGSEV backtrace - it occurs when the stream starts after the application have been launched
Thread 35 "QSGRenderThread" received signal SIGSEGV, Segmentation fault.
[Switching to Thread 0x7fff567fc700 (LWP 106540)]
0x00000000400b0df1 in ?? ()
(gdb) bt
#0 0x00000000400b0df1 in ()
#1 0x00007fffb102fd00 in ()
#2 0x00007fff3ee56a70 in ()
#3 0x00007fff567fb1f0 in ()
#4 0x000000000000007f in ()
#5 0x00007fff84b8173d in () at /usr/lib/x86_64-linux-gnu/libnvidia-glcore.so.460.91.03
#6 0x00007fff84b8b6a9 in () at /usr/lib/x86_64-linux-gnu/libnvidia-glcore.so.460.91.03
#7 0x00007fff84ca2a6a in () at /usr/lib/x86_64-linux-gnu/libnvidia-glcore.so.460.91.03
#8 0x00007fff84cadf58 in () at /usr/lib/x86_64-linux-gnu/libnvidia-glcore.so.460.91.03
#9 0x00007fff84caf484 in () at /usr/lib/x86_64-linux-gnu/libnvidia-glcore.so.460.91.03
#10 0x00007fff84caf80a in () at /usr/lib/x86_64-linux-gnu/libnvidia-glcore.so.460.91.03
#11 0x00007fffec9f44ac in VideoMaterial::bindTexture(int, unsigned char const*) () at /usr/lib/x86_64-linux-gnu/gstreamer-1.0/libgstqt5videosink.so
#12 0x00007fffec9f462c in VideoMaterial::bind() () at /usr/lib/x86_64-linux-gnu/gstreamer-1.0/libgstqt5videosink.so
#13 0x00007fffec9f4bcd in VideoMaterialShader::updateState(QSGMaterialShader::RenderState const&, QSGMaterial*, QSGMaterial*) () at /usr/lib/x86_64-linux-gnu/gstreamer-1.0/libgstqt5videosink.so
#14 0x00007ffff560176a in QSGBatchRenderer::Renderer::renderMergedBatch(QSGBatchRenderer::Batch const*) (this=0x7fff3c125a80, batch=0x7fff3cda8d70) at scenegraph/coreapi/qsgbatchrenderer.cpp:2306
#15 0x00007ffff56021dd in QSGBatchRenderer::Renderer::renderBatches() (this=this@entry=0x7fff3c125a80) at scenegraph/coreapi/qsgbatchrenderer.cpp:2532
#16 0x00007ffff56077d3 in QSGBatchRenderer::Renderer::render() (this=<optimized out>) at scenegraph/coreapi/qsgbatchrenderer.cpp:2735
#17 0x00007ffff55f8303 in QSGRenderer::renderScene(QSGBindable const&) (this=0x7fff3c125a80, bindable=...) at scenegraph/coreapi/qsgrenderer.cpp:244
#18 0x00007ffff55f87cb in QSGRenderer::renderScene(unsigned int) (this=<optimized out>, fboId=<optimized out>) at scenegraph/coreapi/qsgrenderer.cpp:197
#19 0x00007ffff563567e in QSGDefaultRenderContext::renderNextFrame(QSGRenderer*, unsigned int) (this=0x5555563a1280, renderer=0x7fff3c125a80, fboId=<optimized out>)
at scenegraph/qsgdefaultrendercontext.cpp:182
#20 0x00007ffff5692234 in QQuickWindowPrivate::renderSceneGraph(QSize const&) (this=this@entry=0x555555dde800, size=...) at items/qquickwindow.cpp:487
#21 0x00007ffff56411ae in QSGRenderThread::syncAndRender() (this=this@entry=0x55555b0090d0) at scenegraph/qsgthreadedrenderloop.cpp:646
#22 0x00007ffff56447ec in QSGRenderThread::run() (this=0x55555b0090d0) at scenegraph/qsgthreadedrenderloop.cpp:730
#23 0x00007ffff5f4f073 in QThreadPrivate::start(void*) (arg=0x55555b0090d0) at thread/qthread_unix.cpp:361
#24 0x00007ffff466f609 in start_thread (arg=<optimized out>) at pthread_create.c:477
#25 0x00007ffff424a293 in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95
(gdb) bt full
#0 0x00000000400b0df1 in ()
#1 0x00007fffb102fd00 in ()
#2 0x00007fff3ee56a70 in ()
#3 0x00007fff567fb1f0 in ()
#4 0x000000000000007f in ()
#5 0x00007fff84b8173d in () at /usr/lib/x86_64-linux-gnu/libnvidia-glcore.so.460.91.03
#6 0x00007fff84b8b6a9 in () at /usr/lib/x86_64-linux-gnu/libnvidia-glcore.so.460.91.03
#7 0x00007fff84ca2a6a in () at /usr/lib/x86_64-linux-gnu/libnvidia-glcore.so.460.91.03
#8 0x00007fff84cadf58 in () at /usr/lib/x86_64-linux-gnu/libnvidia-glcore.so.460.91.03
#9 0x00007fff84caf484 in () at /usr/lib/x86_64-linux-gnu/libnvidia-glcore.so.460.91.03
#10 0x00007fff84caf80a in () at /usr/lib/x86_64-linux-gnu/libnvidia-glcore.so.460.91.03
#11 0x00007fffec9f44ac in VideoMaterial::bindTexture(int, unsigned char const*) ()
at /usr/lib/x86_64-linux-gnu/gstreamer-1.0/libgstqt5videosink.so
#12 0x00007fffec9f462c in VideoMaterial::bind() () at /usr/lib/x86_64-linux-gnu/gstreamer-1.0/libgstqt5videosink.so
#13 0x00007fffec9f4bcd in VideoMaterialShader::updateState(QSGMaterialShader::RenderState const&, QSGMaterial*, QSGMaterial*) ()
at /usr/lib/x86_64-linux-gnu/gstreamer-1.0/libgstqt5videosink.so
#14 0x00007ffff560176a in QSGBatchRenderer::Renderer::renderMergedBatch(QSGBatchRenderer::Batch const*) (this=
0x7fff3c125a80, batch=0x7fff3cda8d70) at scenegraph/coreapi/qsgbatchrenderer.cpp:2306
gn = 0x7fff3c38c3c0
sms = 0x7fff3e128f00
attrNames = <optimized out>
e = <optimized out>
dirty = <optimized out>
indexBase = 0x0
indexBuf = <optimized out>
material = 0x7fff3dc1a260
program = 0x7fff3e28a9a0
batch = 0x7fff3cda8d70
this = 0x7fff3c125a80
#15 0x00007ffff56021dd in QSGBatchRenderer::Renderer::renderBatches() (this=this@entry=0x7fff3c125a80)
at scenegraph/coreapi/qsgbatchrenderer.cpp:2532
b = <optimized out>
i = 3
r = <optimized out>
renderOpaque = <optimized out>
renderAlpha = 255
#16 0x00007ffff56077d3 in QSGBatchRenderer::Renderer::render() (this=<optimized out>) at scenegraph/coreapi/qsgbatchrenderer.cpp:2735
timer = {t1 = -9223372036854775808, t2 = -9223372036854775808}
timeRenderLists = 0
timePrepareOpaque = 0
timePrepareAlpha = 0
timeSorting = 0
timeUploadOpaque = 0
timeUploadAlpha = 0
largestVBO = <optimized out>
largestIBO = <optimized out>
#17 0x00007ffff55f8303 in QSGRenderer::renderScene(QSGBindable const&) (this=0x7fff3c125a80, bindable=...) at scenegraph/coreapi/qsgrenderer.cpp:244
bindTime = 0
renderTime = 0
bindable = <optimized out>
this = 0x7fff3c125a80
#18 0x00007ffff55f87cb in QSGRenderer::renderScene(unsigned int) (this=<optimized out>, fboId=<optimized out>) at scenegraph/coreapi/qsgrenderer.cpp:197
bindable = warning: RTTI symbol not found for class 'QSGRenderer::renderScene(unsigned int)::B'
{<QSGBindable> = {_vptr.QSGBindable = 0x7ffff5b04098 <vtable for QSGRenderer::renderScene(unsigned int)::B+16>}, <No data fields>}
#19 0x00007ffff563567e in QSGDefaultRenderContext::renderNextFrame(QSGRenderer*, unsigned int) (this=0x5555563a1280, renderer=0x7fff3c125a80, fboId=<optimized out>)
at scenegraph/qsgdefaultrendercontext.cpp:182
#20 0x00007ffff5692234 in QQuickWindowPrivate::renderSceneGraph(QSize const&) (this=this@entry=0x555555dde800, size=...) at items/qquickwindow.cpp:487
fboId = <optimized out>
devicePixelRatio = 1
_qml_memory_scope = {static state = QQmlMemoryScope::Failed, pushed = false}
#21 0x00007ffff56411ae in QSGRenderThread::syncAndRender() (this=this@entry=0x55555b0090d0) at scenegraph/qsgthreadedrenderloop.cpp:646
waitTimer = {t1 = 26747, t2 = 483837597}
repaintRequested = false
syncRequested = <optimized out>
exposeRequested = false
current = <optimized out>
#22 0x00007ffff56447ec in QSGRenderThread::run() (this=0x55555b0090d0) at scenegraph/qsgthreadedrenderloop.cpp:730
#23 0x00007ffff5f4f073 in QThreadPrivate::start(void*) (arg=0x55555b0090d0) at thread/qthread_unix.cpp:361
thr = 0x55555b0090d0
data = 0x55555b67a1a0
__clframe = {__cancel_routine = 0x7ffff5f4e310 QThreadPrivate::finish(void*), __cancel_arg = 0x55555b0090d0, __do_it = 1, __cancel_type = <optimized out>}
#24 0x00007ffff466f609 in start_thread (arg=<optimized out>) at pthread_create.c:477
ret = <optimized out>
pd = <optimized out>
unwind_buf =
{cancel_jmp_buf = {{jmp_buf = {140734644602624, 5005158788743483774, 140737488344734, 140737488344735, 140737488344960, 140734644600704, -5004825638826487426, -5005173004756790914}, mask_was_saved = 0}}, priv = {pad = {0x0, 0x0, 0x0, 0x0}, data = {prev = 0x0, cleanup = 0x0, canceltype = 0}}}
not_first_call = 0
#25 0x00007ffff424a293 in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95
(gdb)I've tried commenting out the VideoItem on qml side and the backend runs fine without crashing, so I'm seriously starting to think there are some problems that go beyond the code itself with Nvidia drivers or QT/Gstreamer
I'm running the application in the following environment:
OS: Ubuntu 20.04
GPU: TU117M [Nvidia GeForce GTX 1650 Mobile / Max-Q]
Nvidia Driver Version: 460.91.03
Qt Version : 5.12.5
Gstreamer Version: GStreamer Core Library version 1.16.2I hope I've provided enough details, if anyone knows of the issue or spots something wrong I would be forever grateful.
-
From the maintainers of that module it was deprecated and is unmaintained.
They are providing an example to use the QML plugin that is now their official entry point for Qt.
-
Hi,
Are you using the QtGStreamer module ?
-
@SGaist Hi, and thank you very much for replying, yes infact i'm using the QtGstreamer module
here's the .pro imports
PKGCONFIG += Qt5GStreamer-1.0 Qt5GStreamerUtils-1.0 Qt5GStreamerUi-1.0 gstreamer-1.0 gstreamer-video-1.0 LIBS += -L/home/.../Qt/5.12.5/gcc_64/lib/ -lQt5GStreamerQuick-1.0
-
From the maintainers of that module it was deprecated and is unmaintained.
They are providing an example to use the QML plugin that is now their official entry point for Qt.
-
Hello SGaist,
we are experiencing the same problem as Fal92.
At this time we cannot change the code even though we know that the module has been deprecated.
Could you give us some hint to understand the possible cause of the problem?
Thanks in advance
Regards -
@guruhenry hi and welcome to devnet,
Are you also using a NVIDIA graphics card ?
-
Latest version of the driver ?
Did you test using the nouveau driver ?