Audio Error? Maybe?

Yizzard

Member
So basically I have been having this error happen in one level specifically of my game, and not anywhere else where if you enter a battle with an enemy every once in a while the game crashes. I have no idea if it's happening due to this OpenAL error that i keep getting but I don't really see this error anywhere else in the game, so I think it's connected. At first I thought that it was trying to load some empty audio files that I had but I replaced them all with stand-ins and it still isn't working. Basically, the game is a platformer in the overworld but colliding with an enemy puts it into a jrpg battle, so after switching screens to the battle screen (which is another room) is when it always crashes. But it hardly ever does it so it's impossible to debug. Here's my output log for the last time I managed to get it to crash:

Entering main loop.
**********************************.
Resizing swap chain...
Resizing window...Audio group 1 -> Loading...
Audio group 2 -> Loading...
Audio group 1 -> Loaded
Audio group 2 -> Loaded
OpenAL error: 40963 (Audio_Tick End)
OpenAL error: 40963 (Audio_Tick End)
Pause event has been registered for this frame
Pause event has been unregistered
Pause event has been registered for this frame
Pause event has been unregistered
OpenAL error: 40963 (Audio_Tick End)
Pause event has been registered for this frame
Pause event has been unregistered
OpenAL error: 40963 (Audio_Tick End)
OpenAL error: 40963 (Audio_Tick End)
OpenAL error: 40963 (Audio_Tick End)
OpenAL error: 40963 (Audio_Tick End)
OpenAL error: 40963 (Audio_Tick End)
OpenAL error: 40963 (Audio_Tick End)
OpenAL error: 40963 (Audio_Tick End)
Pause event has been registered for this frame
Pause event has been unregistered
OpenAL error: 40963 (Audio_Tick End)
OpenAL error: 40963 (Audio_Tick End)
OpenAL error: 40963 (Audio_Tick End)
OpenAL error: 40963 (Audio_Tick End)
OpenAL error: 40963 (Audio_Tick End)
OpenAL error: 40963 (Audio_Tick End)
Error setting sample buffer


X://windows/Runner.exe exited with non-zero status (-1073741819)
elapsed time 00:07:42.4694826s for command "C:\ProgramData/GameMakerStudio2/Cache/runtimes\runtime-2.3.2.426/bin/Igor.exe" -j=8 -options="C:\Users\Yizzard\AppData\Local\GameMakerStudio2\GMS2TEMP\build.bff" -v -- Windows Run started at 06/26/2021 14:08:41
"cmd" /c subst Z: /d

elapsed time 00:00:00.1226719s for command "cmd" /c subst Z: /d started at 06/26/2021 14:16:23
"cmd" /c subst Y: /d

elapsed time 00:00:00.1196797s for command "cmd" /c subst Y: /d started at 06/26/2021 14:16:23
"cmd" /c subst X: /d

elapsed time 00:00:00.1146940s for command "cmd" /c subst X: /d started at 06/26/2021 14:16:23
FAILED: Run Program Complete
For the details of why this build failed, please review the whole log above and also see your Compile Errors window.

