expo-camera 15.0.1 → 15.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -10,6 +10,12 @@
10
10
 
11
11
  ### 💡 Others
12
12
 
13
+ ## 15.0.2 — 2024-04-24
14
+
15
+ ### 🐛 Bug fixes
16
+
17
+ - On `iOS`, fixed regression where recording a video captures dark frames. Reduced frequency of camera initialization. ([#28427](https://github.com/expo/expo/pull/28427) by [@alanjhughes](https://github.com/alanjhughes))
18
+
13
19
  ## 15.0.1 — 2024-04-23
14
20
 
15
21
  _This version does not introduce any user-facing changes._
@@ -1,7 +1,7 @@
1
1
  apply plugin: 'com.android.library'
2
2
 
3
3
  group = 'host.exp.exponent'
4
- version = '15.0.1'
4
+ version = '15.0.2'
5
5
 
6
6
  def expoModulesCorePlugin = new File(project(":expo-modules-core").projectDir.absolutePath, "ExpoModulesCorePlugin.gradle")
7
7
  apply from: expoModulesCorePlugin
@@ -14,7 +14,7 @@ android {
14
14
  namespace "expo.modules.camera"
15
15
  defaultConfig {
16
16
  versionCode 32
17
- versionName "15.0.1"
17
+ versionName "15.0.2"
18
18
  }
19
19
  }
20
20
 
@@ -88,9 +88,7 @@ public final class CameraViewModule: Module, ScannerResultHandler {
88
88
  }
89
89
 
90
90
  Prop("mute") { (view, muted: Bool?) in
91
- if let muted, view.isMuted != muted {
92
- view.isMuted = muted
93
- }
91
+ view.isMuted = muted ?? false
94
92
  }
95
93
 
96
94
  Prop("animateShutter") { (view, animate: Bool?) in
@@ -109,6 +107,10 @@ public final class CameraViewModule: Module, ScannerResultHandler {
109
107
  }
110
108
  }
111
109
 
110
+ OnViewDidUpdateProps { view in
111
+ view.initCamera()
112
+ }
113
+
112
114
  AsyncFunction("getAvailablePictureSizes") { (_: String?) in
113
115
  return PictureSize.allCases.map {
114
116
  $0.rawValue
@@ -28,6 +28,7 @@ public class CameraView: ExpoView, EXCameraInterface, EXAppLifecycleListener,
28
28
  mm.gyroUpdateInterval = 0.2
29
29
  return mm
30
30
  }()
31
+ private var cameraShouldInit = true
31
32
 
32
33
  // MARK: Property Observers
33
34
 
@@ -124,8 +125,6 @@ public class CameraView: ExpoView, EXCameraInterface, EXAppLifecycleListener,
124
125
  setupPreview()
125
126
  #endif
126
127
  UIDevice.current.beginGeneratingDeviceOrientationNotifications()
127
- initializeCaptureSessionInput()
128
- startSession()
129
128
  NotificationCenter.default.addObserver(
130
129
  self,
131
130
  selector: #selector(orientationChanged(notification:)),
@@ -140,13 +139,16 @@ public class CameraView: ExpoView, EXCameraInterface, EXAppLifecycleListener,
140
139
  previewLayer.videoPreviewLayer.needsDisplayOnBoundsChange = true
141
140
  }
142
141
 
143
- private func updateType() {
144
- sessionQueue.async {
145
- self.initializeCaptureSessionInput()
146
- if !self.session.isRunning {
147
- self.startSession()
148
- }
142
+ func initCamera() {
143
+ guard cameraShouldInit else {
144
+ return
149
145
  }
146
+ cameraShouldInit = false
147
+ self.initializeCaptureSessionInput()
148
+ }
149
+
150
+ private func updateType() {
151
+ cameraShouldInit = true
150
152
  }
151
153
 
152
154
  public func onAppForegrounded() {
@@ -199,7 +201,6 @@ public class CameraView: ExpoView, EXCameraInterface, EXAppLifecycleListener,
199
201
  if self.mode == .video {
200
202
  if self.videoFileOutput == nil {
201
203
  self.setupMovieFileCapture()
202
- self.updateSessionAudioIsMuted()
203
204
  }
204
205
  } else {
205
206
  self.cleanupMovieFileCapture()
@@ -230,16 +231,13 @@ public class CameraView: ExpoView, EXCameraInterface, EXAppLifecycleListener,
230
231
 
231
232
  self.addErrorNotification()
232
233
  self.changePreviewOrientation()
233
- self.session.commitConfiguration()
234
+ }
234
235
 
235
- // Delay starting the scanner
236
- self.sessionQueue.asyncAfter(deadline: .now() + 0.5) {
237
- self.barcodeScanner.maybeStartBarcodeScanning()
238
- if !self.session.isRunning {
239
- self.session.startRunning()
240
- }
241
- self.onCameraReady()
242
- }
236
+ // Delay starting the scanner
237
+ sessionQueue.asyncAfter(deadline: .now() + 0.5) {
238
+ self.barcodeScanner.maybeStartBarcodeScanning()
239
+ self.session.startRunning()
240
+ self.onCameraReady()
243
241
  }
244
242
  }
245
243
 
@@ -512,6 +510,13 @@ public class CameraView: ExpoView, EXCameraInterface, EXAppLifecycleListener,
512
510
  }
513
511
 
514
512
  func record(options: CameraRecordingOptions, promise: Promise) {
513
+ sessionQueue.async {
514
+ let preset = options.quality?.toPreset()
515
+ if let preset {
516
+ self.updateSessionPreset(preset: preset)
517
+ }
518
+ }
519
+
515
520
  sessionQueue.async {
516
521
  if let videoFileOutput = self.videoFileOutput, !videoFileOutput.isRecording && self.videoRecordedPromise == nil {
517
522
  if let connection = videoFileOutput.connection(with: .video) {
@@ -532,9 +537,6 @@ public class CameraView: ExpoView, EXCameraInterface, EXAppLifecycleListener,
532
537
  }
533
538
  }
534
539
 
535
- let preset = options.quality?.toPreset() ?? .high
536
- self.updateSessionPreset(preset: preset)
537
-
538
540
  if !self.isValidVideoOptions {
539
541
  return
540
542
  }
@@ -582,13 +584,13 @@ public class CameraView: ExpoView, EXCameraInterface, EXAppLifecycleListener,
582
584
  func updateSessionAudioIsMuted() {
583
585
  sessionQueue.async {
584
586
  self.session.beginConfiguration()
585
- for input in self.session.inputs {
586
- if let deviceInput = input as? AVCaptureDeviceInput {
587
- if deviceInput.device.hasMediaType(.audio) {
588
- if self.isMuted {
587
+ if self.isMuted {
588
+ for input in self.session.inputs {
589
+ if let deviceInput = input as? AVCaptureDeviceInput {
590
+ if deviceInput.device.hasMediaType(.audio) {
589
591
  self.session.removeInput(input)
592
+ return
590
593
  }
591
- return
592
594
  }
593
595
  }
594
596
  }
@@ -687,9 +689,11 @@ public class CameraView: ExpoView, EXCameraInterface, EXAppLifecycleListener,
687
689
  func updateSessionPreset(preset: AVCaptureSession.Preset) {
688
690
  #if !targetEnvironment(simulator)
689
691
  if self.session.canSetSessionPreset(preset) {
690
- self.session.beginConfiguration()
691
- self.session.sessionPreset = preset
692
- self.session.commitConfiguration()
692
+ if self.session.sessionPreset != preset {
693
+ self.session.beginConfiguration()
694
+ self.session.sessionPreset = preset
695
+ self.session.commitConfiguration()
696
+ }
693
697
  }
694
698
  #endif
695
699
  }
@@ -722,6 +726,7 @@ public class CameraView: ExpoView, EXCameraInterface, EXAppLifecycleListener,
722
726
  self.onMountError(["message": "Camera could not be started - \(error.localizedDescription)"])
723
727
  }
724
728
  self.session.commitConfiguration()
729
+ self.startSession()
725
730
  }
726
731
  }
727
732
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "expo-camera",
3
- "version": "15.0.1",
3
+ "version": "15.0.2",
4
4
  "description": "A React component that renders a preview for the device's either front or back camera. Camera's parameters like zoom, auto focus, white balance and flash mode are adjustable. With expo-camera, one can also take photos and record videos that are saved to the app's cache. Morever, the component is also capable of detecting faces and bar codes appearing on the preview.",
5
5
  "main": "build/index.js",
6
6
  "types": "build/index.d.ts",
@@ -42,5 +42,5 @@
42
42
  "peerDependencies": {
43
43
  "expo": "*"
44
44
  },
45
- "gitHead": "ee4f30ef3b5fa567ad1bf94794197f7683fdd481"
45
+ "gitHead": "8b4cb45563b85c2ec91b1b249d136661bf6e8981"
46
46
  }