(SOLVED) Lag issue, but solved ONLY when ALT+ENTER?

Hi everyone,
for a long time I have been fighting lag in my game.
The lag did do something good however; I learned to optimize so many things,
that the lag was reduced by a ton.
I can basically have like 2000 instances running a small (but clever) amount of code and the lag
doesn't really happen.

But one thing always endured:

If I minimize the game, with CRT+ESC shortcut,
en then come back by clicking the game icon in the taskbar,
lag starts to happen. Sometimes to an unplayable degree.

My camera automatically sets the screen to fullscreen,
and there is some surface manipulations going on to get some cool effects, like setting up a lighting surface.
I payed very close attention to how that's done in tutorials, and I don't expect it to be the cause of the lag... I hope.
In the camera, after all the shader magic happened in the code (post-draw event),
I do also do this at the end of my shader code:

GML:
application_surface_draw_enable(false);
if (surface_exists(application_surface))
{
draw_surface(application_surface, 0, 0);
}

The crazy thing is I accidentily homed in on a "solution".

Once back in the game,
if I press the keyboard shortcut ALT + ENTER.
The srceen flashes briefly,
and goes from seemingly maximized to again, seemingly maximized.

This time the lag is FULLY gone. None. Even when I try to push my game to
the limits of what I want to do, no lag. None.
It seems the program "loses track" of something,
and only after the ALT-ENTER press does it "grab back onto it".


So here's my questions:

What does Alt-Enter really do?
How does this affect surfaces?
What happens to surfaces if you CTRL+ESC out of the game?
Is it okay to put window_set_fullscreen(true); in a step event?



EDIT: Extra information
my room speed is set to 60, every room is persistent and clears the display buffer, game starts fullscreen, first room of game is not of a screen display size but a camera handles a proper view,
I allow full screen switching, borderless window is turned on, and I'm "keeping aspect ratio" turned on as well.
 
Last edited:
S

Sybok

Guest
What version of GMS?

I remember something like this happening with one of the earlier GMS 1.4 builds. I can't say I have ever come across this with GMS 2 though.
 
What version of GMS?

I remember something like this happening with one of the earlier GMS 1.4 builds. I can't say I have ever come across this with GMS 2 though.
Game Maker Studio 2, latest build (although I don't have the update, might still be in beta, for the animations)
 
What version of GMS?

I remember something like this happening with one of the earlier GMS 1.4 builds. I can't say I have ever come across this with GMS 2 though.
Sorry for the extra reply but your comment made me think of a question to ask:
do you perhaps have a link or forum post to point me to that handles that problem in GMS 1.4,
as there might be a similar solution between the 2 versions of the program.
 
One more reply, as I found something.

To anyone with deeper knowledge about this, this could be the big indication of what is going on:

In the output log, this occurs:




When backing out of the game using CTRL+ESC, this appears:

Pause event has been registered for this frame
Pause event has been unregistered

Then, while playing, that repeats multiple times and occurs during moments of lag.



After that when ingame, and pressing ALT+ENTER, this happens:

Resizing swap chain...Resizing window...Resizing swap chain...Pause event has been registered for this frame

Then, while playing, the recurring
Pause event has been registered for this frame
Pause event has been unregistered
no longer seems to happen (or at least only on very very rare occasions)
 

Xer0botXer0

Senpai
Sounds like it has something to do with the application surface resizing, and the rendering of content onto it.
Have you tried different monitor resolutions ? - just a guess
 
Sounds like it has something to do with the application surface resizing, and the rendering of content onto it.
Have you tried different monitor resolutions ? - just a guess
My monitor resolution is 1920x1080 and I don't expect that to be a problem.

Furthermore, I want my game to work universally on all screen resolutions. If I had to set my laptop to a specific resolution, just so I can run the game properly on my laptop and my laptop alone,
the game wouldn't be universal I fear.

Right now the resolution of my game works fine on 3 different laptops with 3 different resolutions and I'd like to keep it like that.
 
UPDATE:

it seems to be fully solved!

The crazy thing here, as I expected, is that it wasn't a coding issue. It also wasn't a surface issue or anything like that.
I contacted the Game Maker support on the bug report pages,
and got an answer:

Yes indeed this is more related to the engine and hardware itself.

My laptop's setting for preferred graphics processor was set to "Auto Select".
For some reason it was no longer set to "High Performance Nvidia processor".
Why did it change, I have no idea.
Maybe I did and forgot, or some update messed with it.
I do know that this laptop came with the correct setting and not auto-select.

You can set the preferred graphics processor when you right click your desktop screen
then go to Nvidia Control Panel.
(This will be something else for AMD, ATI,... cards)

Then, under "Manage 3D settings", you'll find the preferred processor.
Mine was switched back to High Performance Nvidia processor.

No more lag!
None!

I don't know if this ends up coming back in the future though.

Still, it was crystal clear:
i changed that setting, all of the issues with lag by maximizing and minimizing the game,
with ALT-TAB, or CTRL-ESC, or ALT-ENTER, were completely gone!
 

Moth27

Member
June 2021

The OP's solution helped me here. I noticed my game in Fullscreen was running about 200FPS in the Debugger, but would go to 600FPS in windowed mode. After switching to High Performance Nvidia processor, the game regularly hits 600 FPS in Fullscreen now.

This is great but if I release a game, will I then have to have a notice that informs the player this change is needed?
 
Yo thanks, this also saved me, i've been working on a game for almost a year now trying to find a solution for this. Same question as Moth's. anyway to set it as a default for other computers or would integration with a platform like opera or steam be able to resolve that
 
Top