Recently, after having changed nothing in our game, UIGridLayout
s are causing lag/complete freezing when parenting a large amount of ImageButton
s to a frame that has a UIGridLayout
under it. This does not occur when using UIListLayout
s.
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:
Properties of the UIGridLayout
and UIListLayout
used:
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