edit: clarified stuffs
Welcome, I’d like to know why this seemingly unorthodox behavior is the case with this function, because of this it seems much less performant of a method to use; compared to connections which have a handy method of checking the yielding and then deciding whether to create a new coroutine or not.
I have tried using yielding, or not yielding, but regardless of whether or not i yield BindToRenderStepped will always print a new wrapped coroutine in the callback.
(This happens irrespective of priority, if you’re curious about that)
Repro: Create a local script that prints coroutine.running() in a bind to render stepped.
game:GetService("RunService"):BindToRenderStep("p", 30, function()
print(coroutine.running())
end)
Here is an image of this happening: Imgur: The magic of the Internet
Also, I believe i’ve found an oddity in bindtorender’s documentation as well. According to the dev hub page for BindToRenderStepped, I quote:
Note: All rendering updates will wait until the code in the render step finishes. Make sure that any code called by BindToRenderStep runs quickly and efficiently. If code in BindToRenderStep takes too long, then the game visuals will be choppy.
This does not seem to be the case, if all callbacks put into a bindtorendertable were called in a generic for, then this would surely be the case as any function having a yield would slow down the updates from other functions. But creating a new coroutine for the callback to run on each time like it’s doing now will allow updates irrespective of whether you yield or not, even at the cost of more resource usage.
Which is why i’m curious on why BindToRender does not use the same solution as connected events? (Fire a connection once with just a print or something, it will lay only on it’s initially created thread. Call it again, but have the callback yield this time. And a new coroutine will be created)