iOS: Virtual keyboard doesn't follow device orientation changes (regression in v8.0.10)

Hi JUCE team,

I’ve encountered an issue with the virtual keyboard on iOS when rotating the device.

Issue Description:
When the virtual keyboard is displayed on iOS and the device orientation is changed (portrait ↔ landscape), the keyboard fails to follow the new orientation and remains in its original position/orientation.

Reproduction:

  1. Display the virtual keyboard on iOS
  2. Rotate the device while the keyboard is visible
  3. The keyboard does not reorient to match the new device orientation

Version Information:

  • Works correctly: v8.0.8
  • Broken: v8.0.10 and latest develop branch

I’ve attached a sample project that reproduces this issue.

Could you please investigate this regression? Let me know if you need any additional information.

Thank you!

KeyboardBugSample.zip (7.7 KB)

Thanks for the report. Please could you let us know which version(s) of iOS display the issue?

The iOS version on which the issue was confirmed is 18.6.2.

If necessary, we can check all the devices we have on hand, so please let us know.

I’ve got a physical device running iOS 18.7.1 here, so it would be helpful to know whether the issue is also present on that version, and/or any of the iOS simulators, before attempting to reproduce locally. Thanks in advance!

Updating the device’s iOS to 18.7.1 still caused issues.
The device is an iPhone 14.

I also checked using the Simulator, but regardless of the situation, the keyboard layout only appeared in Portrait mode, making it difficult to verify properly.

1 Like

Thanks, I am able to reproduce the issue and I’ve bisected the problem to this commit:

I’ve spent some time investigating, and I can’t see any obvious cause for the faulty behaviour. However, while experimenting I did discover that initialising our UIWindow with an appropriate UIWindowScene (as opposed to the current approach, where we assign the UIWindowScene some time after initialising the window) seems to fix the problem.

ios-rotation.patch (13.4 KB)

I don’t have much confidence in this solution, since it’s relying on undocumented behaviour. Please could you try applying the above patch on the develop branch and check whether it fixes the issue for you? Thanks in advance!

I applied the patch above and did a quick test using my code from the other thread (Android and safe area insets). I did so because I noticed that the Bluetooth pairing dialogue is resized imporperly when the device is rotated, so I wondered if this is related. With the patch I can’t get the blueotooth dialogue to be be displayed at all. Tested on iOS 18.7.

1 Like

Thanks for looking into it.

After applying the patch, the bug I reported was fixed!

Thanks, both, for testing this change. I’ll track down the regression, and then get this merged.

2 Likes

These changes are now on the develop branch.

This is the fix for the keyboard failing to follow the device orientation. This also addresses the regression where secondary windows would fail to display.

I also pushed a fix for the issue where the bluetooth MIDI pairing dialog didn’t behave well when rotating the device. This had a different underlying cause in the end.

2 Likes