• Hello [name]! Thanks for joining the GMC. Before making any posts in the Tech Support forum, can we suggest you read the forum rules? These are simple guidelines that we ask you to follow so that you can get the best help possible for your issue.

Question - Code Finish Frame uses 97% of Step

My visually simple game is using 97% of the step event on the Finish_Frame
I'm not using any shaders, there aren't more than 37 objects on the screen, the only thing I could think of is that every image in the game is scaled up 6 times from 320x180 to 1920x1080.
I've tried changing my macro that sets the scale of everything from 6 to 1 but saw no performance difference.
What else should I try?

GameScreenshot (1).jpg Lag.PNG
 
Last edited:

Nocturne

Friendly Tyrant
Forum Staff
Admin
The "Finish Frame" section is just telling you how much of the frame is left after doing the game processing, so, your GAME is using 3% of the step, and to keep timing GMS fills in the rest of the 97% to give you 100% of the frame. :)
 
Thank you Nocturne! That's great to hear. How do I figure out why my game lags?
There is a noticeable jittery lag at the start of a level, and for a lot of people the game runs at 45fps instead of 60
I've never actually been able to figure out why and have just been trying to hide it by using delta_time
 

Tthecreator

Your Creator!
Thank you Nocturne! That's great to hear. How do I figure out why my game lags?
There is a noticeable jittery lag at the start of a level, and for a lot of people the game runs at 45fps instead of 60
I've never actually been able to figure out why and have just been trying to hide it by using delta_time
That's strange, but just with that information you aren't going to be able to do a whole lot.
You have to know their computer's specs and what part of the game they are in. Even if you had a baller computer, 3% shouldn't be exceed your 60 fps frame time on even a very slow computer.
You might have a programming bug somewhere on some level that causes some loop to execute way more than it should. Do you have access to one of the computers at which the game runs at 45 fps? You could try to see if you can debug it on there to see where the issue is.
 

Nocturne

Friendly Tyrant
Forum Staff
Admin
Are you testing on Android? When I was deving games regularly for Android I discovered that a LOT of devices cap the FPS at 45... and so ended up developing my games at that speed or 30fps. If you're getting 45 on desktop, then I'm not sure what to suggest. We'd really need a lot more information about the game... for example, do you use dynamic resources (ie: data structures, surfaces, etc...) or load a lot of files? Do you have the music set top streaming or load into memory? Does an "empty" game run at full speed? Have you tried removing instances one at a time from the game (or commenting out code) to see if anything in particular causes the issue? :)
 
Thank you guys, first off its really hard for me to debug because most of the time it crashes because of this
https://imgur.com/bT6DSUA, randomly it works maybe 1/5 times I hit compile, the other 4 times it says a variable that was clearly declared wasn't.

I have been testing on android. That's really good to know, but I've seen gittery lag at the start on my computer as well as others.

I don't think I'm using anything heavy as you mentioned. The most inefficient things I'm doing are drawing some transformed text and scaling everything up.
I've tried to optimize things as much as possible, but I still can't detect what is the problem.
 

Nocturne

Friendly Tyrant
Forum Staff
Admin
This might be a stupid question, but given the nonsensical nature of that error (the variable referred to looks like it 100% does exist!), have you cleared the compiler cache? The "broom" icon at the top will do this for you. I've found all sorts of very weird errors due to stale cache, so clearing that may help you here if you haven't already.
 

rIKmAN

Member
Run your game using the profiler, this is the best way to see which parts of your game are taking the most time and possibly causing lag.

Edit: Never mind, just seen the screenshot in the OP, doh! :D

Like Noc says, test a fresh project and see if you get the same performance / lag with an empty room.
 
L

Lonewolff

Guest
This might be a stupid question, but given the nonsensical nature of that error (the variable referred to looks like it 100% does exist!), have you cleared the compiler cache? The "broom" icon at the top will do this for you. I've found all sorts of very weird errors due to stale cache, so clearing that may help you here if you haven't already.
Especially so with the mobile exporters, I have found.
 
Yes I clear the cache before every build, I always assumed the problem had to do with scaling up all sprites. If that's not the case I don't know anymore.
I'm going to try to get my friends to test their computers fps again and look at android, considering that 45 or less fps is normal. Thank you guys for your help.
 
Alright I got my hands on a lagging device and figured out what the problem was! There were two things actually I needed to disable.
First, My resolution was too high. I was running the game at 1920x1080 and that was making it run very slow on some machines.
The solution? just call surface_resize(application_surface,960,540) to lower the draw resolution.
Second, DYNAMIC RENDERING MASKS were having a huge lag on the game. So I turned those off. Which was a shame because I really liked how those looked.
Turning off transparency when possible also helped some.
Game runs now at a smooth 60fps
 
Last edited:

Dog Slobber

Member
Yes I clear the cache before every build,
Why?

Do you know how much time you're wasting watching Studio rebuild resources needlessly?

Clear your cache:
  • On creation of a distributable executable.
  • If you unexpected behaviour or messages.
  • When you change target platforms.
  • After an update.
  • After loading a project that you haven't worked on in a loooooooooong time.

And, even then the last three are often unnecessary.
 
That's what I meant. Every time I make a new build of the game to upload online I clear the cache.
I don't normally clear the cache before running the game .
 
FOR FOLKS WHO FIND THIS LATER:

The problem of "jittery lag at the start of a level" sounds like it ALSO might be a result of the game having to load the texture pages for the level assets on the fly.

One thing that helped me with this was to prefetch the texture pages (using texture_prefetch(tex_id)) on a loading screen.

You can read more about it here: https://docs2.yoyogames.com/source/...erence/drawing/textures/texture_prefetch.html
 
Top