UpdateGeometry Clientside Lagspikes

Hello, my game’s been getting this lag spikes with weird lighting on rare occasions. Does anyone know if this is a engine bug or just my game?

It started happening all of a sudden, since the changes I made to the map is very minor and mostly code changes in the past week.

Thanks in advance,
MXKhronos

2 Likes

The MicroProfiler’s crippling lack of information leads to threads like this.

Using the name of the label UpdateGeometry as a point of assumption, I can assume that there is something interaction-heavy regarding parts in your game. Are you aware of any intensive codebase having to do with parts? Doesn’t matter where they are, ViewportFrames count as well (though they’re typically static post-render).

I’ve located the source of the cause.

So what happens is that, my game has a cutscene system and each client has their own NPC but are controlled server sided, and to avoid clients from seeing other client’s NPCs, my replication manager module locally removes them so all clients only see their own NPC.

remoteReplicationManager.OnClientEvent:Connect(function(child, parent)
	if child then 
		child.Parent = parent;
		if parent == nil then
			local humanoid = child:FindFirstChildWhichIsA("Humanoid");
			if humanoid then humanoid.Parent = workspace; end
		end
	end
end)

I recently added this section of the code:

if parent == nil then
	local humanoid = child:FindFirstChildWhichIsA("Humanoid");
	if humanoid then humanoid.Parent = workspace; end
end

And it seems to be the cause of the lagspike, framerate issue and weird lighting issue. I added this section is so that server will stop trying to play an animation on a dead humanoid, normally it just spams the client console with Humanoid has to be a descendant of workspace to play animation.

However, what I don’t understand is why is this causing the client to have the issues?

Humanoids are relatively hacky and expensive by nature of their backend code. Adding a Humanoid to the Workspace does cause unexpected issues: avoid parenting the Humanoid to the Workspace.

I’m not too sure why you need to push the Humanoid to the workspace. You can use pcall before playing an animation if an edge case such as playing animations on a dead humanoid come up. This’ll prevent the error from showing and the script from terminating.