Parenting objects to UIGridLayouts causing extreme lag all of a sudden

Recently, after having changed nothing in our game, UIGridLayouts are causing lag/complete freezing when parenting a large amount of ImageButtons to a frame that has a UIGridLayout under it. This does not occur when using UIListLayouts.
Players started reporting this 1-2 weeks ago, and we have not updated anything in our game to have caused this. It is consistent everywhere that we use UIGridLayouts.

To demonstrate this with a slightly extreme example, modifying and parenting 2621 ImageButtons to a frame that has a UIListLayout under it will complete in roughly 0.3 seconds. Trying to do the same under the same frame, this time with a UIGridLayout, will take too long in studio and will result in a Script Timeout error.

Code of the for loop that is responsible for the parenting

for i = 1, #PN.FirstNames do -- or for i = 1, 2621 do
	local cn = PN.FirstNames[i]
	local nn = script.NameOption:Clone()
	nn.Name = cn
	nn.Title.Text = cn
	if cn == ChosenFName then
		nn.BackgroundColor3 = Color3.new(0.5, 0.5, 0.5)
	end
	nn.Visible = true
	nn.MouseButton1Click:Connect(function()
		if Fade.Visible == true then return end
		UI.Click()
		ChosenFName = cn
		Frame.Info.Selection.Text = "Chosen Name - "..cn.." "..ChosenLName
		local Search = FFrame.List.Frame:GetChildren()
		for o = 1, #Search do
			if Search[o].ClassName == "ImageButton" then
				if Search[o] == nn then
					Search[o].BackgroundColor3 = Color3.new(0.5, 0.5, 0.5)
				else Search[o].BackgroundColor3 = Color3.new(0, 0, 0) end
			end
		end
	end)
	nn.Parent = FFrame.List.Frame
end

Hierarchies of used objects:
image
image

Properties of the UIGridLayout and UIListLayout used:
image
image

CellSize is meant to be edited in the script after parenting everything, though the script always times out before being able to do that.

Further properties of any objects, a video demonstration of the freezing, or any other relevant information, can be provided if needed.
Device specifications can be provided if needed, though this has been reported by a large majority of our playerbase.
For reference, this is occuring in Arcane Odyssey

48 Likes

We need this addressed ASAP, players opening their inventories in our game sometimes freeze for 3+ minutes or even crash since this change

30 Likes

does this happen if the sortorder is changed from name to layoutorder? i could reproduce the bug if the sortorder on the layout (happens to both gridlayouts and listlayouts) was “Name” utilizing this code, but it does not happen if i switch it to ‘LayoutOrder’

	for i = 1, 5000 do
		local button = script.TextButton:Clone()
		button.Name = tostring(math.random(1, 2321)) 

		button.Activated:Connect(function()
			print('awesome')
		end)

		button.Parent = script.Parent -- scrollingframe
	end

image

rbxl file
uilayoutthing.rbxl (64.3 KB)

4 Likes

Hi moochezz, we’ve rolled back a suspect flag for this issue. Could you confirm if the extreme lag still occurs?

9 Likes

Appears to be fixed now, thank you!

9 Likes