GStreamer crash with QMediaPlayer
-
Hey all,
I am experiencing quite regular crashes within GStreamer backend of QMediaPlayer.
I am using 2 instances of QMediaPlayer. First instance's life span is long and the second one is quite short.I've observed that during the construction of QMediaPlayer, QGstreamerPlayerSession is constructed as well.
There gst_type_find_register is called which registers playlist type and a callback to be executed: playlistTypeFindFunction. Pointer to self (this) is also supplied to registration function.Now, I can see that sequence being called twice for both of QMediaPlayer objects. After some time, one of the players is deallocated and while using the remaining instance, quite often, it happens that playlistTypeFindFunction is called with a data pointing to already deallocated instance.
I dont see any deregistration happening in desctructor of QGstreamerPlayerSession.
Am I abusing QMediaPlayer or there's more going on here ?
Note, that it happens in Qt 5.2.1 and Qt 5.5.1 on Ubuntu 14.04 64bit. On Windows 7 64-bit it seems to work fine but I think the backend used is different.
Cheers!
-
@Wieland Hi! Sure I will try to prepare one tomorrow, since I do not run Ubuntu at home. I'll keep you posted.
-
Hey, since I dont see the way how to attach some zipped code, I'll paste the example I have created which causes the app to crash.
#include <QApplication> #include <QMediaPlayer> #include <QDebug> #include <QDir> #include <QTimer> class Sink : public QObject { Q_OBJECT public: Sink() : QObject() {} public slots: void onStart() { QDir dir("."); QMediaPlayer player1; player1.setMedia(QUrl::fromLocalFile(dir.absoluteFilePath("chime.wav"))); const int KIterationCount = 10; for (int i = 0; i < KIterationCount; ++i) { { QMediaPlayer player2; // comment this out to make all work } // play until finished player1.play(); QEventLoop eventLoop; while(player1.state() != QMediaPlayer::StoppedState) { eventLoop.processEvents(); } } QApplication::quit(); } }; #include "main.moc" int main(int argc, char *argv[]) { QApplication app(argc, argv); Sink sink; QTimer::singleShot(10, &sink, SLOT(onStart())); return app.exec(); }
-
I observe the same error on openSUSE with gstreamer. I have no idea what's going wrong here. I found out that the following prevents the program from crashing:
QMediaPlayer *player2 = new QMediaPlayer; player2->deleteLater();
-
Thank for the interest!
Indeed, this seems to solve the issue but in reality it is only hiding the symptoms. Crash does not happen since none of the instances is deleted during the test. All of them get deallocated after onStart finishes and control is given back to main event loop.
I wonder if this is well known issue as I cant imagine no one else encountered this before.
But thank you for confirmation anyways. I was also afraid that my setup might be somehow buggy.
-
Crash does not happen since none of the instances is deleted during the test
Right. This was intended :-) I think your analysis from your first posting points into the right direction and the bug must be somewhere in the QMediaplayer destructor.
-
I have opened the bug ticket https://bugreports.qt.io/browse/QTBUG-50460.
Perhaps it is really a bug and will get fixed in the future ;D