Uploaded image for project: 'Qt for Python'
  1. Qt for Python
  2. PYSIDE-2843

Application freezes when loading another audio file with QMediaPlayer

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • P3: Somewhat important
    • 6.8.0, 6.7.3
    • 6.6.0, 6.7.2
    • PySide
    • None
    • Linux/X11, Windows
    • 3edcd587e (dev), 7e7fc5ba3 (6.7)

    Description

      Hi, I use the QMediaPlayer to playback audio in my application but when I want to load another audio file while one is loaded the whole application freezes up and does not respond any more. It then needs to be killed. Curiously this only occurs with PySide6 and NOT when implementing the same code in C++ (See both projects attached).

      I think it might be a bit flaky so if you want the exact audio files I can send them per request - although I could reproduce it with at least two different audio file formats (opus and webm). I also could reproduce it with Qt 6.6.0 on Windows 10.

      How to reproduce:

      1. Download the attached project (media_player_test_py.zip) and extract
      2. Set up your virtual environment: "python3 -m venv venv"
      3. Activate environment and install requirements: "source venv/bin/activate && pip install -r requirements.txt"
      4. Edit the "AUDIO_PATHS" in the "main.py" file to point to two audio files
      5. Execute application: "python3 main.py"
      6. Press Key "K" once to start playing the first audio
      7. Wait about two seconds
      8. Press "K" again
      9. => Freeze

      What I expect to happen:

      I expect it to play just fine, like it does in the c++ project (media_player_test_cpp.zip).

      More info:

      • ffmpeg is used in the Media backend, gstreamer does not work for me
      • I tried debugging this with gdb and here is the backtrace (normal PySide6 installation via pip and audio paths replaced):
       gdb --args python main.py 
      GNU gdb (Ubuntu 12.1-0ubuntu1~22.04.2) 12.1
      Copyright (C) 2022 Free Software Foundation, Inc.
      License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
      This is free software: you are free to change and redistribute it.
      There is NO WARRANTY, to the extent permitted by law.
      Type "show copying" and "show warranty" for details.
      This GDB was configured as "x86_64-linux-gnu".
      Type "show configuration" for configuration details.
      For bug reporting instructions, please see:
      <https://www.gnu.org/software/gdb/bugs/>.
      Find the GDB manual and other documentation resources online at:
          <http://www.gnu.org/software/gdb/documentation/>.
      
      For help, type "help".
      Type "apropos word" to search for commands related to "word"...
      Reading symbols from python...
      (No debugging symbols found in python)
      (gdb) run
      Starting program: /home/sebiai/Downloads/media_player_test_py/venv/bin/python main.py
      [Thread debugging using libthread_db enabled]
      Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
      [New Thread 0x7ffff05ff640 (LWP 15135)]
      [New Thread 0x7fffefdfe640 (LWP 15136)]
      [New Thread 0x7fffe7fff640 (LWP 15137)]
      [New Thread 0x7fffe77fe640 (LWP 15138)]
      [New Thread 0x7fffe6ffd640 (LWP 15139)]
      [Thread 0x7fffe6ffd640 (LWP 15139) exited]
      [New Thread 0x7fffe6ffd640 (LWP 15140)]
      [New Thread 0x7fffe67fc640 (LWP 15141)]
      [Thread 0x7fffe6ffd640 (LWP 15140) exited]
      [Thread 0x7fffe67fc640 (LWP 15141) exited]
      [New Thread 0x7fffe67fc640 (LWP 15142)]
      [New Thread 0x7fffe6ffd640 (LWP 15143)]
      [Thread 0x7fffe67fc640 (LWP 15142) exited]
      [Thread 0x7fffe6ffd640 (LWP 15143) exited]
      [New Thread 0x7fffe6ffd640 (LWP 15144)]
      Key K pressed
      Player stopped
      URL created PySide6.QtCore.QUrl('file:///path/to/audio1')
      [New Thread 0x7fffe67fc640 (LWP 15145)]
      Source set
      Player initialized
      Player started
      qt.multimedia.ffmpeg.mediadataholder: AVStream duration -9223372036854775808 is invalid. Taking it from the metadata
      [New Thread 0x7fffd1901640 (LWP 15146)]
      [New Thread 0x7fffd1100640 (LWP 15147)]
      [New Thread 0x7fffd08ff640 (LWP 15148)]
      [Thread 0x7fffd08ff640 (LWP 15148) exited]
      [Thread 0x7fffd1100640 (LWP 15147) exited]
      [New Thread 0x7fffd1100640 (LWP 15149)]
      [New Thread 0x7fffd08ff640 (LWP 15150)]
      [New Thread 0x7fffb4392640 (LWP 15151)]
      [opus @ 0x555556259400] Could not update timestamps for skipped samples.
      [New Thread 0x7fffb3b91640 (LWP 15152)]
      Key K pressed
      Player stopped
      URL created PySide6.QtCore.QUrl('file:///path/to/audio2')
      [Thread 0x7fffd08ff640 (LWP 15150) exited]
      [Thread 0x7fffb4392640 (LWP 15151) exited]
      ^C
      Thread 1 "python" received signal SIGINT, Interrupt.
      __futex_abstimed_wait_common64 (private=0, cancel=true, abstime=0x0, op=393, expected=0, futex_word=0x55555660f6b0) at ./nptl/futex-internal.c:57
      57    ./nptl/futex-internal.c: Datei oder Verzeichnis nicht gefunden.
      (gdb) bt
      #0  __futex_abstimed_wait_common64 (private=0, cancel=true, abstime=0x0, op=393, expected=0, futex_word=0x55555660f6b0) at ./nptl/futex-internal.c:57
      #1  __futex_abstimed_wait_common (cancel=true, private=0, abstime=0x0, clockid=0, expected=0, futex_word=0x55555660f6b0) at ./nptl/futex-internal.c:87
      #2  __GI___futex_abstimed_wait_cancelable64 (futex_word=futex_word@entry=0x55555660f6b0, expected=expected@entry=0, clockid=clockid@entry=0, abstime=abstime@entry=0x0, private=private@entry=0) at ./nptl/futex-internal.c:139
      #3  0x00007ffff7cd3a41 in __pthread_cond_wait_common (abstime=0x0, clockid=0, mutex=0x55555660f660, cond=0x55555660f688) at ./nptl/pthread_cond_wait.c:503
      #4  ___pthread_cond_wait (cond=0x55555660f688, mutex=0x55555660f660) at ./nptl/pthread_cond_wait.c:627
      #5  0x00007ffff642320b in QWaitCondition::wait(QMutex*, QDeadlineTimer) () at /home/sebiai/Downloads/media_player_test_py/venv/lib/python3.10/site-packages/PySide6/Qt/lib/libQt6Core.so.6
      #6  0x00007ffff6417371 in QThread::wait(QDeadlineTimer) () at /home/sebiai/Downloads/media_player_test_py/venv/lib/python3.10/site-packages/PySide6/Qt/lib/libQt6Core.so.6
      #7  0x00007fffd1a5deb6 in  () at /home/sebiai/Downloads/media_player_test_py/venv/lib/python3.10/site-packages/PySide6/Qt/plugins/multimedia/libffmpegmediaplugin.so
      #8  0x00007fffd1a5e0ea in  () at /home/sebiai/Downloads/media_player_test_py/venv/lib/python3.10/site-packages/PySide6/Qt/plugins/multimedia/libffmpegmediaplugin.so
      #9  0x00007fffd1a5e629 in  () at /home/sebiai/Downloads/media_player_test_py/venv/lib/python3.10/site-packages/PySide6/Qt/plugins/multimedia/libffmpegmediaplugin.so
      #10 0x00007fffd1a4888f in  () at /home/sebiai/Downloads/media_player_test_py/venv/lib/python3.10/site-packages/PySide6/Qt/plugins/multimedia/libffmpegmediaplugin.so
      #11 0x00007ffff203ca4e in  () at /home/sebiai/Downloads/media_player_test_py/venv/lib/python3.10/site-packages/PySide6/Qt/lib/libQt6Multimedia.so.6
      #12 0x00007ffff203d83d in QMediaPlayer::setSource(QUrl const&) () at /home/sebiai/Downloads/media_player_test_py/venv/lib/python3.10/site-packages/PySide6/Qt/lib/libQt6Multimedia.so.6
      #13 0x00007ffff2101d52 in  () at /home/sebiai/Downloads/media_player_test_py/venv/lib/python3.10/site-packages/PySide6/QtMultimedia.abi3.so
      #14 0x00005555556ae7f4 in  ()
      #15 0x000055555569d742 in _PyEval_EvalFrameDefault ()
      #16 0x00005555556bd251 in  ()
      #17 0x000055555569d742 in _PyEval_EvalFrameDefault ()
      #18 0x00005555556bd4b1 in  ()
      #19 0x00007ffff681b5d1 in PySide::SignalManager::callPythonMetaMethod(QMetaMethod const&, void**, _object*, bool) () at /home/sebiai/Downloads/media_player_test_py/venv/lib/python3.10/site-packages/PySide6/libpyside6.abi3.so.6.7
      #20 0x00007ffff681b8bc in PySide::SignalManager::SignalManagerPrivate::qtMethodMetacall(QObject*, int, void**) () at /home/sebiai/Downloads/media_player_test_py/venv/lib/python3.10/site-packages/PySide6/libpyside6.abi3.so.6.7
      #21 0x00007ffff62dcace in  () at /home/sebiai/Downloads/media_player_test_py/venv/lib/python3.10/site-packages/PySide6/Qt/lib/libQt6Core.so.6
      #22 0x00007ffff31fd3a0 in QShortcut::event(QEvent*) () at /home/sebiai/Downloads/media_player_test_py/venv/lib/python3.10/site-packages/PySide6/Qt/lib/libQt6Gui.so.6
      #23 0x00007ffff0b014f2 in QApplicationPrivate::notify_helper(QObject*, QEvent*) () at /home/sebiai/Downloads/media_player_test_py/venv/lib/python3.10/site-packages/PySide6/Qt/lib/libQt6Widgets.so.6
      #24 0x00007ffff627e18a in QCoreApplication::notifyInternal2(QObject*, QEvent*) () at /home/sebiai/Downloads/media_player_test_py/venv/lib/python3.10/site-packages/PySide6/Qt/lib/libQt6Core.so.6
      #25 0x00007ffff3202543 in QShortcutMap::dispatchEvent(QKeyEvent*) () at /home/sebiai/Downloads/media_player_test_py/venv/lib/python3.10/site-packages/PySide6/Qt/lib/libQt6Gui.so.6
      #26 0x00007ffff32031b8 in QShortcutMap::tryShortcut(QKeyEvent*) () at /home/sebiai/Downloads/media_player_test_py/venv/lib/python3.10/site-packages/PySide6/Qt/lib/libQt6Gui.so.6
      #27 0x00007ffff2e6881b in QWindowSystemInterface::handleShortcutEvent(QWindow*, unsigned long, int, QFlags<Qt::KeyboardModifier>, unsigned int, unsigned int, unsigned int, QString const&, bool, unsigned short) ()
          at /home/sebiai/Downloads/media_player_test_py/venv/lib/python3.10/site-packages/PySide6/Qt/lib/libQt6Gui.so.6
      #28 0x00007ffff2e071dd in QGuiApplicationPrivate::processKeyEvent(QWindowSystemInterfacePrivate::KeyEvent*) () at /home/sebiai/Downloads/media_player_test_py/venv/lib/python3.10/site-packages/PySide6/Qt/lib/libQt6Gui.so.6
      #29 0x00007ffff2e6477c in QWindowSystemInterface::sendWindowSystemEvents(QFlags<QEventLoop::ProcessEventsFlag>) () at /home/sebiai/Downloads/media_player_test_py/venv/lib/python3.10/site-packages/PySide6/Qt/lib/libQt6Gui.so.6
      #30 0x00007ffff091fcda in  () at /home/sebiai/Downloads/media_player_test_py/venv/lib/python3.10/site-packages/PySide6/Qt/plugins/platforms/../../lib/libQt6XcbQpa.so.6
      #31 0x00007ffff3c41d3b in g_main_context_dispatch () at /lib/x86_64-linux-gnu/libglib-2.0.so.0
      #32 0x00007ffff3c972b8 in  () at /lib/x86_64-linux-gnu/libglib-2.0.so.0
      #33 0x00007ffff3c3f3e3 in g_main_context_iteration () at /lib/x86_64-linux-gnu/libglib-2.0.so.0
      #34 0x00007ffff653576a in QEventDispatcherGlib::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) () at /home/sebiai/Downloads/media_player_test_py/venv/lib/python3.10/site-packages/PySide6/Qt/lib/libQt6Core.so.6
      #35 0x00007ffff6289963 in QEventLoop::exec(QFlags<QEventLoop::ProcessEventsFlag>) () at /home/sebiai/Downloads/media_player_test_py/venv/lib/python3.10/site-packages/PySide6/Qt/lib/libQt6Core.so.6
      #36 0x00007ffff628641e in QCoreApplication::exec() () at /home/sebiai/Downloads/media_player_test_py/venv/lib/python3.10/site-packages/PySide6/Qt/lib/libQt6Core.so.6
      #37 0x00007ffff15ddcbb in  () at /home/sebiai/Downloads/media_player_test_py/venv/lib/python3.10/site-packages/PySide6/QtWidgets.abi3.so
      #38 0x00005555556ac5c4 in  ()
      #39 0x000055555569d742 in _PyEval_EvalFrameDefault ()
      #40 0x0000555555694096 in  ()
      #41 0x0000555555789f66 in PyEval_EvalCode ()
      #42 0x00005555557b4e98 in  ()
      #43 0x00005555557ae79b in  ()
      #44 0x00005555557b4be5 in  ()
      #45 0x00005555557b40c8 in _PyRun_SimpleFileObject ()
      #46 0x00005555557b3d13 in _PyRun_AnyFileObject ()
      #47 0x00005555557a670e in Py_RunMain ()
      #48 0x000055555577cdfd in Py_BytesMain ()
      #49 0x00007ffff7c69d90 in __libc_start_call_main (main=main@entry=0x55555577cdc0, argc=argc@entry=2, argv=argv@entry=0x7fffffffda78) at ../sysdeps/nptl/libc_start_call_main.h:58
      #50 0x00007ffff7c69e40 in __libc_start_main_impl (main=0x55555577cdc0, argc=2, argv=0x7fffffffda78, init=<optimized out>, fini=<optimized out>, rtld_fini=<optimized out>, stack_end=0x7fffffffda68) at ../csu/libc-start.c:392
      #51 0x000055555577ccf5 in _start ()
      

      Attachments

        1. media_player_test_py.zip
          1 kB
        2. media_player_test_cpp.zip
          3 kB
        3. pyside2843.zip
          1 kB
        4. pyside2843_stack.txt
          56 kB
        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            kleint Friedemann Kleint
            sebiai Sebastian Aigner
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes