Combine multiple UIView sources to get window insets#2946
Merged
Conversation
fe0c81e to
52217da
Compare
Andrei Salavei (ASalavei)
left a comment
There was a problem hiding this comment.
LGTM, waiting for green tests
Vladimir Mazunin (mazunin-v-jb)
approved these changes
Apr 9, 2026
52217da to
5f4f652
Compare
Andrei Salavei (ASalavei)
approved these changes
Apr 10, 2026
Vendula Švastalová (svastven)
added a commit
that referenced
this pull request
Apr 10, 2026
Combine multiple UIView sources to get correct window insets. Fixes support for embedding compose views in UIKit navigation view with UIKit navigation bar and iPad insets for traffic light controls. Fixes [CMP-9931](https://youtrack.jetbrains.com/issue/CMP-9931) iOS: WindowInsets.safeDrawing does not include UINavigationBar safe area insets (regression in 1.11.0-alpha04) Test [CMP-8922](https://youtrack.jetbrains.com/issue/CMP-8922) on iPad in combination with sample provided in [CMP-9931](https://youtrack.jetbrains.com/issue/CMP-9931) This should be tested by QA - _(prerelease fix)_ Fix `UINavigationBar` safe area insets not included in `WindowInsets.safeDrawing`
Vendula Švastalová (svastven)
added a commit
that referenced
this pull request
Apr 10, 2026
Combine multiple UIView sources to get correct window insets. Fixes support for embedding compose views in UIKit navigation view with UIKit navigation bar and iPad insets for traffic light controls. Fixes [CMP-9931](https://youtrack.jetbrains.com/issue/CMP-9931) iOS: WindowInsets.safeDrawing does not include UINavigationBar safe area insets (regression in 1.11.0-alpha04) Test [CMP-8922](https://youtrack.jetbrains.com/issue/CMP-8922) on iPad in combination with sample provided in [CMP-9931](https://youtrack.jetbrains.com/issue/CMP-9931) This should be tested by QA - _(prerelease fix)_ Fix `UINavigationBar` safe area insets not included in `WindowInsets.safeDrawing`
Ekaterina Zaitseva (sekater)
added a commit
that referenced
this pull request
Apr 10, 2026
…2946) (#2965) Combine multiple UIView sources to get correct window insets. Fixes support for embedding compose views in UIKit navigation view with UIKit navigation bar and iPad insets for traffic light controls. Fixes [CMP-9931](https://youtrack.jetbrains.com/issue/CMP-9931) iOS: WindowInsets.safeDrawing does not include UINavigationBar safe area insets (regression in 1.11.0-alpha04) ## Testing Test [CMP-8922](https://youtrack.jetbrains.com/issue/CMP-8922) on iPad in combination with sample provided in [CMP-9931](https://youtrack.jetbrains.com/issue/CMP-9931) This should be tested by QA ## Release Notes ### Fixes - iOS - _(prerelease fix)_ Fix `UINavigationBar` safe area insets not included in `WindowInsets.safeDrawing`
Jacob Rhoda (jadar)
pushed a commit
to jadar/compose-multiplatform-core
that referenced
this pull request
May 25, 2026
…ered surfaces Fixes [CMP-10230](https://youtrack.jetbrains.com/issue/CMP-10230) `UIKitWindowInsetsManager` per-edge `union()`s safe-area insets from the local `_overlayView` with those from `window.rootViewController.view`. This was added in JetBrains#2946 to cover CMP-9931 (missing `UINavigationBar` height) and CMP-8922 (iPad Stage Manager traffic-light controls), but over-reports whenever the Compose surface is positioned below window- level chrome that does not intersect `_overlayView`, or whose ancestor chain filters safe-area propagation (`UIHostingController.safeAreaRegions = .keyboard`, parent `additionalSafeAreaInsets`, manual frame placement). The local view correctly reports zero for the affected edge, but the window root reports the global value and `max()` wins. This commit: 1. Removes the `window.rootViewController.view` source from `windowInsetsViews`. Standard UIKit safe-area propagation already incorporates ancestor chrome into a child view's `safeAreaInsets` for typical hosting setups, so the CMP-9931 navbar case should still be covered. Worth re-validating against the original repro. 2. Adds a dedicated `onSafeAreaInsetsDidChange` callback on `BackgroundInputView` (parallel to the existing `onLayoutSubviews`) wired to a new `internal fun onSafeAreaInsetsDidChange()` on the mediator. The callback is invoked directly from `safeAreaInsetsDidChange`, without going through `setNeedsLayout`, so Compose re-reads insets even when the parent reposition leaves the input view's local frame unchanged. 3. Adds an Obj-C bridge on `CMPViewController` to expose `viewSafeAreaInsetsDidChange` for Kotlin override (matches the existing `userInterfaceStyleDidChange` pattern). The new `safeAreaInsetsDidUpdate` hook is implemented in `ComposeHostingViewController` and forwards through `container.onSafeAreaInsetsDidChange()`. This is defense-in-depth alongside the view-level hook. Each path is a no-op when the value hasn't changed (`mutableStateOf` only triggers recompose on actual change), so redundant delivery is cheap. The existing `WindowInsetsPaddingTest.testWindowInsetsPaddingAppliedTo NonFullscreenComposeUIViewContent` encoded the union semantics; it has been renamed and inverted to assert the new contract (no padding on a non-fullscreen embedded `ComposeUIView`). The fullscreen-outer test is unchanged. Known limitation not addressed by this commit: iOS does not deliver `safeAreaInsetsDidChange` (UIView) or `viewSafeAreaInsetsDidChange` (UIViewController) to a view/VC occluded by a presented sheet, including during interactive sheet dismissal ("peek"). Confirmed empirically with both hooks wired. Per-frame `CADisplayLink` polling does not help because the read returns the same stale value iOS is caching; geometric inset computation from window-space position handles peek but over-subtracts the legitimate navbar contribution in standard `UINavigationController` setups. ## Release Notes ### Fixes - iOS - Fix `WindowInsets` over-reported on Compose surfaces positioned below window-level chrome that does not intersect the host view (e.g. under a `UIHostingController` with `safeAreaRegions = .keyboard`).
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.
Combine multiple UIView sources to get correct window insets. Fixes support for embedding compose views in UIKit navigation view with UIKit navigation bar and iPad insets for traffic light controls.
Fixes CMP-9931 iOS: WindowInsets.safeDrawing does not include UINavigationBar safe area insets (regression in 1.11.0-alpha04)
Testing
Test CMP-8922 on iPad in combination with sample provided in CMP-9931
This should be tested by QA
Release Notes
Fixes - iOS
UINavigationBarsafe area insets not included inWindowInsets.safeDrawing