Hello, I made a little test game and when I run it in windowed mode (fullscreen = false) with vsync turned on, there is very noticeable stuttering. There is no drop in fps and it's running at a constant 60 fps but there is some issue with the rendering which makes the movement look jerky. This issue completely goes away in fullscreen mode or with vsync turned off. Also, the behaviour isn't consistent. Sometimes it's mild and sometimes it's very hard.
I've attached two files to show you the behaviour. rough.love has the stuttering whereas smooth.love runs fine and the only difference is that vsync is turned off in smooth.love. Press w/a/s/d to move the box and if you don't see any stuttering in rough.love, please close the window and try again because like I said, it doesn't happen consistently. I tried it on my friend's PC and the same thing is happening there too.
Any idea what might be causing this and how I can fix it?
Stuttering in windowed mode with vsync turned on
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
Stuttering in windowed mode with vsync turned on
- Attachments
-
- smooth.love
- (13.12 KiB) Downloaded 174 times
-
- rough.love
- (13.4 KiB) Downloaded 174 times
Re: Stuttering in windowed mode with vsync turned on
I can't see any stuttering (Linux, nVidia GeForce 210, driver version 340.107).
From the line endings I can tell you're using Windows. Could it be your graphics driver? Antivirus? The OS? Also maybe you have some desktop effects enabled and the graphics card is trying to render them, and that slows down the graphics driver occasionally.
I see you load resources with a coroutine which has a time limit of 1/50; that's more than the time of one frame. Could it be that resources are still processed?
There are many possibilities, most likely including some that didn't occur to me, and I can't help narrowing them down because I can't reproduce the issue.
You can see if the delay is visible in the program by checking dt against a threshold. For example:
From the line endings I can tell you're using Windows. Could it be your graphics driver? Antivirus? The OS? Also maybe you have some desktop effects enabled and the graphics card is trying to render them, and that slows down the graphics driver occasionally.
I see you load resources with a coroutine which has a time limit of 1/50; that's more than the time of one frame. Could it be that resources are still processed?
There are many possibilities, most likely including some that didn't occur to me, and I can't help narrowing them down because I can't reproduce the issue.
You can see if the delay is visible in the program by checking dt against a threshold. For example:
Code: Select all
function love.update(dt)
if dt > 1/40 then print("Stutter") end
...
Re: Stuttering in windowed mode with vsync turned on
rough.love is stuttering for me too (Windows 7) while smooth.love is indeed smooth. The stuttering seems to go away after a while, but it's kinda inconsistent as you say. I don't know if this is the actual issue, but commenting out the love.window.setTitle() call seem to solve, or at least decrease, the stuttering for me for whatever reason. Printing out dt reveals that the frame rate don't change with the mentioned change, but somehow the visible stuttering is different.
(I've encountered weird stuttering myself a few of times over the years I've used the different versions of LÖVE, but never really found out why.)
(I've encountered weird stuttering myself a few of times over the years I've used the different versions of LÖVE, but never really found out why.)
Tools: Hot Particles, LuaPreprocess, InputField, (more) Games: Momento Temporis
"If each mistake being made is a new one, then progress is being made."
"If each mistake being made is a new one, then progress is being made."
Re: Stuttering in windowed mode with vsync turned on
Well, for me, all 2 examples stuttering
As for Windows 10, RX570
As for Windows 10, RX570
Re: Stuttering in windowed mode with vsync turned on
Both stutter for me.
The project seems to be extremely sensitive to any other GPU/CPU load.
1st of all, from love2d wiki:
But even without that the framerate is inconsistent.
I moved the box out of the screen area, and the "dt" fluctuates between 0.00168 and 0.05218. If I dare to move a window, max dt can go up to half a second.
Not sure is that's the reason, but you might want to look into this https://stackoverflow.com/questions/184 ... g-it-wrong
The project seems to be extremely sensitive to any other GPU/CPU load.
1st of all, from love2d wiki:
Code: Select all
Constantly updating the window title can lead to issues on some systems and therefore is discouraged.
I moved the box out of the screen area, and the "dt" fluctuates between 0.00168 and 0.05218. If I dare to move a window, max dt can go up to half a second.
Not sure is that's the reason, but you might want to look into this https://stackoverflow.com/questions/184 ... g-it-wrong
Re: Stuttering in windowed mode with vsync turned on
It's happening on other people's PCs too so I don't know if it has anything to do with my drivers, OS, etc.pgimeno wrote: ↑Mon Aug 30, 2021 11:52 am I can't see any stuttering (Linux, nVidia GeForce 210, driver version 340.107).
From the line endings I can tell you're using Windows. Could it be your graphics driver? Antivirus? The OS? Also maybe you have some desktop effects enabled and the graphics card is trying to render them, and that slows down the graphics driver occasionally.
I see you load resources with a coroutine which has a time limit of 1/50; that's more than the time of one frame. Could it be that resources are still processed?
There are many possibilities, most likely including some that didn't occur to me, and I can't help narrowing them down because I can't reproduce the issue.
You can see if the delay is visible in the program by checking dt against a threshold. For example:
Code: Select all
function love.update(dt) if dt > 1/40 then print("Stutter") end ...
It goes to the "play state" only after all resources are loaded and also in that test project there are no resources to be loaded so that's not the problem either.
There is actually no drop in fps at all and the dt is consistent but somehow visually it stutters.
I even created a new empty project with just a single main.lua file which does nothing but move a rectangle when you hold a button and it's still stuttering the same way. It's really weird.
Re: Stuttering in windowed mode with vsync turned on
Yes the framerate is stable but somehow there is visual stuttering. It's like the rectangle is getting distorted for a split-second while being rendered.ReFreezed wrote: ↑Mon Aug 30, 2021 1:09 pm rough.love is stuttering for me too (Windows 7) while smooth.love is indeed smooth. The stuttering seems to go away after a while, but it's kinda inconsistent as you say. I don't know if this is the actual issue, but commenting out the love.window.setTitle() call seem to solve, or at least decrease, the stuttering for me for whatever reason. Printing out dt reveals that the frame rate don't change with the mentioned change, but somehow the visible stuttering is different.
(I've encountered weird stuttering myself a few of times over the years I've used the different versions of LÖVE, but never really found out why.)
Re: Stuttering in windowed mode with vsync turned on
I created a new empty project from scratch which has just one main.lua file with the code you see below and one small image and it's still stuttering. So the problem is obviously not with the code and this issue is happening on other people's systems too so I don't think it's because of anything wrong with my PC environment in particular. What could be causing this?
Code: Select all
function love.load()
love.window.setMode(1280, 720, {
fullscreen = false,
vsync = 1
})
img = love.graphics.newImage('image.png')
x, y = 80, 80
speed = 400
end
function love.update(dt)
if love.keyboard.isDown('s') then
y = y + speed * dt
elseif love.keyboard.isDown('d') then
x = x + speed * dt
elseif love.keyboard.isDown('w') then
y = y - speed * dt
elseif love.keyboard.isDown('a') then
x = x - speed * dt
end
end
function love.draw()
love.graphics.draw(
img,
math.floor(x),
math.floor(y),
0,
2
)
end
- Attachments
-
- wtf.love
- (738 Bytes) Downloaded 164 times
Re: Stuttering in windowed mode with vsync turned on
Measuring performance in FPS is often misleading. In LÖVE the reported FPS is the average over the last second or so. You won't see single-frame spikes in averaged numbers.
Use dt in love.update instead. Displaying min/max/avg dt besides FPS is good practice imo.
One possible explanation is background tasks periodically taking up CPU time. Maybe Antivirus or that other crap running on Windows PCs.What could be causing this?
Re: Stuttering in windowed mode with vsync turned on
So in case anyone is interested, I was able to fix the problem. You can find the solution here.
Who is online
Users browsing this forum: Google [Bot] and 1 guest