LandscapeLeft / LandscapeRight / LandscapeSensor sometimes is not applied immediately

I have ScreenOrientation set to LandscapeRight in my game. And what I am doing in some scripts is that I declare a constant this way:

local SCREEN_AREA = GuiService:GetInsetArea(Enum.ScreenInsets.None)

Unfortunately, despite the fact that ScreenOrientation is applied sometimes it takes time for Roblox to see it and because of that scripts will have SCREEN_AREA set as 400 x 900 for the rest of the execution and not 900 x 400.

I will try to make a reproduction file soon.

inset bug.rbxl (75.3 KB)

We set ScreenOrientation to keep horizontal screen:

We have this simple script:

local GUIService = game:GetService("GuiService")
local none = GUIService:GetInsetArea(Enum.ScreenInsets.None)
print(none.Width, none.Height)

task.wait(1)

local none = GUIService:GetInsetArea(Enum.ScreenInsets.None)
print(none.Width, none.Height)

Another strange behaviour that appears is that DeviceSafeInsets are changing dynamically:

I am using iPhoneXR.

I’m sure this is because of the screen rotation occuring during Roblox App - Game

Probably, but it’s so annoying tbh :frowning:

And I am not sure it explains change of the size of DeviceSafeInsets.

The cross experience print statement thing in the console is annoying too so many people including me have it and idk why

1 Like

i still don’t know what is it lol. what is it?

I don’t know I can’t figure it out

1 Like

Hey! This looks like a timing issue rather than something wrong with your code.

ScreenOrientation isn’t applied immediately — the engine updates it asynchronously, so if you query things like GetInsetArea right after setting it, you can still get values from the previous orientation for a frame or two.

Instead of reading it once (especially during initialization), you might want to listen for when the orientation actually updates:

local GuiService = game:GetService("GuiService")
local playerGui = game.Players.LocalPlayer:WaitForChild("PlayerGui")

local function update()
	local area = GuiService:GetInsetArea(Enum.ScreenInsets.None)
	print(playerGui.CurrentScreenOrientation, area)
	-- update your layout here
end

playerGui:GetPropertyChangedSignal("CurrentScreenOrientation"):Connect(update)

This way you’re reacting to the real applied orientation instead of racing it.

Hope that helps!

1 Like

Will close this bug and mark as “Won’t Fix” since the above solution should resolve the problem. Thank you for taking the time to share the report.