react-native-rectangle-doc-scanner 3.219.0 → 3.220.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.
@@ -179,15 +179,15 @@ class CameraController(
179
179
  cameraSelector,
180
180
  preview
181
181
  )
182
- Log.d(TAG, "[CAMERAX-FIX-V4] Preview bound, waiting before adding analysis...")
182
+ Log.d(TAG, "[CAMERAX-FIX-V5] Preview bound, waiting 2 seconds before adding analysis...")
183
183
 
184
- // Step 2: Add ImageAnalysis after a delay to let Preview session stabilize
184
+ // Step 2: Add ImageAnalysis after a longer delay to let Preview session fully stabilize
185
185
  android.os.Handler(android.os.Looper.getMainLooper()).postDelayed({
186
186
  bindImageAnalysis(provider, cameraSelector, rotation)
187
- }, 500)
187
+ }, 2000)
188
188
 
189
189
  } catch (e: Exception) {
190
- Log.e(TAG, "[CAMERAX-FIX-V4] Failed to bind preview", e)
190
+ Log.e(TAG, "[CAMERAX-FIX-V5] Failed to bind preview", e)
191
191
  analysisBound = false
192
192
  }
193
193
  }
@@ -195,19 +195,24 @@ class CameraController(
195
195
  private fun bindImageAnalysis(provider: ProcessCameraProvider, cameraSelector: CameraSelector, rotation: Int) {
196
196
  if (analysisBound) return
197
197
 
198
+ Log.d(TAG, "[CAMERAX-FIX-V5] Starting to add ImageAnalysis...")
199
+
198
200
  try {
199
- // Build ImageAnalysis
201
+ // Build ImageAnalysis with very low resolution
200
202
  imageAnalysis = ImageAnalysis.Builder()
201
203
  .setBackpressureStrategy(ImageAnalysis.STRATEGY_KEEP_ONLY_LATEST)
202
204
  .setTargetRotation(rotation)
203
- .setTargetResolution(Size(640, 480))
205
+ .setTargetResolution(Size(480, 360))
204
206
  .setOutputImageFormat(ImageAnalysis.OUTPUT_IMAGE_FORMAT_YUV_420_888)
205
207
  .build()
206
208
  .also {
207
209
  it.setAnalyzer(cameraExecutor, DocumentAnalyzer())
208
210
  }
209
211
 
210
- // Rebind with both Preview and ImageAnalysis
212
+ // IMPORTANT: Unbind all first, then rebind together to avoid session reconfiguration timeout
213
+ provider.unbindAll()
214
+
215
+ // Rebind BOTH at the same time
211
216
  camera = provider.bindToLifecycle(
212
217
  lifecycleOwner,
213
218
  cameraSelector,
@@ -215,10 +220,22 @@ class CameraController(
215
220
  imageAnalysis
216
221
  )
217
222
  analysisBound = true
218
- Log.d(TAG, "[CAMERAX-FIX-V4] ImageAnalysis added successfully")
223
+ Log.d(TAG, "[CAMERAX-FIX-V5] ImageAnalysis added successfully after unbind/rebind")
219
224
  } catch (e: Exception) {
220
- Log.e(TAG, "[CAMERAX-FIX-V4] Failed to add ImageAnalysis", e)
225
+ Log.e(TAG, "[CAMERAX-FIX-V5] Failed to add ImageAnalysis", e)
221
226
  analysisBound = false
227
+
228
+ // Fallback: rebind preview only
229
+ try {
230
+ camera = provider.bindToLifecycle(
231
+ lifecycleOwner,
232
+ cameraSelector,
233
+ preview
234
+ )
235
+ Log.d(TAG, "[CAMERAX-FIX-V5] Fallback: Preview only")
236
+ } catch (fallbackException: Exception) {
237
+ Log.e(TAG, "[CAMERAX-FIX-V5] Fallback also failed", fallbackException)
238
+ }
222
239
  }
223
240
  }
224
241
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-rectangle-doc-scanner",
3
- "version": "3.219.0",
3
+ "version": "3.220.0",
4
4
  "description": "Native-backed document scanner for React Native with customizable overlays.",
5
5
  "license": "MIT",
6
6
  "main": "dist/index.js",