Hi.
I am getting an crash periodically when dismissing the popupBar. It seems the CALayer position contains NaN it its y-position when repositioning the popupBar in - (void)_repositionPopupContent.
Stack trace:
CALayerInvalidGeometryLNPopupController
CALayer position contains NaN: [187.5 nan]
LNPopupController/Private/LNPopupController.m:217-[LNPopupController _repositionPopupContent]
LNPopupController/Private/UIViewController+LNPopupSupportPrivate.m:220-[UIViewController(LNPopupLayout) _ln_popup_viewDidLayoutSubviews]
LNPopupController/Private/UIViewController+LNPopupSupportPrivate.m:248LNPopupSupportFixInsetsForViewController
LNPopupController/Private/LNPopupController.m:738_56-[LNPopupController dismissPopupBarAnimated:completion:]_block_invoke_2
LNPopupController/Private/LNPopupController.m:732_56-[LNPopupController dismissPopupBarAnimated:completion:]_block_invok
It seems to only happen on iOS 9 and 10. But dont know for sure, since not many of our users is on iOS 8.
Let me know if you need anything.
Thanks for reporting!
Not sure I understand. Is this an issue that occurs on iOS 8? I have not seen it on 9 or 10, but I have not tested enough on 8. As time goes on, 8 has become non-priority for me.
Sorry about the wording. My bugreporting tool only has occurences of this error on iOS 9 and 10. But that may be because we dont have many users on iOS 8. So for now there is no occurences on iOS 8. Thought that might help you on finding the problem.
I will let you know see any on iOS 8
Ah, OK, thanks. I will investigate.
Following the execution of the code, I found that there is a diveded by zero issue here (LNPopupController.m , line 218):
CGFloat screenScale = _containerController.view.window.screen.scale;
CGFloat fractionalHeight = relativeViewForContentView.frame.origin.y - (_popupBar.frame.origin.y + _popupBar.frame.size.height);
contentFrame.size.height = ceil(fractionalHeight * screenScale) / screenScale;
screenScale is equal to zero.
Note that I'm using xcode 8, and I had other kind of layout issue, It may be the source of the issue.
Also it worth mentioning that I run the exemples without facing this issue
My current workaroung is avoid the divisiong by zero using (LNPopupController.m , line 216) :
CGFloat screenScale = _containerController.view.window.screen.scale == 0 ? 1 : _containerController.view.window.screen.scale ;
I am guessing _containerController.view.window is nil? How are you presenting the controller, and where are you dismissing it? Are you dismissing when the presenting controller's view and popup bar are not displayed?
Yes window property is nil
The project is a sample, here is what I'm doing in a tabbar :
` override func viewDidLoad() {
super.viewDidLoad()
let vc = self.storyboard?.instantiateViewController(withIdentifier: "yo")
self.presentPopupBar(withContentViewController: vc!, animated: true, completion: nil)
// Do any additional setup after loading the view.
}`
This is the issue. In viewDidLoad, the view is not part of the view hierarchy yet (has not been added to a window). Not sure I want to support this. Have to investigate what the implications are. As a workaround, move your code to viewDidAppear.
@Kleemann Can you comment if you are doing something similar? Thanks
The workaround fix it, I compared 1.4.1(where my previous code was working) with 2.0, and the issue came from the scaling code
are there any reason why you don't use the main screen scale ?
iOS supports multiple screens, and there can be different scale on each screen. I will think about this problem, but I need to reproduce it when I have time.
My code is not in the viewDidLoad, but triggered from a from tableView:didSelectRowAtIndexPath:.
let storyBoard = UIStoryboard(name: "AudioBook", bundle: nil)
let player = (storyBoard.instantiateViewControllerWithIdentifier("AudioBookVCID") as! AudioBookViewController)
let navCon = UINavigationController(rootViewController: player)
self.navigationController!.presentPopupBarWithContentViewController(navCon, openPopup: true, animated: true, completion:nil)
The navCon.view.window and player.view.window properties is nil before presenting
I am dismissing it with a delegate callback
self.navigationController?.dismissPopupBarAnimated(true, completion: nil)
Added a proposed fix in V2_0. Please test.
@LeoNatan Will do, great work! I have a scheduled release monday. Then i will keep an eye out is it appears in my bug reporting tool again. I can't reproduce it myself.
Will keep you updated.
Thanks!
The bug has not occurred again. Seems to be fixed. :thumbsup:
Fantastic, thank you!