I have absolutely no clue what could be causing this or even where to look. I'm not sure if anyone will be able to help me with this, but if you happen to have any idea what could be causing this please let me know. There are buzzsaw objects that constantly loop a buzzing noise, but the player character every frame deactivates all objects in the room then reactivates ones within a certain radius to reduce lag and so that there aren't too many audio files trying to play at once which often resulted in many of them being stopped due to priority shenanigans. This could even have nothing to do with the audio, but I'm just assuming it does. Also, when it crashes, it simply exits out of the game. It doesn't stop on a single line of code and say error or anything it just closes out of the game like I had pressed the x in the corner. Idk if it's doing this because of some sort of memory leak thing or what, but the game runs perfectly smoothly (it caps at 60 fps, but the debugger says that it can run at like anywhere from 1,500-5,000 fps depending on whether the player is in battle or in an area with a lot of objects or whatever) and there's no drop in frames at all before crashes or anything.
1624732388873.png
The only time frames drop at all is when loading between areas because I prefetch all sprites (it also does this at the beginning of battles, but 95% of the time the battle prefetches don't cause any frame drops, also they are entirely unnoticeable as it occurs during the transition between two areas or between the overworld and the in battle screen, I wouldn't quite say loading screens because they last for a max of like a second or two at absolute most, but still. The point of that whole ramble is, if it is some sort of memory leak it happens instantly. It's running smoothly at like 1500 fps then I enter a battle and then all of a sudden the game's closed. Also I can't hear any problem with the background music or the sfx of the buzzsaws or attacks or anything either, so I don't even know what this error means or what it's doing. I have looked it up and haven't found anything useful. Anyway, sorry for the long unfocused ramble but I'm just trying to give as much info as possible that may relate to the problem. Thanks to anyone who has any information!
 

kburkhart84

Firehammer Games
I don't know what would be causing it, but since it is reproducible(albeit not easily), you should set up some debugger work, add some breakpoints and/or some debug logs, and you can then pinpoint the exact piece of code(down to the exact line) that is causing it. Once you know that, you may be able to figure it out yourself. If not, you can at the least post the correct code here for us to look at. As it is, unless someone just by chance happens to recognize it, we can't really help, as we don't know much of what is going on.
 

Yizzard

Member
Well... After a bunch of trials, I found out that it seems to be happening sometimes when you are in the battle screen still after a battle if you just wait a while. So I have no clue how this could be possible. The game was just idling on the end battle screen while I waited for a few seconds and then it just exited without any input from me at all. Again with no fps drop or anything. Since it was in battle my fps average was 3275 and the fps on the last debug frame was 3017. I don't at all understand how it could crash while just idling unless it was some sort of memory leak or something but that would cause a frame drop right? Also I didn't once get an OpenAL error during that last battle that crashed the game, so I don't even know if that's related at all at this point. Is there any way for me to check for memory leaks, or is a memory leak even possible without a huge frame drop before the crash? I'm just at a complete loss at this point.
 

kburkhart84

Firehammer Games
I mentioned the debugger before right?! The profiler is part of the debugger. You can easily see if memory usage is increasing during that time period if you open it up and take a look.

I highly recommend learning a few things about the debugger. It has so many features that will come in handy for exactly these situations.
 

Yizzard

Member
Ok so I never had even heard of the profiler before now, I read through those guides and I knew about pretty much everything besides the profiler and buffers (although I still don't really understand those lol but that's ok, I don't think they're super applicable to this situation?) Anyway, after further testing I found something a little strange.

Overly Detailed Account:
The obj_GenericEnemy.Draw event is taking up most of the Step% and it seems to just keep going up indefinitely if I idle on the enemies death screen. This is very strange to me as the enemy plays their death animation with their health bar above them and then once the animation is over, it sets the image_speed to 0 basically freezing on the last KO frame. The thing is, the last frame for specifically the enemies in this level is all empty. Their KO animations for 2 of them is they run off screen and so the last frame is just empty, and the 3rd enemy type explodes and also leaves nothing in the final frame. Why would drawing a blank frame cause memory issues? Anyway, I idled it on the death screen for a very long time and the enemy's draw even just kept climbing Step%, even though the text on the screen and the Player character's draw (which is also visible) both stayed fairly steady and even may have very slightly been going down to accommodate for the enemy's draw going up in percentage. That makes no sense to me as the enemy's draw event (which btw was over halfway taken up by the draw_self event, the rest of which was for draw_sprite_ext and such used for drawing the health bar). The enemy's draw event took up about 7% at the beginning of idling then after a little while it was at 18.5% and was still slowly climbing. After like 20 minutes it was nearing 20% and so I decided to just continue. The weird thing is that the draw_self event was climbing pretty quickly but the other stuff was climbing too, just very slowly. Anyway, the percentage did overall seem to be slowing down in its climbing speed, but it's hard to tell by how much really, but once it got to upper 19% it did seem to be going very slowly. I then ran a test where I made the final frame for one of the enemies to not be fully empty and rebooted the game to see if it would still climb. Again it started at like 7% and after like 15 minutes or so it was at like 18.5% again, so that didn't seem to be it. I again restarted it, but this time I added a line that basically just said if(image_speed == 0 && sprite_index == koSprite) then don't draw_self for enemies. This time it started at like 5% but very quickly rose to 15% within like 5 minutes or less, even though now draw_self was way down to .3%, and within like 20 minutes it was around 18.5%. So an improvement, but much less of one than I expected. I continued on and just quickly fought my way through a bunch of enemies and the game finally had its first crash after fighting a couple more enemies. There were no spikes in anything right before, it just closed out like normal.

TLDR:
The obj_GenericEnemy.Draw event seemed to be taking up a whole lot of memory during the end of battles, and for some reason kept taking up more and more space even though it's nearly identical to the obj_Player.Draw event and that one wasn't taking up that much memory. Most of which was taken from the draw_self event. I then made it just not do the draw_self event after the enemy was dead, and it was only a small improvement. Then I just fought a bunch of enemies and upon exiting a battle the game crashed for the first time doing this experiment with no spikes in usage anywhere directly beforehand.


So in the end I don't think this really gave me any useful information, as I only found that for some reason the enemy's draw was using more memory than I expected, but I don't think it was a memory leak or anything since it seemed to not really ever hit or surpass 20% Step%... And with no spikes beforehand, I have no clue what could've possibly caused it.
 

rIKmAN

Member
Just a guess here but have you tried removing / re-creating your Audio Groups, maybe something got corrupted somehow and they aren't being read properly?
If you have access to another PC try it on there and see if the same issue happens to rule out it being specific to the PC you are currently testing on.
Ensure all drivers are up to date (especially sound drivers) and all the "usual" drivers as well if you haven't already just to tick another possibility off the list.
Uninstall / Re-install OpenAL - again just to rule it out and it's basically removing as many variables as possible from the equation on your side.

If none of those affect the issue I'd also file a bug report and attach the project to the report
If possible give reproduction steps if you have any as that will help YYG narrow it down - even if they are not 100% repro steps they will help.
 
Last edited:

Yizzard

Member
I deleted and remade my Audio Groups, and have already tried exporting the game and running it on like 2 other computers, both of which had the glitch (one seemed to have it worse strangely, but since it's fairly random it could've just been by chance) All my drivers are up to date, and I'm not sure how to uninstall/reinstall OpenAL, but I feel like since it's happening on other computers that shouldn't have anything to do with it. I guess I'll try sending a report to YYG? I'm honestly not sure if it's a problem on my end or if it is something wonky with GMS at this point since I literally cannot find a single problem with memory usage/errors or anything.
 

rIKmAN

Member
A quick Google led me to a couple of threads with the same error number that seemed to be issues with loading the file headers incorrectly when doing so manually.
After narrowing the search by adding "GameMaker" to the search query another thread popped up that had this same error by another user on here.

It turned out to be one of the sound files that was likely the culprit (damaged/incorrect header mosty likely based on the other results where they were manually reading the headers themselves in code). Long story short the user said that they fixed the issue by reimporting all of their music.

Would be worth trying the same thing as a damaged header file makes the most sense based on the results of my search.
Maybe try reimporting everything first and if that doesn't work try again in batches testing between each batch until you start to get the error again and can narrow things down until you find the exact file that is causing it.

Even if this works I'd still file a bug as the IDE could probably give more information to the user if/when a bad/corrupt file is found either at the time of import ot compile time when it checks if it needs to convert any of the audio files based on the originals format and the settings of the user.
 

Yizzard

Member
I actually did the same google before making this thread and already reimported all of the sfx and music that are used in this level. I can try it again tomorrow though, maybe it got double corrupted or something idk. I already filed the bug report and linked this thread in the report though, so if it works then they'll have record of it still.
 

Yizzard

Member
Just to update, I reimported all of the audio files in the entire game, and still got the error. It didn't crash, but that was only one playthrough, and it often doesn't crash in only one playthrough, so I think given that the errors are still happening it didn't work...
 

Yizzard

Member
So, it's been a while but this bug still hasn't been resolved. I have now found out that the crash isn't being caused by the room it is crashing in, rather it must be the previous room. I tried making an entirely new room with just a couple of platforms and some enemies in it and putting that as the next room instead of the one that's been crashing and it still crashed. I then made a way to get to the crashing room via another room later on in the game, and it no longer was crashing at all. So this tells me that the crash must be a result of something that happened in the previous room.
 

Yizzard

Member
Oh also, another update, I no longer get the OpenAL error hardly ever, but the crash still happens, so that's weird.

But I'm now wondering if maybe the game is actually closing on purpose thinking it's supposed to for some reason, since the game doesn't give any error report. I don't think it's the game_end() event, because the way the output log looks is the same as if you press the red x in the corner, saying "X://windows/Runner.exe exited with non-zero status (-1073741819)" instead of the exited successfully or whatever it says when you use game_end(). Is there any other exit thing it can do? And can you put a breakpoint inside of game_end() to test if that is it?
 

Yizzard

Member
Ok so one final thing, I ran through the game where starting a new game immediately goes into the room that crashes. It still crashed. Then I moved that room back to right before this one cutscene, it still crashed. Then I moved it back to right after that cutscene, and it no longer crashed. So clearly something is being initialized in that one cutscene that is stopping the crashes.
 

Yizzard

Member
I found out kinda what is causing it now, it's not having a weapon equipped. (The cutscene previously mentioned gives you your first weapon so that's why it worked after it). I gave the player a weapon right at the beginning of the game and played through the level 3 times with no crashes. Then I unequipped the weapon on a later save, and it crashed. So that's very helpful to know. There is an object called obj_NoWeaponEquipped that is basically a placeholder weapon that is used whenever the player has no weapon equipped that basically is treated as a fairly weak weapon. This object didn't have an event_inherited() in it's create code like all other weapons did, so I thought maybe that could be it, but when I added it it still crashed. So now I know that it's the fact that you have no weapon that causes the crash, but I don't know if it's the obj_NoWeaponEquipped object or something else actually doing the crash. It's very weird that this is the cause given that at the beginning of fights weapons are more or less loaded in then used to replace the basic attack of any character with the attack of the weapon, and then never referenced again throughout the battle, so I would think that would be when they crashed, or when equipping/unequipping weapons, but again that's not when crashes are occurring. They typically occur right after a battle while the screen is still fading into the overworld, but sometimes happen at random other times, which doesn't really make sense. But still, this is quite a big discovery.
 

