The documentation about the ordering of RunService events is incorrect

title self explanatory

Everything is correct, except the part where it says that .PostSimulation runs before .Heartbeat, when the opposite is true:
image

In microprofiler, it appears that .PostSimulation runs after .Heartbeat:

The code to reproduce this: (localscript in StarterPlayer)

local RunService = game:GetService("RunService")

local function logevent(eventName)
	debug.profilebegin(eventName)
	for i = 1, 10000 do local a = Random.new():NextUnitVector() * math.random(100) end -- junk work to lengthen the frame
	
	debug.profileend()
end

-- it doesnt matter in which order the events below are connected to a function

RunService.PreRender:Connect(function()
	logevent("PreRenderEvent")
end)

RunService.RenderStepped:Connect(function()
	logevent("RenderSteppedEvent")
end)

RunService.Stepped:Connect(function()
	logevent("SteppedEvent")
end)

RunService.PreAnimation:Connect(function()
	logevent("PreAnimationEvent")
end)

RunService.PreSimulation:Connect(function()
	logevent("PreSimulationEvent")
end)

RunService.PostSimulation:Connect(function()
	logevent("PostSimulationEvent")
end)

RunService.Heartbeat:Connect(function()
	logevent("HeartbeatEvent")
end)

The correct ordering of the events according to the microprofiler, are:

  1. RenderStepped
  2. PreRender
  3. PreAnimation
  4. Stepped
  5. PreSimulation
  6. Heartbeat
  7. PostSimulation

Repro file: runservice ordering doc issue repro.rbxl (55.1 KB)

Page URL: https://create.roblox.com/docs/studio/microprofiler/task-scheduler#scheduler-priority

1 Like

Already tried fixing this with a previous PR, but it’s the code itself that is incorrect. PostSimulation is intended to run before Heartbeat, even though the opposite is currently true. I believe this is being worked on internally.