Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ensure MSFNotification doesn't internally handle safe areas #2099

Merged
merged 1 commit into from
Oct 21, 2024

Conversation

lukas-cap
Copy link
Contributor

@lukas-cap lukas-cap commented Oct 18, 2024

Platforms Impacted

  • iOS
  • visionOS
  • macOS

Description of changes

By default, UIHostingController will internally handle safe areas by growing the hosting view correspondingly (to allow the content to clear the unsafe area).

This sometimes caused a layout feedback loop (and a hang) in MSFNotification.
To hide, we slide the notification beyond the host view edge to which it was constrained. This can cause it to be in the unsafe area, which causes the hosting view to grow (because of the safe area region handling behavior). This triggers a synchronous layout pass to shift the view even further away to satisfy the new constraints, which causes it to grow again. This repeats indefinitely and the app hangs.

This doesn't always repro - we need a special combo of soft keyboard (which causes a safe area mismatch between SwiftUI and UIKit) and specific notification positioning. Regardless, this view (and probably most other leaf node views) should not internally handle safe areas. So I'm exposing the safeAreaRegions API, and setting it to an empty array for the notification view.

Verification

Reproduced hang in product and in a small test app.
Verified hang is fixed, and did sanity checks in fluent test app to make sure nothing else regressed.

Pull request checklist

This PR has considered:

  • Light and Dark appearances
  • iOS supported versions (all major versions greater than or equal current target deployment version)
  • VoiceOver and Keyboard Accessibility
  • Internationalization and Right to Left layouts
  • Different resolutions (1x, 2x, 3x)
  • Size classes and window sizes (iPhone vs iPad, notched devices, multitasking, different window sizes, etc)
  • iPad Pointer interaction
  • SwiftUI consumption (validation or new demo scenarios needed)
  • Objective-C exposure (provide it only if needed)
Microsoft Reviewers: Open in CodeFlow

@lukas-cap lukas-cap requested a review from a team as a code owner October 18, 2024 23:35
@lukas-cap lukas-cap merged commit f1ebf87 into microsoft:main Oct 21, 2024
7 checks passed
@lukas-cap lukas-cap deleted the safeRegionsControl branch October 21, 2024 17:16
@joannaquu joannaquu mentioned this pull request Nov 21, 2024
12 tasks
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