kburkhart84

Firehammer Games
If you would add some debug messages like I had mentioned before(or some breakpoints), you would be able to more directly pinpoint at exactly which line the crash is happening. I'm guessing there is something that your weapons do that your "NoWeapon" does not, and so by pinpointing that, you can see exactly what is causing the crash and what is missing from your "NoWeapon" thing.
 

Yizzard

Member
Holy crap I think I fixed it, I just ran through it three times in a row with no crashes. No idea how what I changed fixed it, but it seems to have. I found that upon setting a player's weapon as it's basic attack, the NoWeaponEquipped was being set slightly differently. It still wasn't actually changing anything at all, other than instead of reading from the weapon the variables, I had copy pasted the variables into this part and read the variables into that since I didn't want the name of the attack to be "No Weapon Equipped!" since that is what the name of the object was and that's how it determines the name of the attack for weapons, so I literally just made it read it from the weapon instead, except for the name and the description of the attack, which I kept the hard coded into thing and somehow that fixed it. Makes no sense at all as I walked through the code there multiple times and the variables were all set to the correct thing every time, and now they are still being set to the same things, but for some reason the fact that it's reading it from the weapon is now making it not crash. So... That makes sense... But whatever, it's working now. I still believe this to be a GameMaker bug though as there was never any crash report, it just closed out of the program each time, and I fixed it by doing something that doesn't actually change anything, but that's fine. It works and that's what matters lol.

