iOS 18 Picture-in-Picture dynamically changes UIScreen.main.bounds on iPhone 11 causing keyboard clipping and layout issues

When creating and activating AVPictureInPictureController on iPhone 11 running iOS 18.x, the main screen viewport unexpectedly changes from the native 375×812 logical points to 414×896 points (the size of a different device such as iPhone XR/11 Plus). Additionally, a separate UIWindow with zero CGRect is created. This causes UIKit layout calculations, especially related to the keyboard and safeAreaInsets, to malfunction and results in issues like keyboard clipping and general UI misalignment. The problem appears tied specifically to iOS 18+ behavior and does not manifest on earlier iOS versions or other devices consistently.

Steps to Reproduce:

  1. Run the app on iPhone 11 with iOS 18.x (including the latest minor updates).
  2. Instantiate and start an AVPictureInPictureController during app runtime.
  3. Observe that UIScreen.main.bounds changes from 375×812 (native iPhone 11 size) to 414×896.
  4. Notice a secondary UIWindow appears with frame CGRectZero.
  5. Interact with text inputs that cause the keyboard to appear.
  6. The keyboard is clipped or partially obscured, causing UI usability issues.
  7. Layout elements dependent on UIScreen.main.bounds or safeAreaInsets behave incorrectly.

Expected Behavior:

UIScreen.main.bounds should not dynamically change upon PiP controller creation. The coordinate space and viewport should remain accurate to device native dimensions. The keyboard and UI layout should adjust properly with respect to the actual on-screen size and safe areas.

Actual Behavior:

  • UIScreen.main.bounds changes to 414×896 upon PiP controller creation on iPhone 11 iOS 18+.
  • A zero-rect secondary UIWindow is created, impacting layout queries.
  • Keyboard clipping and UI layout bugs occur.
  • The app viewport and coordinate space are inconsistent with device hardware.

iOS 18 Picture-in-Picture dynamically changes UIScreen.main.bounds on iPhone 11 causing keyboard clipping and layout issues
 
 
Q