• Hey! Guest! The 40th (!!!) GMC Jam will take place between February 25th, 12:00 UTC to March 1st 12:00 UTC. Why not join in this very special anniversary jam! Click here to find out more!

Windows Unfocusing game keeps making it crash or be unplayable

1610624139296.png
Game works just fine while its focused, the second it looses focus, bam, variable not set... WTH is going on, game resets on losing focus or smth? cause its getting annoying and I cant fix damn screen resizing itself after focus is back, now this...
And if I manage to fix resizing, how the hell I fix damn blackscreen....
 
Last edited:

Nocturne

Friendly Tyrant
Forum Staff
Admin
Moderator
Do you have a script or code or anything that deactivates objects when the game is paused or loses focus? The error references a variable "ttd", so start looking at where this is defined and how it works, then look at the object that's giving the error... Feel free to post any relevant code for us to look at too.
 
Do you have a script or code or anything that deactivates objects when the game is paused or loses focus? The error references a variable "ttd", so start looking at where this is defined and how it works, then look at the object that's giving the error... Feel free to post any relevant code for us to look at too.
no, only time things are deactivated is with console call.
And TTD is defined at create, at step and every time options are changed
 

Nocturne

Friendly Tyrant
Forum Staff
Admin
Moderator
Hmmm... Can you show the code for this ttd variable anyway? Just to see exactly what's happening. Also, do you have any code that would destroy the button object with that variable? Destroy isn't actually instantaneous and I've seen issues like this crop up because the instance has been flagged as destroyed but still runs an event (although very rarely have I seen this, and recently not at all).
 
nothing is destroyed at menu, TTD is variable saved from jason, overall code is pretty complicated and would be hard to paste all of it

//create
// Properties
width = 280;
height = 80;

updateSelf = true;

text = "Click here";
ttd = "Click here";

// Vars
hover = 0;

// Script
script = -1;

//step

var _hover = get_hover();
var _click = _hover && mouse_check_button_pressed(mb_left);

// Hover
hover = lerp(hover, _hover, 0.1);
y = lerp(y, ystart - _hover * 8, 0.1);

// Click
if (_click && script >= 0) {
script_execute(script);
switch (text)
{
case "New game":
event_user(0);
break;

case "Load":
event_user(3);
break;

case "Options":
event_user(1);
break;

case "Credits":
room_goto(rCredits);
break;

case "Quit":
game_end()
break;

case "Back to menu":
event_user(2);
break;
}
}

if (updateSelf)
{
updateSelf = false;
switch (text)
{
case "New game":
ttd = LoadLanguage(global.Language, "menu0");
break;

case "Load":
ttd = LoadLanguage(global.Language, "menu1");
break;

case "Options":
ttd = LoadLanguage(global.Language, "menu2");
break;

case "Credits":
ttd = LoadLanguage(global.Language, "menu3");
break;

case "Quit":
ttd = LoadLanguage(global.Language, "menu4");
break;
}
}

//draw gui

// Set color
draw_set_font(ftDefault);
draw_set_color(merge_color(c_ltgray, c_white, hover));

// Draw rounded rectangle
draw_roundrect(x, y, x + width, y + height, 0);

// Draw text
draw_set_color(c_black);
draw_set_halign(fa_center);
draw_set_valign(fa_middle);
draw_text(x + width/2, y + height/2, ttd);
draw_set_halign(fa_left);
draw_set_valign(fa_top);

// Reset color
draw_set_color(c_white);
 

Umaro

Member
Hmmm... Can you show the code for this ttd variable anyway? Just to see exactly what's happening. Also, do you have any code that would destroy the button object with that variable? Destroy isn't actually instantaneous and I've seen issues like this crop up because the instance has been flagged as destroyed but still runs an event (although very rarely have I seen this, and recently not at all).
I saw this today, actually. The YYC tries to execute all the code in an event even if the instance is already destroyed, causing YYC-specific crashes.
 

Nocturne

