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

QQuickWidget introduces VSync Latency to EventLoop

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • P2: Important
    • None
    • 5.5.1
    • Quick: Widget
    • None

    Description

      Hey all,

      I encountered a severe issue with QQuickWidget: It seems to introduce the VSync latency into the eventloop, thereby massively decreasing its throughput for other, GUI-unrelated operations. I have reproduced this issue on a Linux Laptop with the configuration described below.

      The attached minimal example triggers this behavior. It measures the eventloop throughput by measuring the time it takes to loop 10000 times via Qt::QueuedConnection.

      By default, the application shows just an empty QMainWindow. Adding a single CLI argument adds an empty QQuickWidget as central widget. Adding a second CLI argument adds a busy progress bar widget into the QMainWindow status bar. The timings for these three situations are as follows:

      onboard Intel GPU + vsync:
      empty: 34 ms elapsed for 10000 eventloops, i.e. 294.118 Hz (./eventloop_vsync)
      quick: 87 ms elapsed for 10000 eventloops, i.e. 114.943 Hz (./eventloop_vsync 1)
      quick+progress: 27590 ms elapsed for 10000 eventloops, i.e. 0.36245 Hz (./eventloop_vsync 1 2)

      onboard Intel GPU + vsync disabled via ~/.drirc:
      empty: 22 ms elapsed for 10000 eventloops, i.e. 454.545 Hz
      quick: 53 ms elapsed for 10000 eventloops, i.e. 188.679 Hz
      quick+progress: 62 ms elapsed for 10000 eventloops, i.e. 161.29 Hz

      dedicated NVidia GPU via primusrun:
      empty: 31 ms elapsed for 10000 eventloops, i.e. 322.581 Hz
      quick: 287 ms elapsed for 10000 eventloops, i.e. 34.8432 Hz
      quick+progress: 290 ms elapsed for 10000 eventloops, i.e. 34.4828 Hz

      For the Intel + vsync case with the abysmal performance I profiled the sleep time with perf, the results are shown in perf_sleep.txt. Note that this is against the system Qt and misses a few symbols, I'll redo this against a selfcompiled Qt with more debug symbols. But already it shows some culprits in the following backtrace, this time taken with GDB:

      #0  0x00007f57670df07f in pthread_cond_wait@@GLIBC_2.3.2 () from /usr/lib/libpthread.so.0
      #1  0x00007f576457ed39 in ?? () from /usr/lib/libxcb.so.1
      #2  0x00007f5764580497 in ?? () from /usr/lib/libxcb.so.1
      #3  0x00007f57645805a1 in xcb_wait_for_reply () from /usr/lib/libxcb.so.1
      #4  0x00007f5766872727 in _XReply () from /usr/lib/libX11.so.6
      #5  0x00007f5764c5439a in ?? () from /usr/lib/libGL.so.1
      #6  0x00007f5764c546d7 in ?? () from /usr/lib/libGL.so.1
      #7  0x00007f574f44d2ab in ?? () from /usr/lib/xorg/modules/dri/i965_dri.so
      #8  0x00007f574f44d7b1 in ?? () from /usr/lib/xorg/modules/dri/i965_dri.so
      #9  0x00007f574f43f4a0 in ?? () from /usr/lib/xorg/modules/dri/i965_dri.so
      #10 0x00007f5767abcab6 in QPlatformBackingStore::composeAndFlush(QWindow*, QRegion const&, QPoint const&, QPlatformTextureList*, QOpenGLContext*, bool) () from /usr/lib/libQt5Gui.so.5
      #11 0x00007f575e1dc907 in ?? () from /usr/lib/libQt5XcbQpa.so.5
      #12 0x00007f5768fad30b in ?? () from /usr/lib/libQt5Widgets.so.5
      #13 0x00007f5768fae146 in ?? () from /usr/lib/libQt5Widgets.so.5
      #14 0x00007f5768fb026f in ?? () from /usr/lib/libQt5Widgets.so.5
      #15 0x00007f5768fb043c in ?? () from /usr/lib/libQt5Widgets.so.5
      #16 0x00007f5768fce5ef in QWidgetPrivate::syncBackingStore() () from /usr/lib/libQt5Widgets.so.5
      #17 0x00007f5768fe57c8 in QWidget::event(QEvent*) () from /usr/lib/libQt5Widgets.so.5
      #18 0x00007f57690fb9fb in QMainWindow::event(QEvent*) () from /usr/lib/libQt5Widgets.so.5
      #19 0x00007f5768fa29ac in QApplicationPrivate::notify_helper(QObject*, QEvent*) () from /usr/lib/libQt5Widgets.so.5
      #20 0x00007f5768fa7e86 in QApplication::notify(QObject*, QEvent*) () from /usr/lib/libQt5Widgets.so.5
      #21 0x00007f5768bf8bab in QCoreApplication::notifyInternal(QObject*, QEvent*) () from /usr/lib/libQt5Core.so.5
      #22 0x00007f5768bfafa6 in QCoreApplicationPrivate::sendPostedEvents(QObject*, int, QThreadData*) () from /usr/lib/libQt5Core.so.5
      #23 0x00007f5768c4f143 in ?? () from /usr/lib/libQt5Core.so.5
      #24 0x00007f5766bbbdc7 in g_main_context_dispatch () from /usr/lib/libglib-2.0.so.0
      #25 0x00007f5766bbc020 in ?? () from /usr/lib/libglib-2.0.so.0
      #26 0x00007f5766bbc0cc in g_main_context_iteration () from /usr/lib/libglib-2.0.so.0
      #27 0x00007f5768c4f54f in QEventDispatcherGlib::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) () from /usr/lib/libQt5Core.so.5
      #28 0x00007f5768bf657a in QEventLoop::exec(QFlags<QEventLoop::ProcessEventsFlag>) () from /usr/lib/libQt5Core.so.5
      #29 0x00007f5768bfe53c in QCoreApplication::exec() () from /usr/lib/libQt5Core.so.5
      

      Is there any way to prevent QQuickWidget from introducing the VSync delay into the eventloop?

      Attachments

        1. eventloop_vsync.tar.bz2
          1.0 kB
        2. glxinfo_nvidia.txt
          40 kB
        3. glxinfo.txt
          24 kB
        4. perf_sleep.txt
          6 kB
        5. Screenshot_20191120_115941.png
          Screenshot_20191120_115941.png
          267 kB
        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            lagocs Laszlo Agocs
            milianw Milian Wolff
            Votes:
            2 Vote for this issue
            Watchers:
            9 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes