Skip to content

Commit cee93fd

Browse files
committed
Fix memory leak introduced in 21f7601
Self is accessed within AVCaptureEventInteraction closure, which is stored in eventInteraction class variable, creating a retain cycle Use [weak self] to break the cycle 21f7601#diff-5011dc3d3aefd7b67661ffa11130868519526e31f62f630ebf6ddc2d7f714e09R128-R135
1 parent 29e5873 commit cee93fd

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

ios/ReactNativeCameraKit/CameraView.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -134,12 +134,12 @@ public class CameraView: UIView {
134134
#if !targetEnvironment(macCatalyst)
135135
// Create a new capture event interaction with a handler that captures a photo.
136136
if #available(iOS 17.2, *) {
137-
let interaction = AVCaptureEventInteraction { event in
137+
let interaction = AVCaptureEventInteraction { [weak self] event in
138138
// Capture a photo on "press up" of a hardware button.
139139
if event.phase == .began {
140-
self.onCaptureButtonPressIn?(nil)
140+
self?.onCaptureButtonPressIn?(nil)
141141
} else if event.phase == .ended {
142-
self.onCaptureButtonPressOut?(nil)
142+
self?.onCaptureButtonPressOut?(nil)
143143
}
144144
}
145145
// Add the interaction to the view controller's view.

0 commit comments

Comments
 (0)