Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. GStreamer crash with QMediaPlayer
Forum Updated to NodeBB v4.3 + New Features

GStreamer crash with QMediaPlayer

Scheduled Pinned Locked Moved Unsolved General and Desktop
qmediaplayergstreamerubuntu 14.04qt 5.2.1qt 5.5.1
8 Posts 2 Posters 4.4k Views 2 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • E Offline
    E Offline
    enmaniac
    wrote on last edited by enmaniac
    #1

    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!

    Cheers!

    ? 1 Reply Last reply
    0
    • E enmaniac

      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!

      ? Offline
      ? Offline
      A Former User
      wrote on last edited by
      #2

      @enmaniac Hi! Can you create a minimal example? I'd like to see if I can reproduce this.

      E 1 Reply Last reply
      0
      • ? A Former User

        @enmaniac Hi! Can you create a minimal example? I'd like to see if I can reproduce this.

        E Offline
        E Offline
        enmaniac
        wrote on last edited by
        #3

        @Wieland Hi! Sure I will try to prepare one tomorrow, since I do not run Ubuntu at home. I'll keep you posted.

        Cheers!

        1 Reply Last reply
        0
        • E Offline
          E Offline
          enmaniac
          wrote on last edited by
          #4

          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();
          }
          

          Cheers!

          ? 1 Reply Last reply
          0
          • E enmaniac

            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();
            }
            
            ? Offline
            ? Offline
            A Former User
            wrote on last edited by
            #5

            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();
            
            E 1 Reply Last reply
            0
            • ? A Former User

              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();
              
              E Offline
              E Offline
              enmaniac
              wrote on last edited by enmaniac
              #6

              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.

              Cheers!

              1 Reply Last reply
              0
              • ? Offline
                ? Offline
                A Former User
                wrote on last edited by A Former User
                #7

                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.

                E 1 Reply Last reply
                0
                • ? A Former User

                  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.

                  E Offline
                  E Offline
                  enmaniac
                  wrote on last edited by
                  #8

                  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

                  Cheers!

                  1 Reply Last reply
                  0

                  • Login

                  • Login or register to search.
                  • First post
                    Last post
                  0
                  • Categories
                  • Recent
                  • Tags
                  • Popular
                  • Users
                  • Groups
                  • Search
                  • Get Qt Extensions
                  • Unsolved