react-native-rectangle-doc-scanner 3.214.0 → 3.216.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.
@@ -156,43 +156,14 @@ class CameraController(
156
156
  analysisBound = false
157
157
 
158
158
  val rotation = previewView.display?.rotation ?: Surface.ROTATION_0
159
+
160
+ // Build Preview with PERFORMANCE mode
159
161
  preview = Preview.Builder()
160
162
  .setTargetAspectRatio(AspectRatio.RATIO_4_3)
161
163
  .setTargetRotation(rotation)
162
164
  .build()
163
- .also {
164
- it.setSurfaceProvider(previewView.surfaceProvider)
165
- }
166
-
167
- val cameraSelector = if (useFrontCamera) {
168
- CameraSelector.DEFAULT_FRONT_CAMERA
169
- } else {
170
- CameraSelector.DEFAULT_BACK_CAMERA
171
- }
172
-
173
- try {
174
- camera = provider.bindToLifecycle(
175
- lifecycleOwner,
176
- cameraSelector,
177
- preview
178
- )
179
- Log.d(TAG, "[CAMERAX] Camera bound successfully")
180
- } catch (e: Exception) {
181
- Log.e(TAG, "[CAMERAX] Failed to bind camera", e)
182
- return
183
- }
184
-
185
- // Bind analysis after preview to avoid session timeouts on some devices.
186
- ContextCompat.getMainExecutor(context).execute {
187
- bindAnalysis(cameraSelector, rotation)
188
- }
189
- }
190
165
 
191
- private fun bindAnalysis(cameraSelector: CameraSelector, rotation: Int) {
192
- if (analysisBound) {
193
- return
194
- }
195
- val provider = cameraProvider ?: return
166
+ // Build ImageAnalysis
196
167
  imageAnalysis = ImageAnalysis.Builder()
197
168
  .setBackpressureStrategy(ImageAnalysis.STRATEGY_KEEP_ONLY_LATEST)
198
169
  .setTargetRotation(rotation)
@@ -203,6 +174,13 @@ class CameraController(
203
174
  it.setAnalyzer(cameraExecutor, DocumentAnalyzer())
204
175
  }
205
176
 
177
+ val cameraSelector = if (useFrontCamera) {
178
+ CameraSelector.DEFAULT_FRONT_CAMERA
179
+ } else {
180
+ CameraSelector.DEFAULT_BACK_CAMERA
181
+ }
182
+
183
+ // Bind both Preview and ImageAnalysis together in one call
206
184
  try {
207
185
  camera = provider.bindToLifecycle(
208
186
  lifecycleOwner,
@@ -210,10 +188,14 @@ class CameraController(
210
188
  preview,
211
189
  imageAnalysis
212
190
  )
191
+
192
+ // Set surface provider AFTER binding to avoid timeout
193
+ preview?.setSurfaceProvider(previewView.surfaceProvider)
194
+
213
195
  analysisBound = true
214
- Log.d(TAG, "[CAMERAX] Analysis bound successfully")
196
+ Log.d(TAG, "[CAMERAX-FIX] Camera and analysis bound successfully in ONE call")
215
197
  } catch (e: Exception) {
216
- Log.e(TAG, "[CAMERAX] Failed to bind analysis; keeping preview only", e)
198
+ Log.e(TAG, "[CAMERAX-FIX] Failed to bind camera use cases", e)
217
199
  analysisBound = false
218
200
  }
219
201
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-rectangle-doc-scanner",
3
- "version": "3.214.0",
3
+ "version": "3.216.0",
4
4
  "description": "Native-backed document scanner for React Native with customizable overlays.",
5
5
  "license": "MIT",
6
6
  "main": "dist/index.js",