react-native-rectangle-doc-scanner 3.219.0 → 3.221.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.
@@ -172,22 +172,24 @@ class CameraController(
172
172
  CameraSelector.DEFAULT_BACK_CAMERA
173
173
  }
174
174
 
175
- // Step 1: Bind Preview ONLY first
175
+ // TEMPORARY: Bind Preview ONLY to test if Preview works without ImageAnalysis
176
176
  try {
177
177
  camera = provider.bindToLifecycle(
178
178
  lifecycleOwner,
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-DEBUG] Preview ONLY bound successfully - NO ImageAnalysis")
183
+ analysisBound = false
183
184
 
184
- // Step 2: Add ImageAnalysis after a delay to let Preview session stabilize
185
- android.os.Handler(android.os.Looper.getMainLooper()).postDelayed({
186
- bindImageAnalysis(provider, cameraSelector, rotation)
187
- }, 500)
185
+ // TODO: If Preview works, we need to find alternative for document detection
186
+ // Options:
187
+ // 1. Use ImageCapture instead of ImageAnalysis
188
+ // 2. Use lower resolution for ImageAnalysis (already tried)
189
+ // 3. Use Camera2 API directly instead of CameraX
188
190
 
189
191
  } catch (e: Exception) {
190
- Log.e(TAG, "[CAMERAX-FIX-V4] Failed to bind preview", e)
192
+ Log.e(TAG, "[CAMERAX-DEBUG] Failed to bind preview", e)
191
193
  analysisBound = false
192
194
  }
193
195
  }
@@ -195,19 +197,24 @@ class CameraController(
195
197
  private fun bindImageAnalysis(provider: ProcessCameraProvider, cameraSelector: CameraSelector, rotation: Int) {
196
198
  if (analysisBound) return
197
199
 
200
+ Log.d(TAG, "[CAMERAX-FIX-V5] Starting to add ImageAnalysis...")
201
+
198
202
  try {
199
- // Build ImageAnalysis
203
+ // Build ImageAnalysis with very low resolution
200
204
  imageAnalysis = ImageAnalysis.Builder()
201
205
  .setBackpressureStrategy(ImageAnalysis.STRATEGY_KEEP_ONLY_LATEST)
202
206
  .setTargetRotation(rotation)
203
- .setTargetResolution(Size(640, 480))
207
+ .setTargetResolution(Size(480, 360))
204
208
  .setOutputImageFormat(ImageAnalysis.OUTPUT_IMAGE_FORMAT_YUV_420_888)
205
209
  .build()
206
210
  .also {
207
211
  it.setAnalyzer(cameraExecutor, DocumentAnalyzer())
208
212
  }
209
213
 
210
- // Rebind with both Preview and ImageAnalysis
214
+ // IMPORTANT: Unbind all first, then rebind together to avoid session reconfiguration timeout
215
+ provider.unbindAll()
216
+
217
+ // Rebind BOTH at the same time
211
218
  camera = provider.bindToLifecycle(
212
219
  lifecycleOwner,
213
220
  cameraSelector,
@@ -215,10 +222,22 @@ class CameraController(
215
222
  imageAnalysis
216
223
  )
217
224
  analysisBound = true
218
- Log.d(TAG, "[CAMERAX-FIX-V4] ImageAnalysis added successfully")
225
+ Log.d(TAG, "[CAMERAX-FIX-V5] ImageAnalysis added successfully after unbind/rebind")
219
226
  } catch (e: Exception) {
220
- Log.e(TAG, "[CAMERAX-FIX-V4] Failed to add ImageAnalysis", e)
227
+ Log.e(TAG, "[CAMERAX-FIX-V5] Failed to add ImageAnalysis", e)
221
228
  analysisBound = false
229
+
230
+ // Fallback: rebind preview only
231
+ try {
232
+ camera = provider.bindToLifecycle(
233
+ lifecycleOwner,
234
+ cameraSelector,
235
+ preview
236
+ )
237
+ Log.d(TAG, "[CAMERAX-FIX-V5] Fallback: Preview only")
238
+ } catch (fallbackException: Exception) {
239
+ Log.e(TAG, "[CAMERAX-FIX-V5] Fallback also failed", fallbackException)
240
+ }
222
241
  }
223
242
  }
224
243
 
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.221.0",
4
4
  "description": "Native-backed document scanner for React Native with customizable overlays.",
5
5
  "license": "MIT",
6
6
  "main": "dist/index.js",