Mark Abent is here in Bugsmashers with a bug about Star Marine
As per usual, anything said during the show is subject to change by CIG and may not always be accurate at the time of posting. Also any mistakes you see that I may have missed, please let me know so I can correct them. Enjoy the show!
Game suddenly pauses or if you die/revive your game pauses
This is caused by skins(face and hands) being constantly loaded and unloaded every time you revive or respawn rather than keeping it there in memory
What Mark does is configure the skins to preload to a degree so that they are not having to reload the assets every time from scratch.
Mark Abent: Hey everyone, welcome to Bugsmashers. I’m your host Mark Abent, I’m a Gameplay Programmer here at CIG, Los Angeles and I’m here to show you some bugs that we smashed and let’s take a look.
So, this bug is when you’re having fun playing Arena… I’m sorry, Star Marine and you’re having a fun time shooting and all of the sudden your game pauses or if you die and you revive your game pauses. So what’s happening...well, we have our character here and as you can see what we have is we have this body and then we have his face and then his hands and those hands and face… they’re called skins. So we have a skeleton which is his body and then we have skins and a face which are still the same thing. They get attached to his skeleton and they become embedded and those extra, extra bits of geometry that get tangled into making what he is and his skeleton is preloaded and it stays in memory til it’s no longer needed and then it will eventually unload. His skins on the other hand, they’re constantly loaded and unloaded every time you revive or respawn as a character and that’s what’s causing these big performance drops because we have to unload it and then reload it, unload it then reload it, rather than keeping it there in memory.
So what we’ve done is added a resource caching for skins just like all our other geometry. So that we don’t have get this stall, so let’s see what that stall looks like. So if I kill this guy and I revive on this guy… oh, I can no longer move the mouse because he’s stalling loading the other guy and you can see it can be quite severe on some machines and other instances it can be a few milliseconds… on this guy it’s a full couple seconds.
So, let’s go into the code and we have this thing called a global resource skin is what we made to preload skins and what we want to do is enable it. So… what this does is any time that there’s a skin resource either through DataForge or through XMLs, it will load this particular thing in which we’ll know it’s a skin resource and on unload it’ll load our skin once and any time we use it we’ll add one of these rough counts and the idea is when we die we have our ragdoll which will bump the rough count up. We revive, we have the player which bumps the rough count up to one and then the ragdoll goes away which releases one of the counts and we still have one count so we don’t have a stall and eventually when the player and the ragdoll go away because... well, the player left and there’s no one using his face or his head it removes the resource cause it’s not needed anymore.
So, let’s recode and see what happens. All right, so back into the game and we’ll kill this guy and as we take time to respawn… funny enough before we were doing this fix, we actually stuck in a bunch of the heads in the level as a temporary fix so all the heads would be loaded so it wouldn’t cause any stalls til the code was ready. Once code was ready we removed the heads and now we have a proper code fix. So we respawn and as you can see I’m able to move around just fine, there’s slight delay but not as bad as it was before cause we’re actually keep the head in memory or skins in memory until we’re not needed anymore. So, we die and respawn, die and respawn, it won’t have to load them cause they’re already there in memory. Well, hope you guys enjoyed.
So as you guys saw we had a little fun bug where if your player dies and he revives, he’ll completely stall for a few seconds depending on your machine could be like nothing or if you have a slow hard drive it could takes seconds in which really gets frustrating cause you want to get back into the battle, kicking ass or just dying again. So, what happened is… well, we have a way to precache a bunch of geometry and things like the player’s body or skeleton, that gets preloaded and it stays around so if he dies and revives, it’s there so it just makes a copy, but his hands and face, they don’t so when you die and revive it has to reload them again which causes the stall. So all it was is we had to add a little bit of preloading so those skins stay intact so when we die and revive it knows just to plop them back there and not load a big resource hogging thing. Well, hope you guys enjoyed, til next time.