Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. QML Timer Component in Qt5 has a very slow perfomance
Forum Updated to NodeBB v4.3 + New Features

QML Timer Component in Qt5 has a very slow perfomance

Scheduled Pinned Locked Moved QML and Qt Quick
12 Posts 3 Posters 8.4k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • E Offline
    E Offline
    epicfailguy93
    wrote on 9 Jan 2013, 12:52 last edited by
    #1

    This works well in Qt 5 Alpha and Qt 5 Beta 1, but since Beta 2 timers aren't working as they should. You can see this for yourself with a simple example:
    @import QtQuick 2.0

    Rectangle {
    width: 360
    height: 360
    property int count: 0
    Text {
    anchors.centerIn: parent
    text: count
    }
    Timer {
    interval: 10
    repeat: true
    running: true
    onTriggered: count++
    }
    }
    @
    So, I mean, that timers work well, if the interval is set higher than 100 milliseconds, but if this value is less, you'll get slow reaction (this is right for Windows 7 x64 platform).
    I'm writing a game in which physics has to be updated with high frequency. What can I do? Try to write my own Timer component and make it into a separate thread? Any ideas?

    1 Reply Last reply
    0
    • W Offline
      W Offline
      weiyuemin
      wrote on 9 Jan 2013, 13:05 last edited by
      #2

      You can try this:
      @
      import QtQuick 2.0

      Rectangle {
          width: 360
          height: 360
          property int count: 0
          Text {
              anchors.centerIn: parent
              id: t
          }
          Timer {
              interval: 10
              repeat: true
              running: true
              onTriggered: {
                 count++
                 if (count % 100 == 0) {
                     t.text = count;
                 }
              }
          }
      }
      

      @

      It means that not the Timer has slow perfomance, but the Text has slow performance

      1 Reply Last reply
      0
      • W Offline
        W Offline
        weiyuemin
        wrote on 9 Jan 2013, 13:13 last edited by
        #3

        Yes, when comment the if:
        @
        //if (count % 100 == 0) {
        t.text = count;
        }
        @
        the code will works well in QtQuick 1.1, but obviously slow in QtQuick 2.0

        1 Reply Last reply
        0
        • E Offline
          E Offline
          epicfailguy93
          wrote on 9 Jan 2013, 13:29 last edited by
          #4

          Anyway, it's just a simple example. In my project I have a javascript-handler for calculating the positions of bodies (lightweight, because the playing field is a set of cells), and now, with the new version of Qt, it has become impossible slow. It will be very bad if the code can not be fixed and now it has actually become useless :/

          1 Reply Last reply
          0
          • E Offline
            E Offline
            epicfailguy93
            wrote on 9 Jan 2013, 14:41 last edited by
            #5

            Just look at this... facepalm
            @import QtQuick 2.0

            Rectangle {
            width: 360
            height: 360
            Rectangle {
            id: rect
            width: 100
            height: 100
            color: "green"
            }
            Timer {
            interval: 1
            repeat: true
            running: true
            onTriggered: rect.x++
            }
            }
            @

            1 Reply Last reply
            0
            • W Offline
              W Offline
              weiyuemin
              wrote on 9 Jan 2013, 16:58 last edited by
              #6

              I still think it's other component have slow performance in Qt 5, not the timer.

              I modified your code:
              @
              import QtQuick 2.0

              Rectangle {
              width: 360
              height: 360
              Rectangle {
              id: rect
              width: 100
              height: 100
              color: "green"
              }
              Timer {
              interval: 1
              repeat: true
              running: true
              property int count: 0
              onTriggered: {
              count ++;
              if (count == 1000)
              {
              rect.x += 100;
              count = 0;
              }
              }
              }
              }
              @

              The timer triggers 1000 times per second, and the rectangle moves once per second (by eye).

              1 Reply Last reply
              0
              • E Offline
                E Offline
                epicfailguy93
                wrote on 9 Jan 2013, 19:58 last edited by
                #7

                OK, you're right. Now the question remains - why rendering in QtQuick 2.0 so slow? That was broken in the Beta 2 release?

                1 Reply Last reply
                0
                • C Offline
                  C Offline
                  chrisadams
                  wrote on 10 Jan 2013, 01:25 last edited by
                  #8

                  Hi,

                  This is a serious issue, but one that I don't know much about (because I think it's scenegraph related). I haven't reproduced it (I don't have a windows machine), so are you able to provide me with some information:

                  Does rendering take a long time (ie, the actual opengl draw calls), or is the timer not being triggered correctly? From weiyuemin's last post, it seems like the timer is being triggered fine (which suggests that whatever is taking so long, is not blocking the event loop of the main thread). Most likely, stuff going on in the render thread is the culprit here. What sort of GPU do you have, and which drivers are you using? Are you using ANGLE or do you support OpenGL directly?

                  Please file a bug, including all relevant information plus the minimal test case, and assign it to Gunnar Sletta or Samuel Rodal.

                  Cheers,
                  Chris.

                  1 Reply Last reply
                  0
                  • W Offline
                    W Offline
                    weiyuemin
                    wrote on 10 Jan 2013, 02:16 last edited by
                    #9

                    Mine:
                    NVIDIA GeForce GTX 550 Ti
                    Version 6.14.13.1090 (2012-12-29)

                    1 Reply Last reply
                    0
                    • W Offline
                      W Offline
                      weiyuemin
                      wrote on 10 Jan 2013, 02:20 last edited by
                      #10

                      I don't know about ANGLE, and I can play new games normally, it should support OpenGL directly, I think.

                      1 Reply Last reply
                      0
                      • C Offline
                        C Offline
                        chrisadams
                        wrote on 10 Jan 2013, 10:01 last edited by
                        #11

                        Wow, ok, it's not a GPU issue then.
                        This is looking like it's due to ANGLE. I believe it is used by default on Windows, according to http://lists.qt-project.org/pipermail/development/2012-October/007445.html

                        See http://blog.qt.digia.com/blog/2012/10/24/graphics-on-windows-from-a-different-angle/ for more information.

                        Using a profiler to find out what's happening would be useful information, if you can do that, too.

                        Cheers,
                        Chris.

                        1 Reply Last reply
                        0
                        • E Offline
                          E Offline
                          epicfailguy93
                          wrote on 10 Jan 2013, 13:57 last edited by
                          #12

                          Guys I just installed Kubuntu 12.10 with KDE 4.9.3 and checked my code. It's awesome! No lags, no slowdowns, I'm so glad!

                          1 Reply Last reply
                          0

                          1/12

                          9 Jan 2013, 12:52

                          • Login

                          • Login or register to search.
                          1 out of 12
                          • First post
                            1/12
                            Last post
                          0
                          • Categories
                          • Recent
                          • Tags
                          • Popular
                          • Users
                          • Groups
                          • Search
                          • Get Qt Extensions
                          • Unsolved