High cpu usage
-
Hello,
I have a problem where my QML program starts to consume more and more cpu. I used the QML profiler, and found no problems. So I started to look into some of the QSG_ and QML_ environment variables and found an option that fixes the cpu usage:
export QT_OPENGL_NO_SANITY_CHECK=1
This is apparently almost the same as using this:
export QSG_RENDER_LOOP=threaded
and makes use of the "threaded" rendering loop. This fixes my case, however, after a short amount of time, like 5 minutes or so, my application totally hangs in the GUI thread, waiting for an event to happen it seems.
If I use the other threading loop types, either the "basic" or "windows" ones, I don't have the lockup, but the CPU usage just keeps increasing slowly, without getting stable, so it becomes unuseable after a while of course.
I am using the following system:
- Linux kernel 4.2.8-ckt10 from ubuntu wily
- xorg 1.18.2
- Qt 5.6.0
- Intel HD Graphics 5500
- Mesa 11.2.1
I also tried with Qt 5.7.0 and it has the same problem. Also I have tried setting the system to not use the sg animation driver:
export QSG_FIXED_ANIMATION_STEP=yes
but that did not help either.
I also checked that "glxgears" ran at 60 FPS so that my vsync is working, and it was ok.
The thing is that I use the QtQuick.Windows library and I have 2 extra windows besides my main window, all created from within QML with "Window" items. So maybe it has something to do with this I don't know.
Does anyone have a clue what could be the main issue here?
-
I have found a simple QML file which illustrates the problem. The problem occurs with the intel driver, and when using animations in multiple windows. See this code below which you can run with "qmlscene".
So when one of the 2 numberanimations is commented out, there is no increase in cpu usage. It doesn't matter which one! But when they both are active, you get high cpu usage. With proprietary nvidia drivers, it seems I don't get the problem.
import QtQuick 2.2 import QtQuick.Window 2.0 Window { title: qsTr("Two Window Testcase - Window 1") width: 640 height: 480 visible: true Rectangle { id: r1 x: 50 y: 50 width: 75 height: 75 color: "red" } NumberAnimation { loops: Animation.Infinite from: 100 to: 400 running: true target: r1 property: "width" } Window { title: qsTr("Two Window Testcase - Window 2") width: 640 height: 480 visible: true Rectangle { id: r x: 100 y: 100 width: 200 height: 200 color: "green" } NumberAnimation { loops: Animation.Infinite from: 100 to: 400 running: true target: r property: "width" } } }
-
Is there someone who can give me a clue on how I can disable ALL animations in qml?
-
The solution is:
export QSG_RENDER_LOOP=threadedand in your own Qt application, set the init threads attribute:
QCoreApplication::setAttribute(Qt::AA_X11InitThreads);
This was a really annoying bug. Apparently X11 is used in some way. I thought Qt was only using xcb nowadays?
So with qmlscene it can not be solved I think, you need your own application so you can set the attribute, BEFORE creating the QGuiApplication object!