AnimationTrack limit exceeded error is unhelpful

We’re seeing this error in our game: “AnimationTrack limit of 256 tracks for one Animator exceeded, new animations will not be played”
This happens after we leave the game running for a while (~30 minutes). We’re not sure of the underlying cause - breakpoints on every loadAnimation call seems to reveal nothing, but this error could be improved to help us track this down (or report a better bug).

We’ve output the list of playing animations on every animator, and none have more than 4, but I presume this error refers to any loaded animation not just playing ones.

Expected behavior

I’d like to see the error report at least the path to the Animator causing this issue and ideally a call stack that shows where this error is coming from - does it come from loading or from playing an animation? Ideally I’d like some way to see what these 255 animation tracks are (though, obviously listing these all in the error is not ideal).

I took a look at the code to confirm, this error should only happen if there are 256 active animation tracks playing on the animator. This would indicate tracks keep getting added but are never stopped.

However, it sounds like you are calling animator:GetPlayingAnimationTracks() on every animator and are not seeing hundreds of tracks piling up. That’s a bit concerning because it would indicate there is some other source leaking animation tracks that don’t show up when you call GetPlayingAnimationTracks but do count against the 256 limit.

Would it be possible to get us a place that reproduces this issue?

I’m pretty sure you have to :Destroy() the animation instance after it’s stopped. Ths 256 animation tracks still add up even when stopped the way it’s demonstrated in the Animate script is that you :Destroy() the loadedanimation after you’re done using it. This is the alternative to keeping all the animations :Loaded into the humanoid at the start and playing them as needed versus :LoadAnimation as needed in real time.
If all else fails, the most effective way to stop all the animations is by setting

 LoadedAnimationInstance.Looped=false --(sometimes some animations just won't stop playing) 
LoadedAnimationInstance:Stop(.1) 
task.delay(.2,function() LoadedAnimationInstance:Destroy() end)

This is a function snippet from my code base


local	function StopAllAnimations(humanoid)
	if humanoid and humanoid:IsA("Humanoid") and humanoid:FindFirstChild("Animator") then
		local animator = humanoid.Animator
		local animationTracks = animator:GetPlayingAnimationTracks()
		for _, animationTrack in ipairs(animationTracks) do
			
			animationTrack:AdjustSpeed(1) animationTrack.Priority=Enum.AnimationPriority.Core	animationTrack.Looped=false
			animationTrack:Stop(.1)
		end
		
	end
end 

Here I am using every method of the LoadedAnimation known to man to make the animation stop,
But overall, I’ve seen your issue before and it’s caused by not destroying the invisible Loaded Animation instances.
I’ve had other issues with animations such as the animation not even stopping which is why Looped and animationTrack.Priority are used.
.
One more thing to note! Animations loaded on the server can only be stopped on the server by the server. They may appear to stop on the client, but are actually still playing on the server. Which means they still count towards your animation track limit unless Destroyed on the server.

EDIT: I didn’t do my devforum search hard enough as there was a ROBLOXCRITICAL report about this yesterday as it was an exploit (that was my third theory, my game is often targeted by exploiters)

Sorry to bump this thread but I am having a similar issue in my game Obby Royale. The problem is that I do not load any animations myself.

First I noticed that my developer stats log would have thousands of entries

Today I managed to dive into one of these servers as someone reported it as it was happening. The logs on both the server and the client were being bombarded with the warning and the game was severely lagging for everybody - down at only a few fps.

In the script stats I could see from the console, there was an [UNKNOWN] script running at 60 times a second but this is not very helpful.

I only have two theories at the moment; that this is either caused by a rogue avatar item that somehow manages to cause this issue or it’s caused by player respawn behaviour - but if this were true then I would expect to have seen this in my game before, and it has only started recently with no changes to respawn behaviour.

As you can see here on a longer timescale, the issue has been around for at least 30 days but has got significantly worse recently (also with a 32 track version?)

As there are no animations being loaded in my game and have been no recent changes to how I respawn characters, I would consider this a potentially severe bug being triggered by something in the Roblox client itself.

I noticed nowadays it reports it as being limited to 64. Is this reduction permanent?

image

I noticed this too, it at least errors sooner, but I’m still not sure what causes it in our case.

Good news is with the next Release notes they are introducing a new feature to improve the AnimationTrack limit exceeded warning!

The new error is much more helpful, thank you.

In our case the issue appears to have been caused by us accidentally leaving the default Animate script on the character when we were really driving the animations elsewhere with our own custom script. This error helped identify this as it showed that the animations being played were default Roblox ones rather than our custom ones.