qmlglsink: crashes when created and destroyed in quick succession
qmlglsink crashes when created and destroyed in quick succession. Crash is very easy to reproduce, see snippet below:
import QtQuick 2.11
import org.freedesktop.gstreamer.GLVideoItem 1.0
Item {
Loader {
id: sinkLoader
sourceComponent: Component { GstGLVideoItem {} }
}
Timer {
interval: 1
running: true
repeat: true
onTriggered: sinkLoader.active = !sinkLoader.active;
}
}
Reproduced on:
- Ubuntu 18.04 (X11) with gst-plugins-good-1.14.5 and Qt 5.11.2
- Embedded Linux (Wayland) with gst-plugins-good-1.16.2 and Qt 5.11.2
- Embedded Linux (Wayland) with gst-plugins-good-master (5fb5abc8) and Qt 5.11.2
Analysis: It seems to be caused by a race condition where the render thread calls a method on the QtGLVideoItem instance that was previously destroyed in the main thread, here: https://gitlab.freedesktop.org/gstreamer/gst-plugins-good/-/blob/master/ext/qt/qtitem.cc#L100 Also, less frequently, QtGLVideoItem::onSceneGraphInitialized is called when QQuickItem::window is null, also causing a crash.
Edited by Bastien Reboulet