Lnpopupcontroller: customBarViewController is nil after dismissPopupBar but still retained by LNPopupBar

Created on 21 Feb 2018  路  9Comments  路  Source: LeoNatan/LNPopupController

I'm setting a customBarViewController like this:

let popupBarVC = PopupBarViewController()
let contentVC = PopupContentViewController()

popupBar.customBarViewController = popupBarVC

presentPopupBar(withContentViewController: contentVC, openPopup: true, animated: true, completion: nil)

when I'm dismissing the popupBar the customBarViewController property becomes nil

// popupBar.customBarViewController is still set here

dismissPopupBar(animated: true) {
    // self.popupBar.customBarViewController is nil here
}

However the PopupBarViewController instance is not deallocated and according to Xcode's Memory Graph Debugger it is still retained by an instance of LNPopupBar.

If I repeat to present and dismiss the popupBar like this I accumulate instances of PopupBarViewController that are all retained by different instances of LNPopupBar.

screen shot 2018-02-21 at 10 35 32
screen shot 2018-02-21 at 10 36 04

If I keep a reference to the PopupBarViewController instance myself and reuse that to set it to the popupBar.customBarViewController property everytime I'm going to present the popupBar, the PopupBarViewController instance will be retained by many LNPopupBar instances.

Seems to me that LNPopupBar instances are not released when they should be (after dismissPopupBar).

I'm using
LNPopupController v2.5.10
Xcode 9.2

bug

Most helpful comment

Thank you for the great report!
I will look into this ASAP.

All 9 comments

Thank you for the great report!
I will look into this ASAP.

Considering how the system works, the popup bar itself is created on demand and only released when the presenting controller is released. This is to allow, for example, customization done by the user to persist between presentations.

I do however see a problem where cleanup should be performed after dismissing the popup.

It would be fine for me if the popup bar is not released until the presenting view controller is released. But it seems a new popup bar instance is created on every present.

Only one bar should be created per presenting controller.

Yes, I see what you mean. Investigating

//No longer need to retain the popup controller after dismissing.
objc_setAssociatedObject(self, _LNPopupControllerKey, nil, OBJC_ASSOCIATION_RETAIN_NONATOMIC);

Well that about will do it 馃槅

OK, found a leak that caused previous bars to remain in memory.

But I still think the correct behavior of the system should be to only release the bar upon the presentation controller release.

Please try now with 2.5.11.

Thanks

fix confirmed. thanks!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

RajChanchal picture RajChanchal  路  5Comments

funkenstrahlen picture funkenstrahlen  路  3Comments

PrakashMaharjan picture PrakashMaharjan  路  6Comments

yetdog picture yetdog  路  8Comments

johnswifttt picture johnswifttt  路  5Comments