Friendly Tyrant
Forum Staff
Admin
Moderator
Hmmm... code looks okay as the var is definitely being defined in the Create Event. So there's not much more I can suggest... Add lots of breakpoints to the code and use the debugger to step through it and see what's happening, or use show_debug_message() everywhere to get some answers in real-time. In particular, add a show debug message to each event (step, draw, etc...) that displays the value of ttd to the screen and see what happens when you try to reproduce the issue. If all else fails, make a YYZ of the project and file a bug with YYG and include a link to the YYZ so they can look at it.
 
how can I check the game, when problem occurs outside of game :DDDD

tried debuging with messages, screen width changes, black screen isnt caused by deactivation, cause background would still be there, why the F variable dissapears, is beyond me

tried fixing resolution with focus function, got weird errors on graphics xD
 

Nocturne

Friendly Tyrant
Forum Staff
Admin
Moderator
That's why I suggest using "show_debug_message" everywhere! With that you can check things like instance_exists, var values etc... in the console up to the point where the game crashes and see if it gives any clue as to the issue. I suspect though that from what you're saying the only solution you'll get is from a bug report to YYG.
 
That's why I suggest using "show_debug_message" everywhere! With that you can check things like instance_exists, var values etc... in the console up to the point where the game crashes and see if it gives any clue as to the issue. I suspect though that from what you're saying the only solution you'll get is from a bug report to YYG.
**********************************.
Entering main loop.
**********************************.
Pause event has been registered for this frame
Pause event has been unregistered
Button was destroyed
Button was destroyed
Button was destroyed
Button was destroyed
Button was destroyed
Button was destroyed
Button was destroyed
Button was destroyed
Button was destroyed
Button was destroyed
Button was destroyed
Button was destroyed
Button was destroyed
Button was destroyed
Button was destroyed
Button was destroyed
Button was destroyed
Button was destroyed
Button was destroyed
Button was destroyed
Button was destroyed
Button was destroyed
Button was destroyed
Button was destroyed
Button was destroyed
Button was destroyed
Button was destroyed
Button was destroyed
Button was destroyed
Button was destroyed
Button was destroyed
Button was destroyed
Button was destroyed
Button was destroyed
Button was destroyed
Button was destroyed
Button was destroyed
Button was destroyed
Button was destroyed
Button was destroyed
Button was destroyed
Button was destroyed
Button was destroyed
Button was destroyed
Button was destroyed
Button was destroyed
Button was destroyed
Button was destroyed
Button was destroyed
Button was destroyed
Button was destroyed
Button was destroyed
Button was destroyed
Button was destroyed
Button was destroyed
Button was destroyed
Button was destroyed
Button was destroyed
Button was destroyed
Button was destroyed
Pause event has been registered for this frame
Button was destroyed
Pause event has been unregistered
Button was destroyed
Button was destroyed
Button was destroyed
Button was destroyed
Button was destroyed
Button was destroyed
Button was destroyed
Button was destroyed
Button was destroyed
Button was destroyed
Button was destroyed
Button was destroyed
Button was destroyed
Button was destroyed
Button was destroyed
Button was destroyed
Button was destroyed
Button was destroyed
Button was destroyed
Button was destroyed
Button was destroyed
Button was destroyed
Button was destroyed
Button was destroyed
Button was destroyed
Button was destroyed
Button was destroyed
Button was destroyed
Button was destroyed
Button was destroyed
Button was destroyed
Button was destroyed
Button was destroyed
Button was destroyed
Button was destroyed
Button was destroyed
Button was destroyed
Button was destroyed
Button was destroyed
Button was destroyed
Button was destroyed
Button was destroyed
Button was destroyed
Button was destroyed
Button was destroyed
Button was destroyed
Button was destroyed
Button was destroyed
Button was destroyed
Button was destroyed
Button was destroyed
Button was destroyed
Button was destroyed
Button was destroyed
Button was destroyed
Button was destroyed
Button was destroyed
Button was destroyed
Button was destroyed
Button was destroyed
Button was destroyed
Button was destroyed
Button was destroyed
Button was destroyed
Button was destroyed
Button was destroyed
Button was destroyed
Button was destroyed
Button was destroyed
Button was destroyed
Button was destroyed
Button was destroyed
Button was destroyed
Button was destroyed
Button was destroyed
Button was destroyed
Button was destroyed
Button was destroyed
Button was destroyed
Button was destroyed
Button was destroyed
Button was destroyed
Button was destroyed
Button was destroyed
Button was destroyed
Button was destroyed
Button was destroyed
Button was destroyed
Button was destroyed
Button was destroyed
Button was destroyed
Button was destroyed
Button was destroyed
Button was destroyed
Button was destroyed
Button was destroyed
Button was destroyed
Button was destroyed
Button was destroyed
Button was destroyed
Button was destroyed
Button was destroyed
Button was destroyed
Button was destroyed
Button was destroyed
Button was destroyed
Button was destroyed
Button was destroyed
Button was destroyed
Button was destroyed
Button was destroyed
Button was destroyed
Attempting to set gamepadcount to 0
Not shutting down steam as it is not initialised


