@switchlabs/verify-ai-react-native 2.5.2 → 2.5.3

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.
@@ -23,10 +23,18 @@ const CAMERA_CAPTURE_RETRY_DELAY_MS = 350;
23
23
  const CAMERA_CAPTURE_RETRY_TORCH_SETTLE_MS = 800;
24
24
  const IOS_CAMERA_CAPTURE_RETRY_READY_TIMEOUT_MS = 3000;
25
25
  const ANDROID_CAMERA_CAPTURE_RETRY_READY_TIMEOUT_MS = 10000;
26
- const IOS_CAMERA_STARTUP_WATCHDOG_MS = 8000;
26
+ // iOS AVCaptureSession cold start can legitimately exceed 8s on first launch (permission
27
+ // prompt, first-ever session spin-up, thermal/low-power throttling). An 8s watchdog tore
28
+ // down sessions that were seconds from ready and restarted from scratch, which made slow
29
+ // cold starts *worse* and fired camera_preview_timeout in bursts. Match Android at 10s.
30
+ const IOS_CAMERA_STARTUP_WATCHDOG_MS = 10000;
27
31
  const ANDROID_CAMERA_STARTUP_WATCHDOG_MS = 10000;
28
32
  const CAMERA_STARTUP_SLOW_TELEMETRY_MS = 3000;
33
+ // Base backoff between startup remounts. Each successive remount escalates this (see
34
+ // startupRemountBackoffMs below) so later attempts get progressively more uninterrupted
35
+ // time to initialize the native session instead of thrashing at a fixed interval.
29
36
  const CAMERA_STARTUP_REMOUNT_BACKOFF_MS = 350;
37
+ const CAMERA_STARTUP_REMOUNT_BACKOFF_MAX_MS = 1200;
30
38
  const CAMERA_STARTUP_WATCHDOG_MAX_REMOUNTS = 5;
31
39
  const ANDROID_ORIENTATION_NO_EVENT_TIMEOUT_MS = 3000;
32
40
  const ANDROID_ORIENTATION_SAMPLE_TELEMETRY_MS = 3000;
