Results 1 to 6 of 6

Thread: Slow Graphics since Qt 5.6.0

  1. #1
    Join Date
    Feb 2015
    Posts
    14
    Thanks
    1
    Qt products
    Qt5
    Platforms
    Windows

    Default Slow Graphics since Qt 5.6.0

    Hi there,

    the problem:
    The graphic animations of the same Qt application are running on Qt 5.4.2, Qt 5.5.0 and Qt 5.5.1 just fine. But on Qt 5.6.0, Qt 5.6.1 and Qt 5.7.0 at minimum 100% slower. No matter if MinGW 32 bit or Microsoft 32 or 64 bit compiler is used.

    Setup:
    Processor: Intel Core 2 Duo E8400 @ 3.00GHz
    RAM: 8GB
    Graphicscard: ATI Radeon HD 3600 - Directx 10.1 (non gamer card)
    Operating System: Windows 10 64 bit (no enviroment variable set for Qt)
    IDE: Qt Creator
    Qt Windows Desktop Application 32 and 64bit.
    Graphic Animations run on QWidget with QPainter and 100x drawText() and 400x drawLine() functions.
    Animations are started with mouse click and hold on QPushbutton with autorepeat=true and "autorepeatinterval"=0

    I tried to isolate the problem to a specific part of the application without success. If QPainter::drawText() is disabled in the full application, then it seams the speed is there again. But if I program a small test application with massiv use of QPainter::drawText() only, there is no slow down between the different Qt versions.

    It's hard for me to understand on what graphics driver my Qt application is running on Windows 10 (ANGLE or OpenGL?). So eventually there might be the problem. Because I did not change anything in my Qt application when testing the obove mentioned Qt versions. Should I have done that? For example set an Windows enviroment variable oder an entry in project file (*.pro)?

    Does anybody know what the problem might be, or provide tips how to find the issue?
    Last edited by mireiner; 16th June 2016 at 21:41.

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Slow Graphics since Qt 5.6.0

    Try profiling your app to see where the bottleneck is.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  3. #3
    Join Date
    Feb 2015
    Posts
    14
    Thanks
    1
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: Slow Graphics since Qt 5.6.0

    Hi wysota,

    I found the bug. It's in QPainter:drawText() but only in combination with QPainter::setFont(). The following code runs two tests. A Windows 10 desktop application build with Qt 5.4.2, Qt 5.5.0 and Qt 5.5.1 will execute both tests with the same speed in debug mode. But build with Qt 5.6.0, Qt 5.6.1 or Qt 5.7.0 Test2 takes about 9 times longer than Test1!

    Qt Code:
    1. #include <QApplication>
    2. #include <QWidget>
    3. #include <QPainter>
    4. #include <QElapsedTimer>
    5.  
    6. class Widget : public QWidget
    7. {
    8. public:
    9. Widget();
    10.  
    11. protected:
    12. void timerEvent(QTimerEvent*);
    13. void paintEvent(QPaintEvent*);
    14.  
    15. private:
    16. QElapsedTimer elapsedTimer;
    17. int timerId;
    18. int elapsedTime1, elapsedTime2;
    19. bool isFinished1, isFinished2, isFinished3;
    20. int i, x1, x2, y1, y2;
    21. };
    22.  
    23. Widget::Widget()
    24. {
    25. setAutoFillBackground(true);
    26. setPalette(Qt::white);
    27.  
    28. timerId = startTimer(1);
    29. elapsedTimer.start();
    30.  
    31. i=0; x1=0; x2=0;
    32. isFinished1 = isFinished2 = isFinished3 = false;
    33. }
    34.  
    35. void Widget::timerEvent(QTimerEvent*)
    36. {
    37. update();
    38. }
    39.  
    40. void Widget::paintEvent(QPaintEvent*)
    41. {
    42. QPainter painter(this);
    43.  
    44. if (i > 0 && i < 800)
    45. {
    46. // 'Test1' runs about 9 times faster than 'Test2' on Qt 5.6.0, Qt 5.6.1 and Qt 5.7.0
    47.  
    48. y1 = 10;
    49. painter.setFont(QFont("Arial", 14));
    50. painter.drawText(x1, y1 += 30, "Test 1");
    51. painter.drawText(x1, y1 += 30, "row 01");
    52. painter.drawText(x1, y1 += 30, "row 02");
    53. painter.drawText(x1, y1 += 30, "row 03");
    54. painter.drawText(x1, y1 += 30, "row 04");
    55. painter.drawText(x1, y1 += 30, "row 05");
    56. painter.drawText(x1, y1 += 30, "row 06");
    57. painter.drawText(x1, y1 += 30, "row 07");
    58. painter.drawText(x1, y1 += 30, "row 08");
    59. painter.drawText(x1, y1 += 30, "row 09");
    60. painter.drawText(x1, y1 += 30, "row 10");
    61. painter.drawText(x1, y1 += 30, "row 11");
    62. painter.drawText(x1, y1 += 30, "row 12");
    63. x1++;
    64.  
    65. elapsedTime1 = elapsedTimer.elapsed();
    66. }
    67. else if (i > 800 && i < 1600)
    68. {
    69. // 'Test2' takes about 9 times longer than 'Test1' on Qt 5.6.0, Qt 5.6.1 and Qt 5.7.0
    70.  
    71. isFinished1 = true;
    72.  
    73. y2 = 300;
    74. painter.setFont(QFont("Arial", 14));
    75. painter.drawText(x2, y2 += 30, "Test 2");
    76. painter.setFont(QFont("Caladea", 14));
    77. painter.drawText(x2, y2 += 30, "row 01");
    78. painter.setFont(QFont("Tomaha", 14));
    79. painter.drawText(x2, y2 += 30, "row 02");
    80. painter.setFont(QFont("Consolas", 14));
    81. painter.drawText(x2, y2 += 30, "row 03");
    82. painter.setFont(QFont("Calibri", 14));
    83. painter.drawText(x2, y2 += 30, "row 04");
    84. painter.setFont(QFont("Impact", 14));
    85. painter.drawText(x2, y2 += 30, "row 05");
    86. painter.setFont(QFont("Courier New", 14));
    87. painter.drawText(x2, y2 += 30, "row 06");
    88. painter.setFont(QFont("Gorgia", 14));
    89. painter.drawText(x2, y2 += 30, "row 07");
    90. painter.setFont(QFont("Verdana", 14));
    91. painter.drawText(x2, y2 += 30, "row 08");
    92. painter.setFont(QFont("Times New Roman", 14));
    93. painter.drawText(x2, y2 += 30, "row 09");
    94. painter.setFont(QFont("Microsoft Sans Serif", 14));
    95. painter.drawText(x2, y2 += 30, "row 10");
    96. painter.setFont(QFont("Segoe UI", 14));
    97. painter.drawText(x2, y2 += 30, "row 11");
    98. painter.setFont(QFont("Trebuchet MS", 14));
    99. painter.drawText(x2, y2 += 30, "row 12");
    100. x2++;
    101.  
    102. elapsedTime2 = elapsedTimer.elapsed();
    103. }
    104. else if (i > 1600)
    105. {
    106. isFinished2 = true;
    107. }
    108. i++;
    109.  
    110. if (isFinished1)
    111. {
    112. painter.setFont(QFont("Arial", 12, QFont::Bold));
    113. painter.drawText(QPoint(200, 150), "'Test1' elapsed time in seconds: " + QString::number(elapsedTime1/1000.0));
    114. }
    115. if (isFinished2)
    116. {
    117. painter.drawText(QPoint(200, 430), "'Test2' elapsed time in seconds: " + QString::number((elapsedTime2-elapsedTime1)/1000.0));
    118. isFinished3 = true;
    119. }
    120. if (isFinished3)
    121. {
    122. painter.setFont(QFont("Arial", 11));
    123. painter.drawText(QPoint(200, 620), "On Windows Desktop with Qt 5.4.2, Qt 5.5.0 and Qt 5.5.1 Test1 and Test2 are both equally fast.");
    124. painter.drawText(QPoint(200, 650), "On Windows Desktop with Qt 5.6.0, Qt 5.6.1 and Qt 5.7.0 Test2 is approx 9 times slower than Test1 !");
    125. painter.drawText(QPoint(200, 680), "No matter if compiled with MinGW 32bit or MSVC 32 or 64bit");
    126. killTimer(timerId);
    127. }
    128. }
    129.  
    130. int main(int argc, char *argv[])
    131. {
    132. QApplication app(argc, argv);
    133. Widget widget;
    134. widget.showMaximized();
    135. return app.exec();
    136. }
    To copy to clipboard, switch view to plain text mode 
    Did you know how to report a bug report to the Qt developer team? Never did that before. Can you help me with this?
    Last edited by mireiner; 17th June 2016 at 12:17.

  4. #4
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Slow Graphics since Qt 5.6.0

    Qt has an open bug tracker at https://bugreports.qt.io/secure/Dashboard.jspa

    Cheers,
    _

  5. #5
    Join Date
    Feb 2015
    Posts
    14
    Thanks
    1
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: Slow Graphics since Qt 5.6.0

    Hi anda_skoa,

    thanks for the link. So I reported this bug on the site you mentioned:
    (QTBUG-54180) https://bugreports.qt.io/browse/QTBU...%3AdrawText%22

    But the first reaction is a bit funny. It seams they didn't even test my short example code and write it's normal that this code runs so slow. Nevertheless I reported that all earlier Qt version prior v5.6.0 ran this code fast and only the newer Qt versions 5.6.0 and later got this massiv slow down with this example code.
    Last edited by mireiner; 17th June 2016 at 15:45.

  6. #6
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Slow Graphics since Qt 5.6.0

    The developer probably focused too much on the title, which doesn't include that it become slower between versions.

    I would recommend to post your numbers.
    Instead of drawing the elapsed time write it to qDebug() or similar and paste edit the report to contian these for a good and a bad version.

    Cheers,
    _

Similar Threads

  1. graphics
    By nabeel in forum Qt Programming
    Replies: 0
    Last Post: 5th September 2013, 13:08
  2. Qt-Graphics
    By grsandeep85 in forum Qt Programming
    Replies: 3
    Last Post: 30th October 2009, 09:33
  3. Qt Graphics
    By soumya in forum Qt Programming
    Replies: 1
    Last Post: 27th October 2009, 09:41
  4. 3D graphics
    By impeteperry in forum Qt Programming
    Replies: 3
    Last Post: 19th July 2009, 08:00
  5. graphics view slow
    By dognzhe in forum Qt Programming
    Replies: 16
    Last Post: 11th May 2009, 17:36

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.