X://windows/Runner.exe DONE (0)
Igor complete.
elapsed time 00:00:15.2779889s for command "C:\ProgramData/GameMakerStudio2/Cache/runtimes\runtime-2.2.5.378/bin/Igor.exe" -j=8 -options="C:\Users\Paulius-PC\AppData\Local\GameMakerStudio2\GMS2TEMP\build.bff" -v -- Windows Run started at 01/14/2021 14:34:56
"cmd" /c subst Z: /d

elapsed time 00:00:00.0363102s for command "cmd" /c subst Z: /d started at 01/14/2021 14:35:11
"cmd" /c subst Y: /d

elapsed time 00:00:00.0371195s for command "cmd" /c subst Y: /d started at 01/14/2021 14:35:11
"cmd" /c subst X: /d

elapsed time 00:00:00.0383382s for command "cmd" /c subst X: /d started at 01/14/2021 14:35:11
SUCCESS: Run Program Complete

added debug on destroy event on 1 of the buttons
WHY!?
Minimized game for 2 secs

so should I just restart room on focus back?

:rolleyes:
 
surface_resize(application_surface, RESOLUTION_W, RESOLUTION_H);
display_set_gui_size(RESOLUTION_W,RESOLUTION_H);

this is in create event of main object

but even then if I comment that surface resize same thing happens

1610630723318.png

Menu has main instance which creates the buttons in instance layer
 

Attachments

Nocturne

Friendly Tyrant
Forum Staff
Admin
Moderator
Check your code. Something is destroying the object! Oh, and have you cleaned the build? Use the "broom" icon at the top of the IDE. Sometimes a stale cache can give very weird issues....

PS: Please don't double post. Use the EDIT button, as multi-posting is against the rules and I've merged your posts.
 

Nocturne

Friendly Tyrant
Forum Staff
Admin
Moderator
found the issue, its on how weirdly it checks if game is focused
Care to elaborate so other users can benefit from the solution?

Also, I've sent you alerts and even commented in this very topic to say it, but you've ignored me so I'll say it again just to be clear: DO NOT DOUBLE POST UNLESS 48 HOURS HAVE PASSED AS PER THE FORUM RULES. Use the edit button please. :)
 
Care to elaborate so other users can benefit from the solution?

Also, I've sent you alerts and even commented in this very topic to say it, but you've ignored me so I'll say it again just to be clear: DO NOT DOUBLE POST UNLESS 48 HOURS HAVE PASSED AS PER THE FORUM RULES. Use the edit button please. :)
I did not ignore you and I stated why I created another post, please read before accusing

deleted focus check, cause it had pause , which would be fired once, but somehow it was firing million times, even tho it shouldnt, cause variable set was done once, which should have prevented that, but it didnt and game just went crazy, maybe it was reseting it, dunno
 
Lol. You literally just double posted then. I don't think you understand. Double posting doesn't simply relate to starting new topics, it also relates to posting in your current topics. If you post a new message in one of your topics and then think of something else to add, either wait the requisite 48 hours to post another message or edit the previous message instead of posting a new one again...This is to make sure you don't drown out other users asking for help by consistently bumping your own topic.
 
Lol. You literally just double posted then. I don't think you understand. Double posting doesn't simply relate to starting new topics, it also relates to posting in your current topics. If you post a new message in one of your topics and then a few minutes later think of something else to add, edit the previous message instead of posting a new one again...
oh, thank you for clarifying ^^ will now know
 
Top