And I was using breakpoints quite frequently. The problem was not having any idea of where to put them since I had no idea what was determining whether or not the crash was and the fact that the crash was happening at random times and not consistently. I've never had a bug like this one in my life and I've been coding for like 10 years, the past 2 of which have been in GameMaker.
 

Yizzard

Member
If you're curious as to what I changed to fix it,



I changed the scr_setAttackToItem (which sets the players basic attack to the item they have equipped) from:
GML:
//Attack option changes to current weapon
with(argument0)
{
    if(inventory[0] != obj_NoWeaponEquipped)
    {
        action[0] = inventoryName[0];
        actionEff[0] = inventoryEff[0];
        actionTarg[0] = inventoryTarg[0];
        actionDesc[0] = inventoryDesc[0];
    }
    else
    {
        action[0] = "Attack";
        actionEff[0] = [15, 100, 0, 0, attackSprite, attackSound]; //0 attack, 100 acc, eff # 0 (no effect), effLvl 0
        actionTarg[0] = 2;
        actionDesc[0] = "The user attacks the opponent";
        actionAP[0] = 0;
    }
}
To:

GML:
//Attack option changes to current weapon
with(argument0)
{
    if(inventory[0] != obj_NoWeaponEquipped)
    {
        action[0] = inventoryName[0];
        actionDesc[0] = inventoryDesc[0];
    }
    else
    {
        action[0] = "Attack";
        actionDesc[0] = "The user attacks the opponent";
    }
    actionEff[0] = inventoryEff[0];
    actionTarg[0] = inventoryTarg[0];
}
which makes no sense as I walked through those variables and they were all being set correctly (the only difference was that I changed the noWeaponEquipped's inventoryEff to [10, 90, ....] from [15, 100, ...] Which just determines the power and accuracy of the move, but I walked through this section in the debugger multiple times and all variables were being set properly other than that one change with the power/accuracy of the move being altered. I also deleted the actionAP[0] = 0 thing because upon walking through there I realized that it already was always at 0 so there was no need to change it to 0. So I'm not sure at all how this could possibly have been causing a crash, especially since it wasn't ever crashing during the part that this code would be running, but somehow it did.
 
Top