Repository navigation
Conversation
…he keyboard inset TestSceneKeyboardInsetFollowsFocus failed with heights [0 0] on every apple-simulator run since bec2c94 added TestTitledKeyCommandsUseUIKit to the same iPad invocation. That test runs first and presses keys as IOHID keyboard events; once UIKit takes one, the simulator counts a hardware keyboard as connected (UIKeyboardImpl hardwareKeyboardAttached, HardwareKeyboardLastSeen in com.apple.keyboard.preferences) for as long as it runs, so focusing a field shows no software keyboard and the inset stays 0 in both scenes. The test now tells GraphicsServices no hardware keyboard is attached, as on a newly booted simulator, before it focuses the fields. Setting UIKit's own flag is not enough: UIKit reads the system's state again as a scene activates.
houko
enabled auto-merge (rebase)
November 22, 2026 01:45
Collaborator
Author
|
Reviewed. The root cause is well supported: the failure only appears once
No changes requested. |
This was referenced Nov 22, 2026
auto-merge was automatically disabled
November 22, 2026 03:13
Pull request was closed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Root cause
TestSceneKeyboardInsetFollowsFocusfails on everyapple-simulatorrun withfocus in scene 1 gave heights [0 0]. It passed on #1168 because the iPad invocation then held only the four scene tests. bec2c94 addedTestTitledKeyCommandsUseUIKitto the same invocation, and it runs first (keycommands_test.gosorts beforescene_test.go).That test presses keys, which on a simulator are IOHID keyboard events enqueued through
-[UIApplication _enqueueHIDEvent:]. Once UIKit takes one, the simulator counts a hardware keyboard as connected (UIKeyboardImpl.hardwareKeyboardAttachedandisInHardwareKeyboardModeare true,HardwareKeyboardLastSeenis written tocom.apple.keyboard.preferences), for as long as the simulator runs and in every app launched after. Focusing a field then shows no software keyboard, soKeyboardHeightstays 0 in both scenes. The engine is right: with a hardware keyboard there is no inset.Evidence on the Mac Studio (Xcode 27.1, iOS 27.0, iPad Pro 13-inch (M5)), each from a freshly erased simulator:
TestTitledKeyCommandsUseUIKitthen the inset test, on main: fails with[0 0], same as CISetting UIKit's flag (
-[UIKeyboardImpl setHardWareKeyboardAttached:NO]) is not enough: UIKit reads the system's state again as a scene activates, and the run still fails.Fix
A test-only
ios.DetachHardwareKeyboardForTestcalls GraphicsServices'GSEventSetHardwareKeyboardAttached(false, 0)on simulators, putting the simulator back to the no-hardware-keyboard state it boots with, and does nothing on a physical device.TestSceneKeyboardInsetFollowsFocuscalls it before focusing the fields, so it no longer depends on which tests ran before it. The assertion is unchanged.Verification
On the Mac Studio, freshly erased iPad Pro 13-inch (M5) on iOS 27.0:
TestTitledKeyCommandsUseUIKit+TestSceneKeyboardInsetFollowsFocus: fails on main, passes with this changeTestScenesShowTreesOfTheirOwn|TestSceneDisconnectsWhileTheOtherRuns|TestSceneStatusBarAndOrientationsArePerScene|TestSceneKeyboardInsetFollowsFocus|TestTitledKeyCommandsUseUIKit): 5 passedScreenshots
None.