Reproduction Steps
Studio Version: 0.541.205.5410438
OS: Windows 10 Pro
CPU: AMD Ryzen 5
GPU: NVIDIA GeForce RTX 2070
In an empty place file, create a new LocalScript in StarterPlayerScripts with the following code:
local s = Instance.new("ScreenGui")
s.IgnoreGuiInset = true
s.Parent = game.Players.LocalPlayer.PlayerGui
print("vs:", workspace.CurrentCamera.ViewportSize)
print("sg:", s.AbsoluteSize)
print("vr:", game:GetService("VRService").VREnabled)
print("---")
task.wait(2)
print("vs:", workspace.CurrentCamera.ViewportSize)
print("sg:", s.AbsoluteSize)
print("vr:", game:GetService("VRService").VREnabled)
Then test this in Studio Play solo. Try this with and without VR.
Also let:
- SVS = studio viewport size
- VVS = VR viewport size – which is usually (960, 720) I think
Expected Behavior
The output should without VR should have been:
vs: SVS
sg: SVS
vr: false
---
vs: SVS
sg: SVS
vr: false
and the output with VR should have been:
vs: VVS
sg: VVS
vr: true
---
vs: VVS
sg: VVS
vr: true
Actual Behavior
Without VR, the output you should get is:
vs: 1, 1
sg: SVS
vr: false
---
vs: SVS
sg: SVS
vr: false
This means the Camera’s ViewportSize was at (1, 1) when the script ran, then later was updated to the correct value.
With VR, the output should get is:
vs: 1, 1
sg: SVS
vr: false
---
vs: VVS
sg: VVS
vr: true
This means initially the Camera ViewportSize was at (1, 1), the ScreenGui’s AbsoluteSize was using the studio viewport size, and VR was thought to not be enabled. However, the engine shortly figures out (in the next frame or two) the correct values for these properties.
When doing the test in VR you may also note an error in the output from the PlayerModule:
I think there are two places in the PlayerModule which assume that VREnabled will always be true, hence when this bug occurs the PlayerModule throws errors.
I’m not sure if Camera.ViewportSize being (1, 1) on start is a bug, but I did get errors in my own code from it and those errors were not appearing prior to this update, so I assume that is unintended. Also, the fact of the ScreenGui’s AbsoluteSize property working differently than Camera.ViewportSize may imply a bug as well.
Workaround
- Being careful with Camera.ViewportSize.
- Listening to property changes of VRService.VREnabled, instead of checking it once at startup.
- Applying the above to a forked version of the PlayerModule
Issue Area: Studio
Issue Type: Display
Impact: Moderate
Frequency: Constantly
Date First Experienced: 2022-08-30 00:08:00 (+12:00)