Date First Experienced: 4/14/2024
Date Last Experienced: 4/14/2024
Issue: Upon changing the Visibility of a Frame, the previous rendered position gets rendered again.
Reproduction Steps:
Create a ScreenGui in StarterGui & Insert a Frame
Insert a LocalScript under the ScreenGui, with this code:
local frame = script.Parent.Frame
local elapsed = 0
while true do
local deltaTime = game:GetService('RunService').RenderStepped:Wait()
elapsed += deltaTime
if (elapsed > 1) then
elapsed = 0
frame.Position = UDim2.new(0.5, 0, 0.5, 200)
frame.Visible = true
print('visibility set to true, offset:', frame.Position.Y.Offset)
task.wait(1) -- // to better visualize the bug
elseif (frame.Visible) then
warn('moved back to center and set visible to false')
frame.Visible = false
frame.Position = UDim2.fromScale(0.5, 0.5)
end
end
Play-test and observe the Frame bug.
Video of the bug:
Notes:
This bug only occurs when connected to RenderStepped or PreRender.
It seems like the __newindex call is delayed by one frame.
Expected behavior
Expected behavior: Frame will render at the current position, not the previous position.
I’ve been noticing a very similar issue since last week. RenderStepped, PreRender and metatables don’t seem to impact the behavior at all in my case. The issue doesn’t always happen either, but when it does happen it is very consistent.
Below is a video of a character select I created. When I select a locked character I toggle the visibility of a green purchase button. You can see that as soon as it becomes visibile that for one frame its location and size are wrong. You may have to play the video at a lower speed to even notice the issue.
On top of the ‘teleporting’ issue the text inside the green button also becomes smaller than it should be despite TextScaled being set to true. Originally I thought this problem was related to the UIFlex beta being used, but the issue Trooper reported here seems extremely similar to mine despite not using any of the UIFlex beta features in their repro steps.
I’m able to reproduce this much more frequently in plugins. Making plugins visible cause elements to render in a previous position for one frame. It’s more prominent with text being unaligned and out of the TextBox for one frame.