Details
-
Bug
-
Resolution: Out of scope
-
P3: Somewhat important
-
None
-
5.15.8, 6.2.2
-
None
-
iPhone X, iPhone 13 Pro, iOS 15.2, xCode 13
MacBook Pro with Intel 8 Core CPU, macOS 15.1.
Description
Running animations (using timers or using animators) on macOS and iOS yield high CPU usage even for simple animations, such as the rotation of a Rectangle. Depending on the phone model the CPU usage is between 5% to 12% on iOS and between 5% to 8% on my MacBook Pro. This happens for both, OpenGL and Metal backends.
This is a real problem on iOS because it significantly drains the battery for simple things, such as a compass animation (when the screen is kept on). For instance using a native Objective-C app the battery is drained only by 10% per hour, using similar animations with a Qt app drains the battery by 90%!
A similar problem has been reported here: https://forum.qt.io/topic/64924/high-cpu-usage-with-basic-qml-animation/5
The same animations use less than 1% CPU on a Windows machine. I could not exactly determine the CPU usage on Android but measurements show approximately 1%-3% on Android.
import QtQuick 2.15 import QtQuick.Controls 2.15 ApplicationWindow { width: 640 height: 480 visible: true title: qsTr("Test") /* Timer { repeat: true interval: 30 running: true onTriggered: rect.rotation = (rect.rotation+1)%360 } */ Rectangle { id: rect width: 100 height: 100 anchors.centerIn: parent color: "red" NumberAnimation on rotation { from: 0 to: 360 duration: 4000 loops: Animation.Infinite } /* Behavior on rotation { enabled: true RotationAnimation { direction: RotationAnimation.Shortest duration: 100 easing.type: Easing.Linear } }*/ } }