Skip to content

Comments

Fix window insets display cutout behavior#2301

Merged
svastven merged 46 commits intojb-mainfrom
svastven/bugfix/window-insets-display-cutout
Aug 11, 2025
Merged

Fix window insets display cutout behavior#2301
svastven merged 46 commits intojb-mainfrom
svastven/bugfix/window-insets-display-cutout

Conversation

@svastven
Copy link

@svastven svastven commented Aug 10, 2025

In this PR:

  • Fix incorrect behavior of WindowInsets.displayCutout in different interface orientations
  • Fix incorrect behavior of WindowInsets.displayCutout on iPad
  • Add API to UIKitInstrumentedTest to modify interface orientation of the content

Fixes

Testing

Tests for various interface orietations are added in this PR.

This should be tested by QA

Release Notes

Fixes - iOS

  • Fix incorrect behavior of WindowInsets.displayCutout in different interface orientations
  • Fix incorrect behavior of WindowInsets.displayCutout on iPad

fun updateSafeAreaInsets(insets: PlatformInsets) {
mediator?.updateSafeAreaInsets(insets)
}
val safeAreaInsets: PlatformInsets get() = mediator?.safeAreaInsets ?: PlatformInsets.Zero

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would prefer to use hostingViewController.view.safeAreaInsets in tests instead, if possible. And remove this method.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed, thanks for letting me know about the other option.

fun updateSafeAreaInsets(insets: PlatformInsets) {
windowInsetsManager.safeAreaInsets.value = insets
}
val safeAreaInsets: PlatformInsets get() = windowInsetsManager.safeAreaInsets.value

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here. It looks like we don't need to expose platform insets

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed

{ safeAreaInsets.value },
{ keyboardOverlapHeight.value },
{ interfaceOrientation.value },
{ if (isPad) InterfaceOrientation.Portrait else interfaceOrientation.value },

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some comments are required here. Or consider passing userInterfaceIdiom as another parameter to the UIKitWindowInsets and use it there.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated and added comments.

if ((appDelegate.window?.windowScene?.interfaceOrientation != UIInterfaceOrientationPortrait && interfaceOrientations == UIInterfaceOrientationMaskPortrait) || interfaceOrientations != UIInterfaceOrientationMaskPortrait) {
appDelegate.supportedInterfaceOrientations = interfaceOrientations
UIViewController.attemptRotationToDeviceOrientation()
delay(1000)
Copy link

@ASalavei ASalavei Aug 11, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do you need this delay? As far as I remember, the rotation take around 500ms. If you absolutely need to keep the delay, please add a comment, why its needed.

Copy link
Author

@svastven svastven Aug 11, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Delay 500 and 600 is too short. I have tried 700 and so far it passes on all runs for me locally, let's see.

@svastven svastven requested a review from ASalavei August 11, 2025 10:43
Base automatically changed from svastven/window-inset-rulers to jb-main August 11, 2025 11:00
…s and interfaceOrientation, removing redundant update methods.
…ation.LandscapeRight to fix WindowInsets.displayCutout bug
…remove redundant duplicate setContent functions
@svastven svastven force-pushed the svastven/bugfix/window-insets-display-cutout branch from 3b3a596 to 55bd50d Compare August 11, 2025 11:27
@svastven svastven merged commit 6ab1baa into jb-main Aug 11, 2025
10 checks passed
@svastven svastven deleted the svastven/bugfix/window-insets-display-cutout branch August 11, 2025 13:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants