You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I just discovered a problem: If you use a timer in the PopupViewController to call a method on it regularly the PlayerViewController will be kept in memory and active even if the tabBarController instantiated a new PopupViewController.
I discovered this because right at the moment I added a timer, my AVPlayer of each PopupViewController(containing the player) kept playing in the background even when I started playing another song and a new PopupViewController was created.
I fixed this by invalidating the timer each time a new PopupViewController object was created.
// invalidate the timer of the old controller, because this keeps the old controller in the memory
if let oldController = popupContentController {
oldController.timer?.invalidate()
oldController.player?.pause()}
popupContentController = storyboard?.instantiateViewControllerWithIdentifier("DemoMusicPlayerController")as?PlayerViewController
tabBarController?.presentPopupBarWithContentViewController(popupContentController!, animated: true, completion:nil)
Is this issue covered in the demo projects?
The text was updated successfully, but these errors were encountered:
I don't understand the problem here. NSTimer retains the provided target until it finishes or is invalidated and released. It is clearly mentioned in the documentation:
The timer maintains a strong reference to target until it (the timer) is invalidated.
LNPopupController is not responsible for your app's logic and/or memory management. If you choose to use NSTimer, you must be aware of how it works, and prepare accordingly. There are several ways to handle memory management; one you have mentioned, another is to use a weak wrapper object as the target of the timer, and only perform the selector on the wrapped object if it is not nil.
I am closing this issue as it is not related to the framework in any way.
Yes you are right. It is not a problem of the framework itself. However I think it might be nice if the demo projects in this repository would take care of this problem. Maybe people using the demo projects as a template will not run into this problem then.
I just discovered a problem: If you use a timer in the PopupViewController to call a method on it regularly the PlayerViewController will be kept in memory and active even if the tabBarController instantiated a new PopupViewController.
I discovered this because right at the moment I added a timer, my AVPlayer of each PopupViewController(containing the player) kept playing in the background even when I started playing another song and a new PopupViewController was created.
I fixed this by invalidating the timer each time a new PopupViewController object was created.
Is this issue covered in the demo projects?
The text was updated successfully, but these errors were encountered: