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

QPainter debug builds on Windows very slow

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • P3: Somewhat important
    • None
    • 5.14.2, 5.15.2, 6.0
    • GUI: Painting
    • None
    • Windows

    Description

      QPainter on Linux is fine. Performance on debug and release builds are almost the same.
      On Windows using Qt 6.0 with MSVC 16.8.3 64bit complier (MSVC 2019) QPainter debug builds are about 8 times slower than release builds.

      That can be shown using the Qt Creator example application "Chip". Linux debug and release builds starts right away, the same does Windows release build. But Windows debug build needs about 8 seconds before the application window shows up.

      The issue can be shown also running the following QPainter animation test application (the project is attached below):

      #include <QApplication>
      #include <QWidget>
      #include <QPainter>
      #include <QElapsedTimer>
      
      class Widget : public QWidget
      {
      public:
          Widget();
      
      protected:
          void timerEvent(QTimerEvent*);
          void paintEvent(QPaintEvent*);
      
      private:
          QElapsedTimer elapsedTimer;
          int timerId;
          int elapsedTime = 0;
          bool isFinished = false;
          double i=0.0, x=40.0, y=0.0, y2=30.0;
          QPen Pen = QPen(QColor(0,0,0), 8);
          QFont Font = QFont("Arial", 14);
      };
      
      Widget::Widget()
      {
          setAutoFillBackground(true);
          setPalette(Qt::white);
      
          timerId = startTimer(1);
          elapsedTimer.start();
      }
      
      void Widget::timerEvent(QTimerEvent*)
      {
          update();
      }
      
      void Widget::paintEvent(QPaintEvent*)
      {
          QPainter painter(this);
      
          if (i >= 0 && i < 3770) {
              y = 30.0;
              painter.setPen(Pen);
              painter.drawLine(x-20.0, y,       x+92.0, y);
              painter.drawLine(x-20.0, y+570.0, x+92.0, y+570.0);
      
              for (int j=0; j < 550; j=j+30) {
                  painter.drawEllipse(x-40.0, y2+j, 30.0, 30.0);
                  painter.drawEllipse(x+85.0, y2+j, 30.0, 30.0);
              }
      
              painter.setFont(Font);
              painter.drawText(x, y += 20.0, "");
              painter.drawText(x, y += 20.0, "QPainter");
              painter.drawText(x, y += 20.0, "MSVC");
              painter.drawText(x, y += 20.0, "16.8.3");
              painter.drawText(x, y += 20.0, "debug");
              painter.drawText(x, y += 20.0, "builds");
              painter.drawText(x, y += 20.0, "run");
              painter.drawText(x, y += 20.0, "8");
              painter.drawText(x, y += 20.0, "times");
              painter.drawText(x, y += 20.0, "slower");
              painter.drawText(x, y += 20.0, "on");
              painter.drawText(x, y += 20.0, "Windows");
              painter.drawText(x, y += 20.0, "than");
              painter.drawText(x, y += 20.0, "release");
              painter.drawText(x, y += 20.0, "builds");
              painter.drawText(x, y += 20.0, "using");
              painter.drawText(x, y += 20.0, "Qt 6.0");
              painter.drawText(x, y += 20.0, "");
              painter.drawText(x, y += 20.0, "Prior");
              painter.drawText(x, y += 20.0, "Qt");
              painter.drawText(x, y += 20.0, "versions");
              painter.drawText(x, y += 20.0, "run");
              painter.drawText(x, y += 20.0, "only");
              painter.drawText(x, y += 20.0, "little");
              painter.drawText(x, y += 20.0, "faster");
              painter.drawText(x, y += 20.0, "on");
              painter.drawText(x, y += 20.0, "Windows");
              painter.drawText(x, y += 20.0, "");
              painter.drawText(x, y += 20.0, "");
              x = x + 0.2;
      
              elapsedTime = elapsedTimer.elapsed();
          }
          else {
              isFinished = true;
          }
          i++;
      
          if (isFinished) {
              painter.setFont(QFont("Arial", 14, QFont::Bold));
              painter.drawText(QPoint(320, 280), "Elapsed time: " + QString::number(elapsedTime/1000.0) + QString(" seconds"));
          }
      }
      
      int main(int argc, char *argv[])
      {
          QApplication app(argc, argv);
          Widget widget;
          widget.resize(900,640);
          widget.show();
          return app.exec();
      }
      

      The animation finishes:

      Linux debug and release build:
      Qt 5.12.2 to Qt 6.0 -> about 4.4 seconds
      (almost no difference between debug and release build)

      Windows release build:
      Qt 5.12.2 to Qt 6.0 -> 8.5 - 9.5 seconds (later Qt versions slightly faster)

      Windows debug build:
      Qt 5.12.2 to Qt 5.13.2 -> 30 seconds
      Qt 5.14.2 to Qt 5.15.2 -> 40 seconds
      Qt 6.0 -> 70 seconds!

      Attachments

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

        Activity

          People

            vgt Eirik Aavitsland
            mireiner Chris
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes