Fix CADisplayLink retain cycle by invalidating on view removal
Override willMove(toWindow:) in ReviewDiffContentView to call stopHorizontalDeceleration() when the view is removed from the window hierarchy (newWindow == nil). This breaks the retain cycle where CADisplayLink retains its target (the content view), preventing deallocation until deceleration naturally completes.
This commit is contained in:
1 file changed
+7
@@ -1315,6 +1315,13 @@ private final class ReviewDiffContentView: UIView, UIGestureRecognizerDelegate {
|
||||
}
|
||||
}
|
||||
|
||||
override func willMove(toWindow newWindow: UIWindow?) {
|
||||
super.willMove(toWindow: newWindow)
|
||||
if newWindow == nil {
|
||||
stopHorizontalDeceleration()
|
||||
}
|
||||
}
|
||||
|
||||
private func stopHorizontalDeceleration() {
|
||||
decelerationDisplayLink?.invalidate()
|
||||
decelerationDisplayLink = nil
|
||||
|
||||
Reference in new issue
Block a user