Closed gm-bug-reporter[bot] closed 2 weeks ago
For those following along, here is the text message I included with my bug report, detailing the code and the debug information provided to YoYo Games for GMS2. . .
Suddenly, there is something seriously wrong with GMS. Note that prior to rebuilding a room of my app in a separate project file for comprehensive debugging purposes, I uninstalled GMS from my computer and reinstalled from a fresh download of GMS, downloaded today.
And with that, here we go:
I rebuilt a single room of my app with the absolute least code possible and improvised a full debug.
I've got a number of objects on the screen, which will all be found, along with their coordinates. You can ignore all of this (I have deleted a large section of it and made a note in the debug), as these are preplaced objects via drag-n-drop in the editor (not dynamically placed).
The key finding is GMS's failure to initialize the globals I've declared in the CREATE event of the room controller obj_controllerMatchMaster object.
Here are the code snippets with implementation:
// scr_initialize_game
// Gather essential debug information show_debug_message("=== Debug Info Start ==="); show_debug_message("Checking global variables...");
if (variable_global_exists("global.game_level")) { show_debug_message("global.game_level: " + string(global.game_level)); } else { show_debug_message("ERROR: global.game_level not found."); }
if (variable_global_exists("global.visible_game_objects")) { show_debug_message("global.visible_game_objects: " + string(global.visible_game_objects)); } else { show_debug_message("ERROR: global.visible_game_objects not found."); }
if (variable_global_exists("global.total_game_objects")) { show_debug_message("global.total_game_objects: " + string(global.total_game_objects)); } else { show_debug_message("ERROR: global.total_game_objects not found."); }
if (variable_global_exists("global.sprite_pool")) { show_debug_message("global.sprite_pool size: " + string(ds_list_size(global.sprite_pool))); } else { show_debug_message("ERROR: global.sprite_pool not found."); }
show_debug_message("Gathering object instances..."); with (obj_gameObject) { show_debug_message("Found obj_gameObject at position (" + string(x) + ", " + string(y) + ")"); }
with (obj_objectCover) { show_debug_message("Found obj_objectCover at position (" + string(x) + ", " + string(y) + ")"); }
with (obj_gameTileLock) { show_debug_message("Found obj_gameTileLock at position (" + string(x) + ", " + string(y) + ")"); }
show_debug_message("=== Debug Info End ===");
// CREATE Event of obj_controllerMatchMaster
// Minimal global variables for debugging global.game_level = 1; global.visible_game_objects = 18; global.total_game_objects = 32;
// Create an empty sprite pool (for debug purposes) global.sprite_pool = ds_list_create();
// Debug message to confirm initialization show_debug_message("CREATE: Minimal globals initialized.");
// ROOM START Event of obj_controllerMatchMaster
// Call the debug information script scr_initialize_game();
=== Debug Info Start === Checking global variables... ERROR: global.game_level not found. ERROR: global.visible_game_objects not found. ERROR: global.total_game_objects not found. ERROR: global.sprite_pool not found. Gathering object instances... === Debug Info End === TimeLine_Prepare() Object_Prepare() Room_Prepare() Finished PrepareGame() Run_Start Done g_EffectsManager.Init() Done RenderStateManager CreateColPairs took 0.000000s 0 usecs for 6 object types obj_col_numb=0 physobjcount=0 resizes 0 final size 0 Done ObjectLists Done Extension_Initialize About to startroom CREATE: Minimal globals initialized. === Debug Info Start === Checking global variables... ERROR: global.game_level not found. ERROR: global.visible_game_objects not found. ERROR: global.total_game_objects not found. ERROR: global.sprite_pool not found. Gathering object instances... Found obj_gameObject at position (2189, 1056) Found obj_gameObject at position (1929, 1056) Found obj_gameObject at position (1669, 1056) Found obj_gameObject at position (1409, 1056) Found obj_gameObject at position (1150, 1056) Found obj_gameObject at position (890, 1056) Found obj_gameObject at position (631, 1056) Found obj_gameObject at position (371, 1056) Found obj_gameObject at position (2189, 798) Found obj_gameObject at position (1929, 798) Found obj_gameObject at position (1669, 798) Found obj_gameObject at position (1409, 798) Found obj_gameObject at position (1150, 798) Found obj_gameObject at position (890, 798) Found obj_gameObject at position (631, 798) Found obj_gameObject at position (371, 798) Found obj_gameObject at position (2189, 538) Found obj_gameObject at position (1929, 538) Found obj_gameObject at position (1669, 538)
[[[ DELETED from debug for ease of reading output ]]]
=== Debug Info End === Total memory used = 10436706 (0x009f4062) bytes 9.95MB Free memory = 6751872 (0x00670680) bytes 6.44MB Peak memory used = 11906954 (0x00b5af8a) bytes 11.36MB **. Entering main loop. **. Pause event has been registered for this frame Pause event has been unregistered elapsed time 00:00:06.2452214s for command "C:\ProgramData/GameMakerStudio2/Cache/runtimes\runtime-2024.8.1.218/bin/igor/windows/x64/Igor.exe" -j=8 -options="C:\Users\User\AppData\Local\GameMakerStudio2\GMS2TEMP\build.bff" -v -- Windows Run started at 10/29/2024 18:24:06 ---------- STOPPING ---------- SUCCESS: Run Program Complete
Notice how none of the globals are being found. I believe THIS, at the very least, is what inexplicably screwed up my app-in-develoment. And it came out of nowhere -- no code changes at all, no GMS modifications.
I swear to god, my code was working as well as one always hope/expects when I saved it and went to bed. Then, on getting back to work the next day, without changing anything, everything was broken.
I had to rebuild the app's foundation to run this test, and that's what your seeing -- a bare-bones debug. . . And, once more, I uninstalled GMS and reinstalled GMS.
Any ideas?
NOTE: Even the ChatGPT customized GameMaker GURU assistant I built identifies the root cause of the problem as a failure to initialize globals. I have tried every extreme combination of work-arounds to give GMS the time it needs to initialize these variables (performed only to further understand the problem). But GMS simply will not initialize these global variables under any circumstances.
this is not a bug in gm, you are just doing things in the wrong order. all scripts execute their interiors before the first room load—so no objects exist yet—and you are declaring your globals in a create event. this means that you check if the global exists at game launch, but the global doesnt exist yet. second of all, the room start event happens after create events happen, so this is whats happening:
might wanna double check on the order in which these things happen in the manual. if you declared the interior of that script asset as a function, that will stop it from executing at game launch, and then calling it in room start would make more sense.
this talks about scripts/functions, and near the bottom mentions scripts happening at game launch
refresher on globals, just in case you were thinking they might get initialized at compile time rather than runtime
This is why fundamentals matter, folks.
Now, I have to be embarrassed.
Thank you so much for this. A little taste of crow, and I'm on the right path again.
Apologies, and thank you so much for the lesson. I will now go off to dominate and show just how awesome GMS is.
(I truly believe GMS is just not as popular as it deserves.)
Thanks again!
Closing as above, thanks!
Description
I was prototyping an app, and was in a great place. Everything was working, and I was ready to move on to developing a different aspect of my app. I save and go to bed. I wake up and get back to work, and now the app is broken.
There may be more going on, but at the very least, global variable are no longer initializing before room start. Even when no room start event is used, and an initializing script is called directly after global variables are declared, these variables are still not being found and/or are failing to initialize in the CREATE event of the object controller placed in the room.
I rebuilt a bare-bones version of one room of my app in a separate project and ran a comprehensive debug. I have attached the file. There are only three code blocks in this rebuild. I have attached a file providing these code blocks, which also includes the debug out, showing the failure.
Steps To Reproduce
Available in attached text file.
Which version of GameMaker are you reporting this issue for?
IDE v2024.8.1.171 Runtime v2024.8.1.218
Which operating system(s) are you seeing the problem on?
Windows 10.0.22631.0
Attached Files
61a3cf7b-a8d9-4b9c-b156-acd7c16d3672