Menu

#370 Buggy Qt Raster paint engine with Qt6

None
closed
nobody
None
5
2025-04-15
2023-11-29
Anonymous
No

Hello,

I had some code working with Qwt 6.1.5 and Qt 5.14.2.
I migrated my code to Qwt 6.2.0 and Qt 6.2.2.

Then, a piece of my code drawing data with Qwt started being very slow. I investigated and I finally concluded that QwtPlotCurve::drawCurve used to take 6ms with previous version and now takes more than 6s! (1000 times slower!).

The issue only occures when a huge amount of black area is to be shown. I mean if I random data between [0,1] and draw the data with a [0,100] scale axis (then the drawing points fills only the bottom part of the screen), it's drawn very fast with both old and new versions. However, if the axis scale is [0,1] (then the drawing points fills all the space), then drawing takes a while with Qwt 6.2.0/Qt 6.2.2 (draws fast with Qwt 6.1.5/Qt 5.14.2).

I could isolate the problem with the small sample program attached. I t simply generated 5000 random data between [0,1] and plot them.

I tracked down the two versions with a debugger and concluded that qwtDrawPolyline is the function that takes a while to run. It used to call many times QPainter::drawPolyline, it now calls it once only. The beginning of the function mentions a bug with Qt raster paint engine and does:

// work around a bug with short lines below 2 pixels difference
// in height and width
doSplit = qwtIsRasterPaintEngineBuggy();

qwtIsRasterPaintEngineBuggy returns true/false depending on Qt versions, it handles some Qt5 versions where bug was either present or absent I suppose and needs to be workarounded.
For Qt6, the functions returns false, meaning there is not bug to be workarounded, so doSplit is set to false and a single call to QPainter::drawPolyline can be "safely" done....but Qt6 (at least 6.2.2) definitely has the bug. I tried, making qwtIsRasterPaintEngineBuggy resturn true fixes the issue, latest version is able to draw the data in less than 10ms!

You may want to modify qwtIsRasterPaintEngineBuggy and return true for Qt6 in the next version of Qwt.

Kind regards,
Jean Porcherot

1 Attachments

Discussion

  • Uwe Rathmann

    Uwe Rathmann - 2023-12-03

    Actually I would expect that QwtPainter::setPolylineSplitting en/disables the splitting of polygons and only the initial setting is found by analyzing the paint engine. However this is not what the implementation is doing.

    I need to investigate the history of this workaround and will probably restore the behavior of Qwt 6.1.

     
  • Uwe Rathmann

    Uwe Rathmann - 2024-03-13

    Done in develop ( will be available in Qwt 6.3.x )

     
  • Uwe Rathmann

    Uwe Rathmann - 2024-03-13
    • status: open --> closed
    • Group: -->
     
  • Jean Porcherot

    Jean Porcherot - 2025-04-15

    Just updated my environment to migrate to Qt 6.9 and Qwt 6.3.0 and I can now confirm it's fixed for good.

    Thanks a lot for this great library,
    Jean

     

Anonymous
Anonymous

Add attachments
Cancel