Reproducible DockWidgetPluginGui BindToClose crash

Describe the bug

Creating a new DockWidgetPluginGui inside a function executed by spawn inside another DockWidgetPluginGui’s BindToClose function, and enabling the new DockWidgetPluginGui before disabling the original DockWidgetPluginGui causes a studio crash 100% of the time when the original DockWidgetPluginGui is closed.

How often does this bug happen

100% of the time, tested on multiple OSX machines, when using the repro plugin code below.

OSX Version: 10.14.4
Studio Version: 0.385.0.303034

Steps to reproduce

  1. Save the following as a .lua file in your local plugins folder.
local info = DockWidgetPluginGuiInfo.new(
	Enum.InitialDockState.Float,
	false,
	true
)

local mainWidget = plugin:CreateDockWidgetPluginGui("TestWidget", info)
mainWidget.Enabled = true

mainWidget:BindToClose(function()
	spawn(function()
		local errorWidget = plugin:CreateDockWidgetPluginGui("ErrorWidget", info)
		errorWidget.Enabled = true
		mainWidget.Enabled = false
	end)
end)
  1. Close the widget created

Other info

Interestingly this bug does not happen if mainWidget.Enabled = false and errorWidget.Enabled = true are swapped.

2 Likes