Skip to content

Commit a73b84e

Browse files
committed
Removed iOsSleepBeforeStarting
No longer needed with proper begin/commit handling
1 parent db93bcf commit a73b84e

13 files changed

Lines changed: 7 additions & 48 deletions

File tree

README.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,6 @@ Additionally, the Camera can be used for barcode scanning
197197
| `resizeMode` | `'cover' / 'contain'` | Determines the scaling and cropping behavior of content within the view. `cover` (resizeAspectFill on iOS) scales the content to fill the view completely, potentially cropping content if its aspect ratio differs from the view. `contain` (resizeAspect on iOS) scales the content to fit within the view's bounds without cropping, ensuring all content is visible but may introduce letterboxing. Default behavior depends on the specific use case. |
198198
| `scanThrottleDelay` | `number` | Duration between scan detection in milliseconds. Default 2000 (2s) |
199199
| `maxPhotoQualityPrioritization` | `'balanced'` / `'quality'` / `'speed'` | [iOS 13 and newer](https://developer.apple.com/documentation/avfoundation/avcapturephotooutput/3182995-maxphotoqualityprioritization). `'speed'` provides a 60-80% median capture time reduction vs 'quality' setting. Tested on iPhone 6S Max (66% faster) and iPhone 15 Pro Max (76% faster!). Default `balanced` |
200-
| `iOsSleepBeforeStarting` | `number` | iOS only. Delay (ms) before the capture session starts. Default `100`. Set to `0` to skip. Helps ensure `session.commitConfiguration()` finishes before `session.startRunning()`, reducing occasional crashes seen when rapidly toggling cameras: `-[AVCaptureSession startRunning] startRunning may not be called between calls to beginConfiguration and commitConfiguration`. iOS feedback ID: FB21533559 |
201200
| `iOsDeferredStart` | `boolean` | iOS 26+ only. Enables `AVCaptureOutput.deferredStartEnabled` when supported to get the preview visible faster. Default `true`. When enabled, the first capture can be delayed by a few hundred milliseconds. Ignored on Android and on older iOS versions. |
202201
| `onCaptureButtonPressIn` | Function | Callback when iPhone capture button is pressed in or Android volume or camera button is pressed in. Ex: `onCaptureButtonPressIn={() => console.log("volume button pressed in")}` |
203202
| `onCaptureButtonPressOut` | Function | Callback when iPhone capture button is released or Android volume or camera button is released. Ex: `onCaptureButtonPressOut={() => console.log("volume button released")}` |

android/src/newarch/java/com/rncamerakit/CKCameraManager.kt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -155,8 +155,6 @@ class CKCameraManager(context: ReactApplicationContext) : SimpleViewManager<CKCa
155155
}
156156

157157
// Methods only available on iOS
158-
override fun setIOsSleepBeforeStarting(view: CKCamera?, value: Int) = Unit
159-
160158
override fun setRatioOverlay(view: CKCamera?, value: String?) = Unit
161159

162160
override fun setRatioOverlayColor(view: CKCamera?, value: Int?) = Unit