@@ -844,6 +852,9 @@ export function VerifyAIScanner({ onCapture, policy, onResult, onError, onClose,
844
852
  const startupWatchdogRemountCount = startupWatchdogRemountCountRef.current + 1;
845
853
  startupWatchdogRemountCountRef.current = startupWatchdogRemountCount;
846
854
  cameraRemountCountRef.current++;
855
+ // Escalate the backoff with each attempt (350, 700, 1050, capped at 1200ms) so a
856
+ // camera that just needs more time isn't repeatedly interrupted at a fixed cadence.
857
+ const startupRemountBackoffMs = Math.min(CAMERA_STARTUP_REMOUNT_BACKOFF_MS * startupWatchdogRemountCount, CAMERA_STARTUP_REMOUNT_BACKOFF_MAX_MS);
847
858
  telemetry?.track('camera_preview_timeout', {
848
859
  component: 'scanner',
849
860
  error: `Camera did not initialize within ${Math.round(watchdogMs / 1000)} seconds — remounting`,
@@ -852,12 +863,12 @@ export function VerifyAIScanner({ onCapture, policy, onResult, onError, onClose,
852
863
  remount_reason: 'startup_watchdog',
853
864
  startup_watchdog_remount_count: startupWatchdogRemountCount,
854
865
  startup_watchdog_max_remounts: CAMERA_STARTUP_WATCHDOG_MAX_REMOUNTS,
855
- startup_remount_backoff_ms: CAMERA_STARTUP_REMOUNT_BACKOFF_MS,
866
+ startup_remount_backoff_ms: startupRemountBackoffMs,
856
867
  torch_deferred_until_ready: enableTorch ? 1 : 0,
857
868
  }),
858
869
  });
859
870
  requestCameraRemount('startup_watchdog', {
860
- backoffMs: CAMERA_STARTUP_REMOUNT_BACKOFF_MS,
871
+ backoffMs: startupRemountBackoffMs,
861
872
  log: true,
862
873
  });
863
874
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@switchlabs/verify-ai-react-native",
3
- "version": "2.5.2",
3
+ "version": "2.5.3",
4
4
  "description": "React Native SDK for Verify AI - photo verification with AI vision processing",
5
5
  "repository": {
6
6
  "type": "git",
@@ -48,10 +48,18 @@ const CAMERA_CAPTURE_RETRY_DELAY_MS = 350;
48
48
  const CAMERA_CAPTURE_RETRY_TORCH_SETTLE_MS = 800;
49
49
  const IOS_CAMERA_CAPTURE_RETRY_READY_TIMEOUT_MS = 3000;
50
50
  const ANDROID_CAMERA_CAPTURE_RETRY_READY_TIMEOUT_MS = 10000;
51
- const IOS_CAMERA_STARTUP_WATCHDOG_MS = 8000;
51
+ // iOS AVCaptureSession cold start can legitimately exceed 8s on first launch (permission
52
+ // prompt, first-ever session spin-up, thermal/low-power throttling). An 8s watchdog tore
53
+ // down sessions that were seconds from ready and restarted from scratch, which made slow
54
+ // cold starts *worse* and fired camera_preview_timeout in bursts. Match Android at 10s.
55
+ const IOS_CAMERA_STARTUP_WATCHDOG_MS = 10000;
52
56
  const ANDROID_CAMERA_STARTUP_WATCHDOG_MS = 10000;
53
57
  const CAMERA_STARTUP_SLOW_TELEMETRY_MS = 3000;
58
+ // Base backoff between startup remounts. Each successive remount escalates this (see
59
+ // startupRemountBackoffMs below) so later attempts get progressively more uninterrupted
60
+ // time to initialize the native session instead of thrashing at a fixed interval.
54
61
  const CAMERA_STARTUP_REMOUNT_BACKOFF_MS = 350;
62
+ const CAMERA_STARTUP_REMOUNT_BACKOFF_MAX_MS = 1200;
55
63
  const CAMERA_STARTUP_WATCHDOG_MAX_REMOUNTS = 5;
56
64
  const ANDROID_ORIENTATION_NO_EVENT_TIMEOUT_MS = 3000;
57
65
  const ANDROID_ORIENTATION_SAMPLE_TELEMETRY_MS = 3000;
@@ -1042,6 +1050,12 @@ export function VerifyAIScanner({
1042
1050
  const startupWatchdogRemountCount = startupWatchdogRemountCountRef.current + 1;
1043
1051
  startupWatchdogRemountCountRef.current = startupWatchdogRemountCount;
1044
1052
  cameraRemountCountRef.current++;
1053
+ // Escalate the backoff with each attempt (350, 700, 1050, capped at 1200ms) so a
1054
+ // camera that just needs more time isn't repeatedly interrupted at a fixed cadence.
1055
+ const startupRemountBackoffMs = Math.min(
1056
+ CAMERA_STARTUP_REMOUNT_BACKOFF_MS * startupWatchdogRemountCount,
1057
+ CAMERA_STARTUP_REMOUNT_BACKOFF_MAX_MS,
1058
+ );
1045
1059
  telemetry?.track('camera_preview_timeout', {
1046
1060
  component: 'scanner',
1047
1061
  error: `Camera did not initialize within ${Math.round(watchdogMs / 1000)} seconds — remounting`,
@@ -1050,12 +1064,12 @@ export function VerifyAIScanner({
1050
1064
  remount_reason: 'startup_watchdog',
1051
1065
  startup_watchdog_remount_count: startupWatchdogRemountCount,
1052
1066
  startup_watchdog_max_remounts: CAMERA_STARTUP_WATCHDOG_MAX_REMOUNTS,
1053
- startup_remount_backoff_ms: CAMERA_STARTUP_REMOUNT_BACKOFF_MS,
1067
+ startup_remount_backoff_ms: startupRemountBackoffMs,
1054
1068
  torch_deferred_until_ready: enableTorch ? 1 : 0,
1055
1069
  }),
1056
1070
  });
1057
1071
  requestCameraRemount('startup_watchdog', {
1058
- backoffMs: CAMERA_STARTUP_REMOUNT_BACKOFF_MS,
1072
+ backoffMs: startupRemountBackoffMs,
1059
1073
  log: true,
1060
1074
  });
1061
1075
  }