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:
Cursor Agent committed 2026-05-04 04:02:43 +00:00
1 parent 93ec45eb3c
commit 5dae987581
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