LeoNatan / LNPopupController

A framework for presenting view controllers as popups of other view controllers, much like the Apple Music and Podcasts apps.
MIT License
3.04k stars 342 forks source link

Safe area insets are not maintained correctly in iOS 16 #519

Closed alexwhb closed 2 years ago

alexwhb commented 2 years ago

I'm experiencing the same issue as here, but only inside the LNPopupUI. I'm doing something a little strange where I have a navigation view inside the LNPopup View, but it has worked for me just fine on iOS 15 and below.

Wondering if anyone has experienced the same issue and has any advice on how to solve.

Here's what it looks like in my app

I also realized another very interesting detail.. if you are in the LNPopup view then lock you screen then come back.. this weird navigation behavior goes away and it works as it did on iOS 15.

LeoNatan commented 2 years ago

Hello,

Can you please create a demo project with this issue? Also, could you please try to reproduce it in LNPopupController, using UIKit?

Thanks

alexwhb commented 2 years ago

@LeoNatan Thanks for your quick response. I will do my best to reproduce in a demo project. I'm not very good with UIKit, but I will give it a shot.

LeoNatan commented 2 years ago

Even a SwiftUI will help me debug it. There are known issues with iOS 16, where SwiftUI views do not calculate the top safe area inset when inside the popup. But UINavigationController’s view hierarchy should work correctly, as it’s a UIKit view. So I wonder if it’s a UIKit bug.

alexwhb commented 2 years ago

Good to know. I'll try to have you a good example by tomorrow morning. Appreciate the response.

alexwhb commented 2 years ago

@LeoNatan here is a link to my repo demoing the issue. I'm using Swift UI for this, but I can give it a shot in UIKit if you'd like. Make sure you are running on iOS 16, and let me know if I can add/change anything to make the demo more extensive. It did show the issue on my emulator, so hopefully this is enough for you to get started. Thanks again for your help.

Also note if you lock the screen when you have the popup view open and unlock it the view issue goes away. This makes me think it's possible this is a bug with iOS.

Here's a quick video demo of the demo app

LeoNatan commented 2 years ago

Looking into this, this is actually caused by a bug I’ve known about in iOS 16 SwiftUI for a while. Looking how to solve this.

alexwhb commented 2 years ago

@LeoNatan Thank you for looking into this. Let me know if there's anything I can do to help. I will contact Apple about this today, just to make sure they are aware of the bug. Hopefully they can do something in their next iOS update too.

LeoNatan commented 2 years ago

It seems very easy to reproduce in iOS 16:

Simulator Screen Shot - iPhone 14 Pro - 2022-10-04 at 13 12 02

This is just a very simple example where this reproduces and I’m not sure what to do with it currently. It seems view controllers break safe area management if they are not part of the controller hierarchy, which is not always possible.

LeoNatan commented 2 years ago

I’ve transferred the issue to LNPopupController, where it should be handled.

alexwhb commented 2 years ago

@LeoNatan Thanks for your further investigation into this. Ya it's honestly strange how blatant this bug seems to be, you'd think Apple would have caught it early on in their beta testing. I reported it to them yesterday incase they, somehow, haven't already encountered this bug. Hopefully that does something and they patch this issue in their next release. 🤞

Also it makes sense that it should be in the LNPopupController project. I'll look for it there. Thanks for letting me know.

LeoNatan commented 2 years ago

Fixed in 2.14.0.

LeoNatan commented 2 years ago

Fixed in 1.4.0 (LNPopupUI)

alexwhb commented 2 years ago

@LeoNatan you are truly my hero !!!! Thank you so much!!!