Strange parallel luau EDITED: (Something strange with deferred events)

I have an update on the issue I previously posted about.

The problem occurs when you have 40 different actors, and you send a message very fast to each actor and the script waits for the actor’s response using GetAttributeChangedSignal("ActorFinished"):Wait().
or any sort of waiting for a response except:
repeat task.wait() untill actor:GetAttribute("ActorFinished")
because task.wait() yield the thread till the next heartbeat

for _, i in script.Parent.Folder:GetChildren() do
	i:SendMessage("Hello")
	i:GetAttributeChangedSignal("Hi"):Wait()
	print("actor")
end
local actor = script.Parent

actor:BindToMessage("Hello", function()
	actor:SetAttribute("Hi", true)
end)

this error shows up

image

My question now is: Is this a limitations of parallel Luau, a bug, or am I just doing something wrong?

2 Likes

Can you double check if you are changing the attribute’s value right after waiting for GetAttributeChangedSignal multiple times?

Also maybe you could try to make Workspace’s SignalBehavior property to “Deferred” to produce a bug rather than killing the connection completely after it gets called again and again. So you could just maybe find out where the issue is?

Maximum re-entrancy depth exceeded is a signal connection invoking itself over and over AFAIK.

1 Like

The re-entrancy error is emitted when a signal is recursively invoking itself

If you want to try and narrow it down, find an event handler that might be signalling itself

2 Likes

I’m changing the attribute for every actor, not just one actor. Also, Roblox automatically sets SignalBehavior to “Deferred”.

Later, I tried using “Immediate” instead of “Deferred” and it worked fine
But still i dont understand where is the problem coming from

1 Like

I tried everything, and it seems Roblox can’t handle sending messages very fast to over 40 actors and making custom callbacks using deferred events

Have you tested it without using actors? This could very well happen without actors

Either way, sending this many messages between actors is not recommended as sending messages between lua vms is slow, and it currently isn’t running in parallel (though I assume you will change that once you got your system working). It is also not recommended to go between the serial phase and the parallel phase multiple times per frame

I’ve made this module for running computational tasks in parallel, which you might find interesting

1 Like

yea Sending messages between actors very quickly causes the error, but I don’t understand why setting the SignalBehavior property to ‘Immediate’ makes it work fine.

Btw, I looked up your module, and it seems very useful. I’ll be using it.

Okay, I’ve tested something and found that the problem isn’t from the actors.
Here is what i did:

for i = 1, 50 do
	local event = Instance.new("BindableEvent")
	
	event.Event:Connect(function()
		print("Hi")
		event:SetAttribute("EventFinished", true)
	end)
	
	event:Fire()
	event:GetAttributeChangedSignal("EventFinished"):Wait()
	print("Finished")
end

image

This shows the same error without using actors

1 Like