example/src/App.tsx

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,8 @@ const App = () => {
2121
<View style={styles.container}>
2222
<Text style={{ fontSize: 60 }}>🎈</Text>
2323
<Text style={styles.headerText}>React Native Camera Kit</Text>
24-
<TouchableOpacity style={styles.button} onPress={() => setExample(<CameraExample onBack={onBack} />)}>
25-
<Text style={styles.buttonText}>Camera</Text>
26-
</TouchableOpacity>
27-
<TouchableOpacity style={styles.button} onPress={() => setExample(<BarcodeScreenExample onBack={onBack} />)}>
28-
<Text style={styles.buttonText}>Barcode Scanner</Text>
29-
</TouchableOpacity>
24+
<Button title="Camera" onPress={() => setExample(<CameraExample onBack={onBack} />)}></Button>
25+
<Button title="Barcode Scanner" onPress={() => setExample(<BarcodeScreenExample onBack={onBack} />)}></Button>
3026
<View>
3127
<Text style={[styles.stressHeader, { marginTop: 12 }]}>Mount Stress Test</Text>
3228
<View style={{ flexDirection: 'row', alignItems: 'center' }}>

example/src/CameraExample.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,6 @@ const CameraExample = ({ onBack, stress }: { onBack: () => void; stress?: boolea
243243
}}
244244
torchMode={torchMode ? 'on' : 'off'}
245245
shutterPhotoSound
246-
iOsSleepBeforeStarting={100}
247246
maxPhotoQualityPrioritization="speed"
248247
onCaptureButtonPressIn={() => {
249248
console.log('capture button pressed in');

ios/ReactNativeCameraKit/CKCameraManager.mm

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,23 +6,23 @@
66
#import <AVFoundation/AVFoundation.h>
77

88
#if __has_include(<React/RCTBridge.h>)
9-
#import <React/RCTViewManager.h>
109
#import <React/RCTConvert.h>
10+
#import <React/RCTViewManager.h>
1111
#else
12-
#import "RCTViewManager.h"
1312
#import "RCTConvert.h"
13+
#import "RCTViewManager.h"
1414
#endif
1515

16-
@interface RCT_EXTERN_MODULE(CKCameraManager, RCTViewManager)
16+
@interface RCT_EXTERN_MODULE (CKCameraManager, RCTViewManager)
1717

1818
RCT_EXPORT_VIEW_PROPERTY(cameraType, CKCameraType)
1919
RCT_EXPORT_VIEW_PROPERTY(flashMode, CKFlashMode)
20-
RCT_EXPORT_VIEW_PROPERTY(maxPhotoQualityPrioritization, CKMaxPhotoQualityPrioritization)
20+
RCT_EXPORT_VIEW_PROPERTY(maxPhotoQualityPrioritization,
21+
CKMaxPhotoQualityPrioritization)
2122
RCT_EXPORT_VIEW_PROPERTY(torchMode, CKTorchMode)
2223
RCT_EXPORT_VIEW_PROPERTY(ratioOverlay, NSString)
2324
RCT_EXPORT_VIEW_PROPERTY(ratioOverlayColor, UIColor)
2425
RCT_EXPORT_VIEW_PROPERTY(resizeMode, CKResizeMode)
25-
RCT_EXPORT_VIEW_PROPERTY(iOsSleepBeforeStarting, NSNumber)
2626

2727
RCT_EXPORT_VIEW_PROPERTY(scanBarcode, BOOL)
2828
RCT_EXPORT_VIEW_PROPERTY(onReadCode, RCTDirectEventBlock)

ios/ReactNativeCameraKit/CKCameraViewComponentView.mm

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -279,12 +279,6 @@ - (void)updateProps:(const Props::Shared &)props
279279
_view.maxZoom = newProps.maxZoom > -1 ? @(newProps.maxZoom) : nil;
280280
[changedProps addObject:@"maxZoom"];
281281
}
282-
if (oldViewProps.iOsSleepBeforeStarting != newProps.iOsSleepBeforeStarting) {
283-
_view.iOsSleepBeforeStarting = newProps.iOsSleepBeforeStarting >= 0
284-
? @(newProps.iOsSleepBeforeStarting)
285-
: nil;
286-
[changedProps addObject:@"iOsSleepBeforeStarting"];
287-
}
288282
if (oldViewProps.iOsDeferredStart != newProps.iOsDeferredStart) {
289283
_view.iOsDeferredStart = newProps.iOsDeferredStart;
290284
[changedProps addObject:@"iOsDeferredStart"];

ios/ReactNativeCameraKit/CameraProtocol.swift

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ protocol CameraProtocol: AnyObject, FocusInterfaceViewDelegate {
1717
func update(cameraType: CameraType)
1818
func update(onOrientationChange: RCTDirectEventBlock?)
1919
func update(onZoom: RCTDirectEventBlock?)
20-
func update(iOsSleepBeforeStartingMs: Int?)
2120
func update(iOsDeferredStartEnabled: Bool?)
2221
func update(zoom: Double?)
2322
func update(maxZoom: Double?)

ios/ReactNativeCameraKit/CameraView.swift

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,6 @@ public class CameraView: UIView {
5858
@objc public var zoomMode: ZoomMode = .on
5959
@objc public var zoom: NSNumber?
6060
@objc public var maxZoom: NSNumber?
61-
@objc public var iOsSleepBeforeStarting: NSNumber?
6261
@objc public var iOsDeferredStart: Bool = true
6362

6463
@objc public var onCaptureButtonPressIn: RCTDirectEventBlock?
@@ -84,7 +83,6 @@ public class CameraView: UIView {
8483
if hasPropBeenSetup && hasPermissionBeenGranted && !hasCameraBeenSetup {
8584
let convertedAllowedTypes = convertAllowedBarcodeTypes()
8685

87-
camera.update(iOsSleepBeforeStartingMs: iOsSleepBeforeStarting?.intValue)
8886
camera.update(iOsDeferredStartEnabled: iOsDeferredStart)
8987

9088
hasCameraBeenSetup = true
@@ -304,9 +302,6 @@ public class CameraView: UIView {
304302
}
305303

306304
// Others
307-
if changedProps.contains("iOsSleepBeforeStarting") {
308-
camera.update(iOsSleepBeforeStartingMs: iOsSleepBeforeStarting?.intValue)
309-
}
310305
if changedProps.contains("iOsDeferredStart") {
311306
camera.update(iOsDeferredStartEnabled: iOsDeferredStart)
312307
}

ios/ReactNativeCameraKit/RealCamera.swift

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@ class RealCamera: NSObject, CameraProtocol, AVCaptureMetadataOutputObjectsDelega
4545
private var lastOnZoom: Double?
4646
private var zoom: Double?
4747
private var maxZoom: Double?
48-
private var sleepBeforeStartingMs: Int = 100
4948
private var deferredStartEnabled: Bool = true
5049

5150
// orientation
@@ -135,12 +134,6 @@ class RealCamera: NSObject, CameraProtocol, AVCaptureMetadataOutputObjectsDelega
135134
self.addObservers()
136135

137136
if self.setupResult == .success {
138-
let delay = self.sleepBeforeStartingMs
139-
// Guard against calling startRunning while commitConfiguration is still finishing.
140-
// See README iOsSleepBeforeStarting for details about preventing occasional crashes.
141-
if delay > 0 {
142-
Thread.sleep(forTimeInterval: Double(delay) / 1000.0)
143-
}
144137
self.session.startRunning()
145138
}
146139

@@ -223,12 +216,6 @@ class RealCamera: NSObject, CameraProtocol, AVCaptureMetadataOutputObjectsDelega
223216
self.onZoomCallback = onZoom
224217
}
225218

226-
func update(iOsSleepBeforeStartingMs: Int?) {
227-
let defaultDelayMs = 100
228-
let providedDelay = iOsSleepBeforeStartingMs ?? defaultDelayMs
229-
sleepBeforeStartingMs = max(0, providedDelay)
230-
}
231-
232219
func update(iOsDeferredStartEnabled: Bool?) {
233220
let defaultDeferredStart = true
234221
let shouldEnableDeferredStart = iOsDeferredStartEnabled ?? defaultDeferredStart

ios/ReactNativeCameraKit/SimulatorCamera.swift

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -71,10 +71,6 @@ class SimulatorCamera: CameraProtocol {
7171
self.onZoom = onZoom
7272
}
7373

74-
func update(iOsSleepBeforeStartingMs: Int?) {
75-
// No-op on simulator; startup delay only applies to real devices.
76-
}
77-
7874
func update(iOsDeferredStartEnabled: Bool?) {
7975
// Not applicable on simulator; deferred start only matters for real capture outputs.
8076
}

0 commit comments

Comments
 (0)