I’ve been utilizing the Gameplay Ability System for a project of mine, and I’ve encountered a weird bug with one of my Gameplay Abilities in particular.
Every first time the player uses the ability, the game has a micro-freeze. If I’m testing in the editor, the issue doesn’t repeat until I’ve completely closed out of the Unreal Editor and re-opened it. If I’m playing in a Standalone build, it happens every time I boot up a new instance of the standalone game.
I narrowed down the issue to two nodes in particular: The CommitAbility node, and the ApplyGameplayEffectToOwner node. I wanted to narrow down this issue to the CommitAbility node, so I created an override of the C++ method, and added some profiling info in order to figure out what was going on in more detail.
Upon replicating the issue and observing the information, I found out that K2_CommitAbility is calling ObjectLibrary/Engine/Transient.ObjectLibrary whenever this spike happens, and that particular call is taking around 140 ms, give or take.
I’m not sure what this is doing, and quite frankly I’m not sure how to fix this. None of my other abilities cause any sort of freezing like this, it only seems to happen with this ability in particular.
[Here’s a pastebin of the Blueprint if anyone would like to see.][1] I’ve disconnected and tested everything and it’s only the CommitAbility and ApplyGameplayEffectToOwner nodes that cause the freezing. Also, ignore the two “WaitForGameplayEvent” nodes back-to-back, it was part of a test in order to get the ability to activate at the right time.
(I have also tried “CommitAbilityCooldown” since I don’t use an MP/stamina system, and I’ve encountered the same issue)