Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-118456

QtConcurrent::map freezes UI

    XMLWordPrintable

Details

    • Bug
    • Resolution: Duplicate
    • Not Evaluated
    • None
    • 6.4.2
    • Core: QtConcurrent
    • None
    • OS: Debian trixie/testing (latest)
      Kernel: 6.5.0-2-amd64
      DE: Xfce 4.18
      WM: Xfwm4
      CPU: AMD Ryzen 7 5800X (16) @ 3.800GHz
      GPU: NVIDIA GeForce RTX 3070
      Memory: 32012MiB
    • Linux/X11

    Description

      The following code freezes the main/UI thread:

      void MainWindow::on_pushButton_clicked()
      {
          QProgressDialog dlg(this);
      
          QVector<int> test;
          test.resize(1000);
      
          auto future = QtConcurrent::map(test, [](int& i)
          {
              QThread::msleep(1000);
          });
      
          dlg.exec();
          future.waitForFinished();
      }
      

      I would expect UI to be responsive while the worker threads are doing work (or sleeping in this example case). When the work finishes, the UI becomes responsive again. While it's not finished, the main/UI thread appears to be waiting to acquire some semaphore in drawing code:

      #0  syscall () at ../sysdeps/unix/sysv/linux/x86_64/syscall.S:38
      #1  0x00007ffff7468bb2 in QSemaphore::acquire(int) () at /lib/x86_64-linux-gnu/libQt6Core.so.6
      #2  0x00007ffff691cf8e in  () at /lib/x86_64-linux-gnu/libQt6Gui.so.6
      #3  0x00007ffff66566ce in  () at /lib/x86_64-linux-gnu/libQt6Gui.so.6
      #4  0x00007ffff6634f14 in  () at /lib/x86_64-linux-gnu/libQt6Gui.so.6
      #5  0x00007ffff6657adc in QRasterPaintEngine::drawLines(QLine const*, int) () at /lib/x86_64-linux-gnu/libQt6Gui.so.6
      ...

      (Full stacktrace: stacktrace.txt)

      There is no problem with a small number of elements in the vector (up to 15). Also, QtConcurrent::run and QtConcurrent::task work fine.

      The issue is not reproducible with Qt 5.15.10.

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            cnn Qt Core & Network
            miroslavr Miroslav R.
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes