The pattern seems quite consistent, which suggests interference with something. A system process? VSync?
Does it happen if you give the love process highest priority?
LOVE lag spikes
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
- Luke100000
- Party member
- Posts: 232
- Joined: Mon Jul 22, 2013 9:17 am
- Location: Austria
- Contact:
Re: LOVE lag spikes
I deactivate vsync: it works. That's strange because I've tested this some days before...
How important is vsync? Can I disable it for all my games?
How important is vsync? Can I disable it for all my games?
Re: LOVE lag spikes
Luke100000 wrote:How important is vsync? Can I disable it for all my games?
It depends on your games really. If you deactivate vsync the game will run as fast as it can (which can lead to unexpected behaviour).
Here is an example:
Code: Select all
function love.load()
love.window.setMode(640, 480, { vsync = true });
end
local x = 0;
function love.update(dt)
x = x + 1;
end
function love.draw()
love.graphics.circle('fill', x, 20, 5, 20);
love.graphics.print(string.format("FT: %.3f ms", 1000 * love.timer.getAverageDelta()), 10, love.window.getHeight() - 60);
love.graphics.print(string.format("FPS: %.3f fps", love.timer.getFPS()), 10, love.window.getHeight() - 40);
end
This is where delta time (dt) comes into play:
Code: Select all
function love.load()
love.window.setMode(640, 480, { vsync = true });
end
local x = 0;
local speed = 10;
function love.update(dt)
x = x + speed * dt;
end
function love.draw()
love.graphics.circle('fill', x, 20, 5, 20);
love.graphics.print(string.format("FT: %.3f ms", 1000 * love.timer.getAverageDelta()), 10, love.window.getHeight() - 60);
love.graphics.print(string.format("FPS: %.3f fps", love.timer.getFPS()), 10, love.window.getHeight() - 40);
end
This is preferred, because it also means that older computers can run the game without getting different gameplay results. You can test this by decreasing the framerate:
Code: Select all
function love.load()
love.window.setMode(640, 480, { vsync = true });
end
local x = 0;
local speed = 10;
function love.update(dt)
x = x + speed * dt;
-- Lower framerate manually
local foo = "";
for i = 1, 10000000 do
foo = foo .. "";
end
end
function love.draw()
love.graphics.circle('fill', x, 20, 5, 20);
love.graphics.print(string.format("FT: %.3f ms", 1000 * love.timer.getAverageDelta()), 10, love.window.getHeight() - 60);
love.graphics.print(string.format("FPS: %.3f fps", love.timer.getFPS()), 10, love.window.getHeight() - 40);
end
P.S.: Windows XP is a bit ancient

Re: LOVE lag spikes
If I'm not mistaking there's another side effect to turning off vsync, screen tearing. IMO you're better off keeping vsync enabled and still using dt to get constant motion - that way the lag spikes won't show up as hiccups in perceived movement.
- Luke100000
- Party member
- Posts: 232
- Joined: Mon Jul 22, 2013 9:17 am
- Location: Austria
- Contact:
Re: LOVE lag spikes
Could be a good idea, and I'm using dt, but the lag spikes take 0.4ms.bizziboi wrote:If I'm not mistaking there's another side effect to turning off vsync, screen tearing. IMO you're better off keeping vsync enabled and still using dt to get constant motion - that way the lag spikes won't show up as hiccups in perceived movement.

Re: LOVE lag spikes
Have you figured out a solution to this yet? I'm experiencing this too. When using dt, things move at a constant rate, but when tit spikes, things jump a bit, since it's been a lot of frames since they've updated. It looks pretty bad.
Re: LOVE lag spikes
Even with vsync activated, you cannot assume that the game will run at a constant frame rate, because the computer may have poor graphics drivers or may not even support vsync at all, or might be too slow to reach a steady frame rate. In other words, you need to use dt properly no matter what.
And yes, you can just disable vsync if it causes problems for you. For bigger games, I would suggest including an in-game option for enabling/disabling vsync, as different computers behave differently.
And yes, you can just disable vsync if it causes problems for you. For bigger games, I would suggest including an in-game option for enabling/disabling vsync, as different computers behave differently.
My game called Hat Cat and the Obvious Crimes Against the Fundamental Laws of Physics is out now!
Re: LOVE lag spikes
Just to add to this, is there anyway to enabled/disable vsync during run-time? Or do I need the user to restart the application/game and change it in conf.lua?T-Bone wrote:Even with vsync activated, you cannot assume that the game will run at a constant frame rate, because the computer may have poor graphics drivers or may not even support vsync at all, or might be too slow to reach a steady frame rate. In other words, you need to use dt properly no matter what.
And yes, you can just disable vsync if it causes problems for you. For bigger games, I would suggest including an in-game option for enabling/disabling vsync, as different computers behave differently.
Re: LOVE lag spikes
https://love2d.org/wiki/love.window.setModeBOT-Brad wrote:Just to add to this, is there anyway to enabled/disable vsync during run-time? Or do I need the user to restart the application/game and change it in conf.lua?T-Bone wrote:Even with vsync activated, you cannot assume that the game will run at a constant frame rate, because the computer may have poor graphics drivers or may not even support vsync at all, or might be too slow to reach a steady frame rate. In other words, you need to use dt properly no matter what.
And yes, you can just disable vsync if it causes problems for you. For bigger games, I would suggest including an in-game option for enabling/disabling vsync, as different computers behave differently.
there is a "vsync" attribute in the flags option.
s-ol.nu
Code: Select all
print( type(love) )
if false then
baby:hurt(me)
end
Re: LOVE lag spikes
Nice one, thanks!S0lll0s wrote:https://love2d.org/wiki/love.window.setModeBOT-Brad wrote:Just to add to this, is there anyway to enabled/disable vsync during run-time? Or do I need the user to restart the application/game and change it in conf.lua?T-Bone wrote:Even with vsync activated, you cannot assume that the game will run at a constant frame rate, because the computer may have poor graphics drivers or may not even support vsync at all, or might be too slow to reach a steady frame rate. In other words, you need to use dt properly no matter what.
And yes, you can just disable vsync if it causes problems for you. For bigger games, I would suggest including an in-game option for enabling/disabling vsync, as different computers behave differently.
there is a "vsync" attribute in the flags option.
Who is online
Users browsing this forum: Ahrefs [Bot], Amazon [Bot] and 7 guests