Framerate Inconsistencies

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
Post Reply
crizilla
Prole
Posts: 3
Joined: Wed Jun 10, 2015 10:56 am

Framerate Inconsistencies

Post by crizilla »

When I run my game (still in development) I get massive framerate inconsistencies. One hour it will reach 800fps, then the other hour it will be between 80 and 100. Sometimes up to around 300. This obviously slows down the game big time when it's at a lower frame rate. My questions are why is this happening and is there anyway I have it stay at a given frame rate?
User avatar
kikito
Inner party member
Posts: 3153
Joined: Sat Oct 03, 2009 5:22 pm
Location: Madrid, Spain
Contact:

Re: Framerate Inconsistencies

Post by kikito »

Does the same happen with all the games, or just with yours? If it happens with all the games, it might be a problem in your computer. If it happens just with your game, then there might be a problem in your code. The easiest way for us to know what happens would be for you to upload a .love file so we could give it a look.
When I write def I mean function.
User avatar
BlueWolf
Prole
Posts: 12
Joined: Fri May 29, 2015 7:55 pm

Re: Framerate Inconsistencies

Post by BlueWolf »

Really anything above 60 fps should be more than enough. You shouldn't see any game slowdown. Are you sure you're using dt when updating your game? Regarding your problem I would assume it's due to other processes running in parallel at the same time.
crizilla
Prole
Posts: 3
Joined: Wed Jun 10, 2015 10:56 am

Re: Framerate Inconsistencies

Post by crizilla »

I'm not sure what .love file you would need to check out the project. I put it on github, though
https://github.com/crizilla/love2dshooter

This is the only game I have worked on or run with love. I can check if another game somebody else made has the same issues later when I get home. Games I download from Steam seem to run fine. Yes, I am passing dt through the update function.
User avatar
Evine
Citizen
Posts: 72
Joined: Wed May 28, 2014 11:46 pm

Re: Framerate Inconsistencies

Post by Evine »

It might be the "love.timer.sleep" function that is messing with you.

Try adding.

Code: Select all

function love.timer.sleep() end -- This will undo any calls to it and max out one of your cpu cores.
Artal, A .PSD loader: https://github.com/EvineDev/Artal
crizilla
Prole
Posts: 3
Joined: Wed Jun 10, 2015 10:56 am

Re: Framerate Inconsistencies

Post by crizilla »

Evine wrote:It might be the "love.timer.sleep" function that is messing with you.

Try adding.

Code: Select all

function love.timer.sleep() end -- This will undo any calls to it and max out one of your cpu cores.
So far so good. Thanks
User avatar
kikito
Inner party member
Posts: 3153
Joined: Sat Oct 03, 2009 5:22 pm
Location: Madrid, Spain
Contact:

Re: Framerate Inconsistencies

Post by kikito »

I misunderstood your question. I assumed you were already seeing a big drop in performance in slow parts of your code.

If you aren't, then you should not preemptibly do any "fixes". The "performance drops" you see when do almost nothing in your game won't scale once you actually do stuff in it.
It might be the "love.timer.sleep" function that is messing with you.
Do not do that. LÖVE makes a call to love.timer.sleep on every frame so that the processor can be used by others - including the operating system. Removing it will "lock" it to your game. This has several bad consequences. Here are some I know:
  • It is considered "bad behavior". Some operative systems might decide that your game has frozen and must be terminated
  • It will generate more heat than necessary - the CPU fans will start going up like crazy
  • If you ever export your game to a mobile, it will eat up the battery very rapidly
There might be others.

Don't worry about performance so early in the game: Make it work, make it pretty, and then make it fast.
When I write def I mean function.
szensk
Party member
Posts: 155
Joined: Sat Jan 19, 2013 3:57 am

Re: Framerate Inconsistencies

Post by szensk »

Have you checked if it's the garbage collector?

Try turning off the garbage collector and see if the frame rates stabilize. How? Put

Code: Select all

collectgarbage("stop")
in your love.init. Of course you can't "ship" the game like this but it may help to diagnose the problem.
Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot], Google [Bot], Roland Chastain, slime and 178 guests