If you create a bunch of UI widgets every frame/tick and remove and recreate them the next frame, over and over, gradually your server will run slower and slower. Once the server is running slow, you have to end the session and start a new one in order to get back to normal (which probably just moves you to a new server).
I’ve tried this with creating 100 widgets per tick and the server became almost immediately unresponsive. With 30 widgets per tick, the effect is more gradual, but if you leave it running for 5-10 minutes it becomes VERY apparent.
It’s also possible that the bug is due to the way I am recreating the array every time, perhaps the old contents of the array never get garbage collected?
I’ve included the code below for a device that replicates this bug:
using { /Verse.org/Simulation }
using { /Verse.org/Verse }
using { /Verse.org/Colors }
using { /Verse.org/Random }
using { /UnrealEngine.com/Temporary/UI }
using { /Fortnite.com/Devices }
using { /Fortnite.com/UI }
slow_down_device := class(creative_device):
Canvas : canvas = canvas{}
var ColorBlocks : []color_block = array{}
OnBegin<override>()<suspends>:void =
if:
FirstPlayer := GetPlayspace().GetPlayers()[0]
PlayerUI := GetPlayerUI[FirstPlayer]
then:
PlayerUI.AddWidget(Canvas)
loop:
for (ColorBlock : ColorBlocks):
Canvas.RemoveWidget(ColorBlock)
set ColorBlocks = array{}
# make tons of new widgets every frame
for (i := 1..30):
ColorBlock := color_block:
DefaultColor := color {R := GetRandomFloat(0.0,1.0)}
set ColorBlocks += array{ColorBlock}
Canvas.AddWidget(canvas_slot {Widget := ColorBlock})
Sleep(0.0)