Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
[SOLVED] QtQuick 2 stuttering problem.
Hello all Qt friends :)
It is my first writing here, and it starts sadly with some problem. I am writing some game with my friend as a university project and from the beginning of development we encounter stuttering. At first, we tried classic Qt Widgets, but it doesn't fit well custom UI and introduced some serious stuttering. Then we moved to QML and QtQuick. Here first test were promising - stuttering was a way less noticeable but still exists.
Here is my question why it is like that? By stuttering I mean some micro freeze of the screen while objects are moving. It is rare in case of number of frames but objects in constant motion show this every few seconds and it is quite noticeable and unpleasant. Firstly I supposed vsync, but many tells that QtQuick uses it by default. Event force use in nVidia drivers has no effect. Me and my friend are using Win8.1 and didn't tested app on any other system. What is more it is rather Qt bug than code issue because even the most primitive QML presenting red rectangle over green background, and rectangle moving from left to right and reverse (with SmoothedAnimation inside behavior) run with QML Scene Viewer tool suffers from stuttering.
Am I doing something wrong or it is known issue? As I said running on Windows 8.1, Qt 5.3.1, VS2013.
Thanks in advance for any help and interest on topic. Have a nice day ^^
It is true that Qt Quick will request an OpenGL context with swapInterval == 1, but the driver is free to override it. If you force vsync on in the driver, then we're going be vsynced, no doubt about that :)
Is this an OpenGL build or an ANGLE build?
How does a plain OpenGL app fare on the system? For instance the example in qtbase/examples/gui/openglwindow. Is it also stuttering?
Does turning aero on or off make a difference (Haven't used windows myself in ages, so that might not be possible anymore)
Does running the application with QSG_FIXED_ANIMATION_STEPS=1 in the environment make a difference?
Thank you for reply.
When I finished reading what you have written, I started doing some tests.
Unfortunately I don't know if I've got ANGLE build and I found no information how to check it.
But I run the example you suggested and it was working perfectly fine. Then I check how works some QtQuick examples. It turned out that all of them works OK. Then I thought to check some of the QML files in these examples with QML Scene Viewer, and they also worked fine.
At this moment I said to myself, the problem must be in my code!
I rebuilt it, and run. And today it worked brilliant as never before. I've noticed such freeze only once over several minutes of constant watching the program. Restarted it a few times. I've run certain QML files with viewer and today I would say the problem is unnoticeable.
Have you got any ideas why it could happen like that. I can add, these problem was reoccurring. Much of development time I didn't pay attention to that but it seemed mainly appear. I don't like problems solving itself because I don't know why they were present and will they come back.
I try to test it several times in next few days. I hope it gone like a curse.
It is hard to say what might have changed. If you didn't change Qt and you didn't change your application, then chances are that it was something in the system. Maybe the vsync driver change wasn't applied? It's all guesswork at this point :)
This part of Qt (how animations are driven on windows) has not been updated since 5.1.
The Qt download says "OpenGL" in the name if it is a proper OpenGL build. Otherwise, it is an ANGLE build (OpenGL ES 2.0 emulated over DirectX). You can also check this by looking at the dependencies of QtGui.dll. If it links with opengl.dll, it is an OpenGL build. If it links with libEGL, it is an ANGLE build.
As far as I tested it in various circumstances, my problem seems to concern secondary display used with my laptop. I can easily perceive regular stuttering on monitor connected to my laptop via VGA, at the same time the problem does not occur on laptop's screen. I checked it under common multi-display modes:
using either laptop's screen or external monitor => no problem at all
extending laptop's screen with external monitor => no problem on laptop, stuttering on monitor
sharing the same screen on both displays => no problem on monitor, tearing on laptop
I'll add that my laptop uses integrated Intel GPU aside with nVidia GPU (nVidia Optimus), and I suppose behavior may vary from spec to spec, driver to driver.
BUT, it may be helpful tip for someone concerned (at least I hope so).
Thanks for all replies sletta again.
That makes sense then. I've noticed the same behaviour on OSX as well, when attaching the MacBook to a projector for instance. There are a few different problems causing this problem.
The root cause is that the OS and windowing system blocks in OpenGL's swapBuffers based on the vsync of only one screen (the primary display in this case) rather than for the display the window displayed on.
Qt's animation system is also ticked globally, not per window (except for the Animator classes when using threaded rendering). That means that even if the system were to support it, we still couldn't do individual frame rates on two separate displays. I'm also not sure that is desired. It would have a lot of side effects...