react-native-rectangle-doc-scanner 3.181.0 → 3.183.0

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.
@@ -315,6 +315,11 @@ class CameraController(
315
315
 
316
316
  override fun onError(exception: ImageCaptureException) {
317
317
  Log.e(TAG, "Photo capture failed", exception)
318
+ if (exception.imageCaptureError == ImageCapture.ERROR_CAMERA_CLOSED) {
319
+ Log.w(TAG, "Camera was closed during capture, attempting restart")
320
+ stopCamera()
321
+ startCamera(useFrontCamera, true)
322
+ }
318
323
  onError(exception)
319
324
  }
320
325
  }
@@ -269,6 +269,13 @@ class DocumentScannerView(context: ThemedReactContext) : FrameLayout(context), L
269
269
  return
270
270
  }
271
271
 
272
+ // Ensure lifecycle is active before attempting capture to avoid camera closed errors
273
+ if (lifecycleRegistry.currentState < Lifecycle.State.STARTED) {
274
+ Log.d(TAG, "Lifecycle not STARTED, current state: ${lifecycleRegistry.currentState}")
275
+ promise?.reject("LIFECYCLE_INACTIVE", "Camera preview not ready")
276
+ return
277
+ }
278
+
272
279
  isCapturing = true
273
280
  Log.d(TAG, "Capture initiated with promise: ${promise != null}")
274
281
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-rectangle-doc-scanner",
3
- "version": "3.181.0",
3
+ "version": "3.183.0",
4
4
  "description": "Native-backed document scanner for React Native with customizable overlays.",
5
5
  "license": "MIT",
6
6
  "main": "dist/index.js",
@@ -109,14 +109,6 @@ static inline void dispatch_async_main_queue(dispatch_block_t block)
109
109
  - (void)_foregroundMode
110
110
  {
111
111
  self.forceStop = NO;
112
-
113
- // If the session was stopped while the app was backgrounded, bring it back
114
- if (self.captureSession && !self.captureSession.isRunning) {
115
- NSLog(@"[IPDFCameraViewController] Foreground - restarting capture session");
116
- dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
117
- [self.captureSession startRunning];
118
- });
119
- }
120
112
  }
121
113
 
122
114
  - (void)dealloc
@@ -212,17 +204,6 @@ static inline void dispatch_async_main_queue(dispatch_block_t block)
212
204
  AVCaptureConnection *connection = [dataOutput.connections firstObject];
213
205
  [connection setVideoOrientation:AVCaptureVideoOrientationPortrait];
214
206
 
215
- // Restart capture session automatically after media services/interruption events
216
- [[NSNotificationCenter defaultCenter] addObserver:self
217
- selector:@selector(handleSessionRuntimeError:)
218
- name:AVCaptureSessionRuntimeErrorNotification
219
- object:session];
220
-
221
- [[NSNotificationCenter defaultCenter] addObserver:self
222
- selector:@selector(handleSessionInterruptionEnded:)
223
- name:AVCaptureSessionInterruptionEndedNotification
224
- object:session];
225
-
226
207
  if (device.isFlashAvailable)
227
208
  {
228
209
  [device lockForConfiguration:nil];
@@ -240,34 +221,6 @@ static inline void dispatch_async_main_queue(dispatch_block_t block)
240
221
  [session commitConfiguration];
241
222
  }
242
223
 
243
- - (void)handleSessionRuntimeError:(NSNotification *)notification
244
- {
245
- NSError *error = notification.userInfo[AVCaptureSessionErrorKey];
246
- NSLog(@"[IPDFCameraViewController] Session runtime error: %@", error);
247
-
248
- // Common case: AVErrorMediaServicesWereReset requires restarting the session
249
- if (error.code == AVErrorMediaServicesWereReset) {
250
- [self restartCaptureSession:@"Media services were reset"];
251
- }
252
- }
253
-
254
- - (void)handleSessionInterruptionEnded:(NSNotification *)notification
255
- {
256
- [self restartCaptureSession:@"Interruption ended"];
257
- }
258
-
259
- - (void)restartCaptureSession:(NSString *)reason
260
- {
261
- if (!self.captureSession || self.captureSession.isRunning) {
262
- return;
263
- }
264
-
265
- NSLog(@"[IPDFCameraViewController] Restarting capture session (%@)", reason);
266
- dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
267
- [self.captureSession startRunning];
268
- });
269
- }
270
-
271
224
  - (void)setCameraViewType:(IPDFCameraViewType)cameraViewType
272
225
  {
273
226
  UIBlurEffect * effect = [UIBlurEffect effectWithStyle:UIBlurEffectStyleDark];