Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-99525

High CPU usage on iOS during animations

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: P3: Somewhat important
    • Resolution: Out of scope
    • Affects Version/s: 5.15.8, 6.2.2
    • Fix Version/s: None
    • Component/s: Quick: SceneGraph
    • Labels:
      None
    • Environment:
      iPhone X, iPhone 13 Pro, iOS 15.2, xCode 13
      MacBook Pro with Intel 8 Core CPU, macOS 15.1.
    • Platform/s:
      iOS/tvOS/watchOS, macOS

      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
                  }
              }*/
          }
      }
      

        Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

          Activity

            People

            Assignee:
            janichol Andy Nichols
            Reporter:
            Harald Meyer Harald Meyer
            Votes:
            1 Vote for this issue
            Watchers:
            1 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:

                Gerrit Reviews

                There are no open Gerrit changes