Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

High CPU usage with basic QML animation



  • Hello,

    I was seeing bad performance and high cpu usage in my QML based apps, as much as 50-100% on iOS (device or simulator), and even desktop. After optimising my code as much as I could, I decided to write the simplest possible animated app to isolate the root cause.

    Strangely, even with just a rotating label, I still get 17-20% cpu usage consistently. My ObjC based native iOS app which rotates a png image barely registers above 1% cpu usage. There isn't much code (see below) to profile, and I am not able to make sense of tracing the compiled app using Instruments.

    Any help will be appreciated.

    Code below:

    import QtQuick 2.5
    import QtQuick.Window 2.2
    
    Window {
        visible: true
    
        MouseArea {
            anchors.fill: parent
            onClicked: {
                Qt.quit();
            }
        }
    
        Text {
            text: qsTr("Hello World")
            anchors.centerIn: parent
            NumberAnimation on rotation {
                from: 0
                to: 360
                duration: 4000
                loops: Animation.Infinite
            }
        }
    }
    
    


  • I have the same problem.
    Help.



  • Years later, CPU usage of animations is still a problem. Getting 70% CPU wasted on rotating Shape and animating its PathAngleArc's startAngle and sweepAngle.



  • Hi @ratijas ,
    I don't get significant high CPU values running at least simple animations. Can you provide a sample code and some clarifications about your setup?
    I'am using PySide (Python Qt binding) on my side. I have never tried using QML with C++.



  • I created a small test case to display a GIF file and it uses about 10%CPU. The root cause is that it runs too fast?
    If a loop over call of a func which does almost nothing can use a lot of CPU.


Log in to reply