RunService.Heartbeat:ConnectParallel() in Actor causes crash if Actor is :Destroy()ed upon stopping Play/Play Here simulation

Studio Bug: RunService.Heartbeat:ConnectParallel() in Actor causes crash if Actor is :Destroy()ed upon stopping Play/Play Here simulation

A studio crash occurs if the Actor containing the Heartbeat:ConnectParallel() connection is destroyed at the moment a simulation started by Play or Play Here is stopped (e.g. through game:BindToClose() or Players.PlayerRemoving:Connect()). A crash does not appear to occur when using other frame-related events such as RenderStepped or Stepped.

This crash did not occur prior to the recent Studio update (August 25-26?, 2022).
edit: Crash still occurs as of 9/9/22.
edit edit: Crash has been solved as of 9/14/22 (see post marked as solution).

Reproduction Steps:

On an empty baseplate:

  • Create an Actor with a Script under it and create a RunService.Heartbeat:ConnectParallel() connection within the Script
  • Create a Script outside the Actor that will call :Destroy() on the Actor upon the stopping of the simulation
  • Press Play / Play Here under Home > Test, then press Stop

Studio should then crash with the error “An unexpected error occurred and Roblox needs to quit. We’re sorry!” The crash occurs constantly, but not 100% consistently.
The crash occurs regardless of plugins being enabled or disabled.
The crash appears more likely to occur if the Character has fully loaded in.

Sample Actor script
local heartbeatConnection = game:GetService("RunService").Heartbeat:ConnectParallel(function(deltaTime)
    task.synchronize()
    print("synchronized step")
end)
Sample :Destroy() script
game:BindToClose(function()
    workspace.Actor:Destroy()
end)

A minimal reproduction place is available below:
actorcrash.rbxl (35.2 KB)

Expected Behavior:

Roblox Studio does not crash upon hitting Stop.

Actual Behavior:

Roblox Studio crashes.

System Information:

OS: Windows 10
CPU: Intel(R) Core™ i7-8550U CPU @ 1.80GHz
Memory: 12.0 GB
GPU: Intel(R) UHD Graphics 620

update: can replicate crash on other laptop, albeit with less frequency
OS: Windows 10
CPU: Intel(R) Core™ i7-6700HQ CPU @ 2.60GHz
Memory: 16.0 GB
GPU: NVIDIA GeForce GTX 980M

Crash Dump:

A crash dump has been sent privately to @bug-files.

Issue Area: Studio
Issue Type: Crashing
Impact: Medium - High
Frequency: Constantly
Date First Experienced: 2022-08-26 00:04:00 (UTC)
Date Last Experienced: ongoing

2 Likes

Thank you for the report and an example.
We have found what causes this and there will be a fix later today.

2 Likes

The issue has been fixed now, it should no longer crash after the script is destroyed.

2 Likes

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.