PGSSoft / ParallaxView

tvOS controls and extensions that add parallax effect to your application.
https://pgssoft.github.io/ParallaxView/
MIT License
483 stars 51 forks source link

Retain cycle in ParallaxView? #26

Open yonicsurny opened 8 months ago

yonicsurny commented 8 months ago

Hi, I'm experiencing what appears to be memory leaks using ParallaxView.

The more I use the app, the more unreleased closures are kept in memory.

A2953589-ED29-4C0B-B454-05364C5C3489

In my cell, I have a ParallaxView and I use a similar code as the one given in README of the project.

Relevant excerpt of the code:

@IBOutlet weak var posterView: ParallaxView!

...

override func didUpdateFocus(in context: UIFocusUpdateContext, with coordinator: UIFocusAnimationCoordinator) {
      super.didUpdateFocus(in: context, with: coordinator)
      coordinator.addCoordinatedAnimations { [weak self] in
          guard let self = self else { return }
          if context.nextFocusedView == self {
              self.posterView.addParallaxMotionEffects()
              UIView.animate(withDuration: 0.15, delay: 0, options: .curveEaseOut) {
                  self.posterView.transform = CGAffineTransform(scaleX: 1.1, y: 1.1)
              }
          }
          if context.previouslyFocusedView == self {
              self.posterView.removeParallaxMotionEffects()
              UIView.animate(withDuration: 0.3, delay: 0, options: .curveLinear) {
                  self.posterView.transform = CGAffineTransform(scaleX: 1, y: 1)
              }
          }
      }
  }

Any idea what might be the issue? Thank you in advance!