Micro lags when vsync on or limiting FPS
Posted: Tue Aug 23, 2016 11:26 pm
Hello guys.
I have a very basic and short application which displays a square, which follows the mouse. It has constant velocity and stops immediately after reaching cursor position. It isn't moving very fast. There is a code which determines square's velocity:
(Please don't say that it's a bad code, I know it. )
And here is my problem: When I disable vsync and my application runs at 1000 FPS everything is very smooth and beautiful :> but after turning vsnyc on or limiting FPS to 60 some micro lags start to appear. 30 FPS limit makes the micro lags appear more often. They appear from few seconds to few times per second and they are about 5-20 ms long which makes them visible and annoying.
I am attaching a .love file. Sometimes the lags may not be present for a few seconds. To see the lags make the rectangle move from one screen edge to another only horizontally.
My problem may sound strange and very stupid but I'm 100% serious. Pls help
I have a very basic and short application which displays a square, which follows the mouse. It has constant velocity and stops immediately after reaching cursor position. It isn't moving very fast. There is a code which determines square's velocity:
Code: Select all
-- x and y are the square's coordinates; XX and YY are the mouse cursor ones; dt is delta time which is passed as a paramter in love.update
if y + 50 > YY then y = y - 200 * dt end
if y + 50 < YY then y = y + 200 * dt end
if x + 50 > XX then x = x - 200 * dt end
if x + 50 < XX then x = x + 200 * dt end
And here is my problem: When I disable vsync and my application runs at 1000 FPS everything is very smooth and beautiful :> but after turning vsnyc on or limiting FPS to 60 some micro lags start to appear. 30 FPS limit makes the micro lags appear more often. They appear from few seconds to few times per second and they are about 5-20 ms long which makes them visible and annoying.
I am attaching a .love file. Sometimes the lags may not be present for a few seconds. To see the lags make the rectangle move from one screen edge to another only horizontally.
My problem may sound strange and very stupid but I'm 100% serious. Pls help