Skip to content

Commit a2f61a0

Browse files
committed
Added iOsDeferredStart for UI performance
Reformatted RealCamera.swift
1 parent cdc1cce commit a2f61a0

10 files changed

Lines changed: 718 additions & 508 deletions

File tree

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,7 @@ Additionally, the Camera can be used for barcode scanning
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` |
200200
| `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 |
201+
| `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. |
201202
| `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")}` |
202203
| `onCaptureButtonPressOut` | Function | Callback when iPhone capture button is released or Android volume or camera button is released. Ex: `onCaptureButtonPressOut={() => console.log("volume button released")}` |
203204
| **Barcode only** |

example/ios/Podfile.lock

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2223,7 +2223,7 @@ PODS:
22232223
- React-perflogger (= 0.81.0)
22242224
- React-utils (= 0.81.0)
22252225
- SocketRocket
2226-
- ReactNativeCameraKit (16.1.3):
2226+
- ReactNativeCameraKit (16.2.0):
22272227
- boost
22282228
- DoubleConversion
22292229
- fast_float
@@ -2552,7 +2552,7 @@ SPEC CHECKSUMS:
25522552
ReactAppDependencyProvider: c91900fa724baee992f01c05eeb4c9e01a807f78
25532553
ReactCodegen: a55799cae416c387aeaae3aabc1bc0289ac19cee
25542554
ReactCommon: 116d6ee71679243698620d8cd9a9042541e44aa6
2555-
ReactNativeCameraKit: 269e2abf46202f729ac49a07829d0b6d1b5a91ad
2555+
ReactNativeCameraKit: 9a5c627808ea152bc4c7e5574a89ced9ca196e40
25562556
SocketRocket: d4aabe649be1e368d1318fdf28a022d714d65748
25572557
Yoga: 00013dd9cde63a2d98e8002fcc4f5ddb66c10782
25582558

ios/ReactNativeCameraKit/CKCameraViewComponentView.mm

Lines changed: 273 additions & 228 deletions
Large diffs are not rendered by default.

ios/ReactNativeCameraKit/CameraProtocol.swift

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ protocol CameraProtocol: AnyObject, FocusInterfaceViewDelegate {
1818
func update(onOrientationChange: RCTDirectEventBlock?)
1919
func update(onZoom: RCTDirectEventBlock?)
2020
func update(iOsSleepBeforeStartingMs: Int?)
21+
func update(iOsDeferredStartEnabled: Bool?)
2122
func update(zoom: Double?)
2223
func update(maxZoom: Double?)
2324
func update(resizeMode: ResizeMode)
@@ -27,13 +28,17 @@ protocol CameraProtocol: AnyObject, FocusInterfaceViewDelegate {
2728
func zoomPinchStart()
2829
func zoomPinchChange(pinchScale: CGFloat)
2930

30-
func isBarcodeScannerEnabled(_ isEnabled: Bool,
31-
supportedBarcodeTypes: [CodeFormat],
32-
onBarcodeRead: ((_ barcode: String, _ codeFormat: CodeFormat) -> Void)?)
31+
func isBarcodeScannerEnabled(
32+
_ isEnabled: Bool,
33+
supportedBarcodeTypes: [CodeFormat],
34+
onBarcodeRead: ((_ barcode: String, _ codeFormat: CodeFormat) -> Void)?)
3335

3436
func update(scannerFrameSize: CGRect?)
3537

36-
func capturePicture(onWillCapture: @escaping () -> Void,
37-
onSuccess: @escaping (_ imageData: Data, _ thumbnailData: Data?, _ dimensions: CMVideoDimensions) -> Void,
38-
onError: @escaping (_ message: String) -> Void)
38+
func capturePicture(
39+
onWillCapture: @escaping () -> Void,
40+
onSuccess:
41+
@escaping (_ imageData: Data, _ thumbnailData: Data?, _ dimensions: CMVideoDimensions)
42+
-> Void,
43+
onError: @escaping (_ message: String) -> Void)
3944
}

0 commit comments

Comments
 (0)