After screen orientation change on mobile, new input objects sometimes have UserInputState frozen in Begin state

After screen orientation change on mobile (I only tested this on samsung phone), new touch inputs within ~1s or so after the screen orientation change will have its UserInputState frozen in the Begin state. This means that even if I stop touching the screen, the input object corresponding to that touch will never have its UserInputState change to End.
After about 1s from the orientation change, all new touch inputs will function properly i.e. new InputObjects for those touches behave as expected.

Reproduction:

local uis = game:GetService("UserInputService")
local counter = 0
uis.TouchStarted:Connect(function(input)
    local count = counter
	print("touch input number", count, "detected. State:", input.UserInputState)
	input:GetPropertyChangedSignal("UserInputState"):Connect(function()
		if input.UserInputState == Enum.UserInputState.End then
			print("touch input number", count, "has ended")
		end
	end)
	counter += 1
end)

Now rotate the device like a madman and try to tap the screen a bunch of times right after the screen orientation changes. You should see something like “touch input number 5 detected…” but “touch input number 5 has ended” will never print. It doesn’t always happen and may take a couple of rotations to get the behavior.

This is an obscure bug I discovered a year ago when I was making a custom user input module, which I hooked up to a custom camera module. My module would detect for the InputEnded state in order to remove inputs that had ended. What I found was that after rotating the screen and tapping a bunch, some inputs would get stuck and the camera would pan around endlessly, even after I lifted my fingers from the screen.

Expected behavior

After screen orientation change, new touch inputs should have UserInputState begin as Begin, and end as End.

A private message is associated with this bug report

2 Likes

Hello! Do you know if this is an issue on iOS, Android, or both (what device did you test on)?

Samsung S23 android. I suspect this issue is not specific to android.

Yup, just want to make sure I know which device would be good to start testing on!

So I was not able to reproduce this issue on iOS, but was able to reproduce it on Android. It looks like to me as though this is a shortcoming of the operating system and not receiving the inputs while it resets the application on screen orientation change.

Some of the inputs right after the screen flip ended up firing InputBegan and new input objects were created for those, I’m not familiar with how apps communicate with android, but are you saying that:

  1. User flips screen - OS signals to app and roblox changes the orientation, re-renders ui, etc
  2. A couple ms after the screen flip, the user taps on screen. OS registers tap and signals to app, engine creates new input object and uses some kind of tracking id given to it by the OS to associate the input object with that specific tap
  3. After a couple more ms, only now does the OS do some kind of “reset”, at which point it wipes the tracking ids (or whatever it uses) of the currently active touch inputs. The engine never receives the signal when those specific touch inputs end (even when the user lifts finger off the screen, the OS is ignoring it?), so it thinks that the input objects associated with the taps at step 2 are still alive, and InputEnd is never fired.

since the observed behavior on my end was that there was a short window of time after the screen flip in which the inputs might get bugged (the window in between step 2 and 3 above)

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.