Qt application lags and xorg uses a lot of CPU

1.1k Views Asked by At

I've encountered some problems with my Qt application which is very slow and laggy. Originally it was developed on another machine than I am using now, and it seemed to work fine there. Now, I can see that the CPU load of the xorg process is quite high (>25%) when I start the application although it's barely doing anything.

I'm using two QGLWidgets for drawing 2D graphics at a framerate of 25fps. The way I do it is by overloading the paintEvent() function. I've read that there are cases where this function produces an infinite loop e.g. when creating new objects within the function. I've tried reducing the code to the minimum but the problem still exists:

void GLMonitor::paintEvent(QPaintEvent *event)
{
    QPainter painter;
    painter.begin(this);
    painter.setRenderHint(QPainter::Antialiasing);
    //aerpainter->paint(&painter, event, elapsed);
    painter.end();
}

It's not painting anything (as it should because I commented out aerpainter->paint()) but xorg is still at 25% CPU load and the GUI is slow.

The timeout signal of a timer (with a 25Hz period) is connected to the following slot which should trigger the paintEvent as it is done in one of the Qt examples:

void GLMonitor::animate()
{
    elapsed = (elapsed + qobject_cast<QTimer*>(sender())->interval()) % 1000;
    repaint();
}

Here are some other observations that might be related to problem:

  • There are a lot of kworker and migration processes that also use quite a lot of CPU (summed up it's around 10%-30%).

  • I've tested the app on the original machine where it works fine but i've noticed that not xorg but compiz has high CPU load (around 80%) even when it's not painting anything...

UPDATE: I just realized that other Qt applications like the 2dpainting demo also lag when I increase fps, even when I comment out the painting code (like it is shown above). So they whole issue might be related to my system...?

0

There are 0 best solutions below