Is there an effective way to cut down lag?

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.
User avatar
icekiller8002
Prole
Posts: 36
Joined: Mon Jun 06, 2016 9:28 pm
Location: United States

Is there an effective way to cut down lag?

Post by icekiller8002 » Sun Apr 08, 2018 8:24 pm

I have a game that I made with LÖVE2D. I want to update the game, but when I made the game compatible with löve 11.0, there's a ton of lag when I make the screen size bigger. I honestly don't know what's causing this, and I was wondering if there's an effective way to figure out the main problem for the lag, then remove it.

Code: Select all

function love.draw()
  love.graphics.print("obey")
end

User avatar
drunken_munki
Party member
Posts: 134
Joined: Tue Mar 29, 2011 11:05 pm

Re: Is there an effective way to cut down lag?

Post by drunken_munki » Mon Apr 09, 2018 3:56 am

If it is possible to attach the love file then do so, it would make it easier for people to help out. If not, then posting some of the code would help.

As it is now the problem might be too vague to solve.

On a random note I had a bunch of lag and stuttering on my older pc used for testing, for about two months or so. Turns out the g-card was dying and finally died last week. Anyway, does this happen on other games? Maybe check your drivers.

User avatar
ivan
Party member
Posts: 1531
Joined: Fri Mar 07, 2008 1:39 pm
Contact:

Re: Is there an effective way to cut down lag?

Post by ivan » Mon Apr 09, 2018 5:05 am

an effective way to figure out the main problem for the lag, then remove it.
Yes, there is a way to figure out which functions in your script take the longest time to execute, this is called profiling.
Personally, I use a small utility based on the debug.hook:
https://bitbucket.org/itraykov/profile.lua/src/

User avatar
icekiller8002
Prole
Posts: 36
Joined: Mon Jun 06, 2016 9:28 pm
Location: United States

Re: Is there an effective way to cut down lag?

Post by icekiller8002 » Mon Apr 09, 2018 8:34 pm

drunken_munki wrote:
Mon Apr 09, 2018 3:56 am
If it is possible to attach the love file then do so, it would make it easier for people to help out. If not, then posting some of the code would help.

As it is now the problem might be too vague to solve.

On a random note I had a bunch of lag and stuttering on my older pc used for testing, for about two months or so. Turns out the g-card was dying and finally died last week. Anyway, does this happen on other games? Maybe check your drivers.
This does not happen in other games. I would provide a .love file, but unless if you're willing to look through nearly 2000 lines of code, I don't wanna waste your time.

Code: Select all

function love.draw()
  love.graphics.print("obey")
end

User avatar
Nixola
Inner party member
Posts: 1940
Joined: Tue Dec 06, 2011 7:11 pm
Location: Italy

Re: Is there an effective way to cut down lag?

Post by Nixola » Mon Apr 09, 2018 8:40 pm

One doesn't necessarily need to read all of the code to figure out the issue; plus, two thousand lines of code may be a lot to one person but close to nothing for another one. I'd say you should upload the code (if you want to, of course) and let people decide whether they want to try, especially since it's the easiest way to figure out the issue.
lf = love.filesystem
ls = love.sound
la = love.audio
lp = love.physics
lt = love.thread
li = love.image
lg = love.graphics

User avatar
icekiller8002
Prole
Posts: 36
Joined: Mon Jun 06, 2016 9:28 pm
Location: United States

Re: Is there an effective way to cut down lag?

Post by icekiller8002 » Mon Apr 09, 2018 9:06 pm

Nixola wrote:
Mon Apr 09, 2018 8:40 pm
One doesn't necessarily need to read all of the code to figure out the issue; plus, two thousand lines of code may be a lot to one person but close to nothing for another one. I'd say you should upload the code (if you want to, of course) and let people decide whether they want to try, especially since it's the easiest way to figure out the issue.
Yeah, I agree with you. Well, if anyone wants to waste their time by looking through a script with 2K lines, be my guest.

Remember what I said: The lag issue only occurs when you have a big screen resolution.
Attachments
Ball Booster.love
(61.24 MiB) Downloaded 72 times

Code: Select all

function love.draw()
  love.graphics.print("obey")
end

User avatar
Nixola
Inner party member
Posts: 1940
Joined: Tue Dec 06, 2011 7:11 pm
Location: Italy

Re: Is there an effective way to cut down lag?

Post by Nixola » Mon Apr 09, 2018 9:57 pm

I can't seem to notice any difference between 650x650 and 2560x1440 (which, as of now, is the highest I can go), so I'm afraid I'm unable to reproduce the issue and thus unable to test it.
lf = love.filesystem
ls = love.sound
la = love.audio
lp = love.physics
lt = love.thread
li = love.image
lg = love.graphics

User avatar
yintercept
Citizen
Posts: 61
Joined: Mon Apr 02, 2018 3:31 pm

Re: Is there an effective way to cut down lag?

Post by yintercept » Mon Apr 09, 2018 9:58 pm

Does the lag issue happen when you changing window size/game resolution after start? Does it happen when going from windowed mode to full screen?

What are the specs of the machine you are running it on?
Apparently I'm a fan of most people.

Or maybe LOVE devs are just that good.

User avatar
icekiller8002
Prole
Posts: 36
Joined: Mon Jun 06, 2016 9:28 pm
Location: United States

Re: Is there an effective way to cut down lag?

Post by icekiller8002 » Mon Apr 09, 2018 10:59 pm

I tried putting an FPS counter on the screen. When I get from 1000 x 700 to 1280 x 720, my framerate drops from 60 to 50. When I get from 1280 x 720 to 1366 x 768 (my computer monitor size), it drops from 50 to 30. Also, here's my specs:
Attachments
specs.png
specs.png (5.07 KiB) Viewed 2280 times

Code: Select all

function love.draw()
  love.graphics.print("obey")
end

User avatar
yintercept
Citizen
Posts: 61
Joined: Mon Apr 02, 2018 3:31 pm

Re: Is there an effective way to cut down lag?

Post by yintercept » Mon Apr 09, 2018 11:10 pm

Your .love file was taking ages for me to download, networks are fun like that.

Q - are you drawing all the images one at a time, or are you batching them and drawing from quads? If you're not drawing from quads try that--drawing individual images one after another is the first thing I would assume would cause problems especially if scaling up seems to impact fps.

If that fails, download and include the little profiler/utility library ivan suggested and tell us how it goes.
Last edited by yintercept on Mon Apr 09, 2018 11:11 pm, edited 2 times in total.
Apparently I'm a fan of most people.

Or maybe LOVE devs are just that good.

Post Reply

Who is online

Users browsing this forum: No registered users and 8 guests