How to reproduce:
- Run my code
- Keep the mouse over the window that appears
You'll see that CPU usage is fairly high, although it will depend on your hardware. On my PC it's 20% (5% in each of the 4 virtual cores).
My motivation for this testcase: in my real app I have a lot of invisible (culled) items, and while that the culling helps a lot with the CPU usage, it doesn't help as much as I'd expect.
I'd like ideas on why the CPU usage is so high, and how to reduce it.
My code:
main.qml:
import QtQuick 2.5
import QtQuick.Window 2.2
Window {
visible: true
width: 800
height: 500
MouseArea {
width: 1
height: 1
hoverEnabled: true
}
AnimatedItem {
anchors.centerIn: parent
width: 100
height: 100
}
Repeater {
model: 8000
Item {
opacity: 0
layer.enabled: true
width: 1
height: 1
}
}
}
AnimatedItem.qml:
import QtQuick 2.0
Rectangle {
id: root
color: "black"
property real rotAngle: 0
NumberAnimation on rotAngle {
from: 0
to: 360
loops: Animation.Infinite
running: true
duration: 500
}
transform: Rotation {
origin.x: root.width / 2
origin.y: root.height / 2
angle: root.rotAngle
}
}
I've profiled it with the QML profiler, which has shown that insignificant time is spent in QML. So I've also profiled with a C++ profiler (CodeXL). It reports that the majority of time is spent in QSGRootNode::~QSGRootNode()
, due to it calling QSGNodeUpdater::isNodeBlocked(QSGNode*, QSGNode*) const
. I've looked at the Qt source but haven't been able to figure out why it's even calling the former.