:ApplyLayout crashes the game

I am using UIGridLayout for an inventory system that sorts the items dynamically like this:

function sort(v)
	if v == "  Name" then
		uiGridLayout.SortOrder = 0
	elseif v == "  Price (Low)" then
		uiGridLayout:SetCustomSortFunction(
			function(a,b) 			
				return a.Stat.Price.Value < b.Stat.Price.Value
			end
		)
		uiGridLayout.SortOrder = 1
	elseif v == "  Price (High)" then
		uiGridLayout:SetCustomSortFunction(
			function(a,b) 			
				return a.Stat.Price.Value > b.Stat.Price.Value
			end
		)
		uiGridLayout.SortOrder = 1
	elseif v == "  Amount" then
		uiGridLayout:SetCustomSortFunction(
			function(a,b) 			
				return tonumber(string.sub(a.Quantity.Text,2)) > tonumber(string.sub(b.Quantity.Text,2))
			end
		)
		uiGridLayout.SortOrder = 1
	end	
	uiGridLayout:ApplyLayout()
end

but whenever I run this function online the game crashes. The weird thing is that it works fine in studio, does not crash and sorts correctly with no errors.

It’s my first time using it so might be just me using it incorrectly. But since it only crashes online and works perfectly fine in studio I don’t know how to fix this.

1 Like

@Tiffblocks

1 Like

This is a bug I’ve been trying to track down for a while, hopefully I’ll get around to fixing it soon now that I have a repro for it.

3 Likes

Pretty annoying. Tried to fix it for like 2-3 weeks, eventually switched over to LayoutOrder, making a special algorithm for it.

Thanks for looking into this. Is it possible to have a timeframe for this fix? Not meant to rush you, just need to know if it’s worth switching to something else in the meantime.

You can use LayoutOrder instead in the mean time. I’m not sure what the timeline is, it depends on when I’ll have time to work on it. But if I were to fix it immediately it’d still take about 2 weeks to be live.

1 Like

Are you still working on this? This bug is pretty annoying.

The fix is waiting to ship.

1 Like

Great to hear, thanks!

The bug should be fixed now.

2 Likes

Praise the Lord! Thanks @Tiffblocks!