Hello!
I was faced with unexpected behavior of hardware keyboard focus in UITests.
A clear description of the problem
When running UITests on the iOS Simulator with both "Full Keyboard Access" and "Connect Hardware Keyboard" options enabled, there is a noticeable delay between keyboard actions for focus managing (like pressing Tab or arrow keys). The delay seems to increase with repeated input and suggests that events are being queued instead of processed immediately. I will describe why I have such an assumption later.
A step-by-step set of instructions to reproduce the problem
- Launch the iOS Simulator.
- Enable both "Full Keyboard Access" and "Connect Hardware Keyboard" in the Simulator settings.
- Run a UITest on a target application (ideally an endless or long-running test).
- Once the app is launched, press the Tab key several times.
- Observe the delay in focus movement.
- Optionally, press the Tab or arrow keys rapidly, then stop the UITest.
- After stopping, you’ll see a burst of rapid focus changes.
What results you expected
We expected keyboard actions (like Tab) to be handled immediately and the UI focus to update smoothly during UITests.
What results you saw
There was a 4–10 (end more) second delay between pressing keys and seeing a response. All stacked keyboard events (used for managing focus) are performed all at once after stopping the UITest.
The version of Xcode you are using
- Xcode: Version 16.3 (16E140)
- Simulator: iPhone 16 Pro (iOS 18.4 and 18.1)
- Simulator: iPad Pro 11-inch (M4) (iPadOS 17.5)