QML Timer Component in Qt5 has a very slow perfomance
-
wrote on 9 Jan 2013, 12:52 last edited by
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.0Rectangle {
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? -
wrote on 9 Jan 2013, 13:05 last edited by
You can try this:
@
import QtQuick 2.0Rectangle { 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
-
wrote on 9 Jan 2013, 13:13 last edited by
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 -
wrote on 9 Jan 2013, 13:29 last edited by
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 :/
-
wrote on 9 Jan 2013, 14:41 last edited by
Just look at this... facepalm
@import QtQuick 2.0Rectangle {
width: 360
height: 360
Rectangle {
id: rect
width: 100
height: 100
color: "green"
}
Timer {
interval: 1
repeat: true
running: true
onTriggered: rect.x++
}
}
@ -
wrote on 9 Jan 2013, 16:58 last edited by
I still think it's other component have slow performance in Qt 5, not the timer.
I modified your code:
@
import QtQuick 2.0Rectangle {
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).
-
wrote on 9 Jan 2013, 19:58 last edited by
OK, you're right. Now the question remains - why rendering in QtQuick 2.0 so slow? That was broken in the Beta 2 release?
-
wrote on 10 Jan 2013, 01:25 last edited by
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. -
wrote on 10 Jan 2013, 02:16 last edited by
Mine:
NVIDIA GeForce GTX 550 Ti
Version 6.14.13.1090 (2012-12-29) -
wrote on 10 Jan 2013, 02:20 last edited by
I don't know about ANGLE, and I can play new games normally, it should support OpenGL directly, I think.
-
wrote on 10 Jan 2013, 10:01 last edited by
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.htmlSee 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. -
wrote on 10 Jan 2013, 13:57 last edited by
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/12