react-native-rectangle-doc-scanner 3.226.0 → 3.228.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.
@@ -10,7 +10,6 @@ import android.graphics.Rect
10
10
  import android.graphics.YuvImage
11
11
  import android.util.Log
12
12
  import android.view.Surface
13
- import androidx.camera.core.AspectRatio
14
13
  import androidx.camera.core.Camera
15
14
  import androidx.camera.core.CameraSelector
16
15
  import androidx.camera.core.ImageAnalysis
@@ -43,6 +42,7 @@ class CameraController(
43
42
  private val cameraExecutor: ExecutorService = Executors.newSingleThreadExecutor()
44
43
  private val lastFrame = AtomicReference<LastFrame?>()
45
44
  private var analysisBound = false
45
+ private var pendingBindAttempts = 0
46
46
 
47
47
  private var useFrontCamera = false
48
48
  private var detectionEnabled = true
@@ -167,6 +167,18 @@ class CameraController(
167
167
  }
168
168
 
169
169
  private fun bindCameraUseCases() {
170
+ if (!previewView.isAttachedToWindow || previewView.width == 0 || previewView.height == 0) {
171
+ if (pendingBindAttempts < 5) {
172
+ pendingBindAttempts++
173
+ Log.d(TAG, "[CAMERAX-V9] PreviewView not ready (attached=${previewView.isAttachedToWindow}, w=${previewView.width}, h=${previewView.height}), retrying...")
174
+ previewView.post { bindCameraUseCases() }
175
+ } else {
176
+ Log.w(TAG, "[CAMERAX-V9] PreviewView still not ready after retries, aborting bind")
177
+ }
178
+ return
179
+ }
180
+ pendingBindAttempts = 0
181
+
170
182
  val provider = cameraProvider ?: return
171
183
  provider.unbindAll()
172
184
  analysisBound = false
@@ -176,7 +188,6 @@ class CameraController(
176
188
 
177
189
  // Build Preview without a fixed size to avoid unsupported stream configs.
178
190
  preview = Preview.Builder()
179
- .setTargetAspectRatio(AspectRatio.RATIO_4_3)
180
191
  .setTargetRotation(rotation)
181
192
  .build()
182
193
  .also {
@@ -198,8 +209,7 @@ class CameraController(
198
209
  preview
199
210
  )
200
211
 
201
- Log.d(TAG, "[CAMERAX-V9] Preview bound with 640x480 resolution")
202
- Log.d(TAG, "[CAMERAX-V9] Waiting for capture session to configure...")
212
+ Log.d(TAG, "[CAMERAX-V9] Preview bound, waiting for capture session to configure...")
203
213
 
204
214
  // Log session state after some time
205
215
  android.os.Handler(android.os.Looper.getMainLooper()).postDelayed({
@@ -78,6 +78,7 @@ class DocumentScannerView(context: ThemedReactContext) : FrameLayout(context), L
78
78
  layoutParams = LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT)
79
79
  visibility = View.VISIBLE
80
80
  keepScreenOn = true
81
+ // TextureView mode avoids some device-specific Camera2 session timeouts.
81
82
  implementationMode = PreviewView.ImplementationMode.COMPATIBLE
82
83
  scaleType = PreviewView.ScaleType.FILL_CENTER
83
84
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-rectangle-doc-scanner",
3
- "version": "3.226.0",
3
+ "version": "3.228.0",
4
4
  "description": "Native-backed document scanner for React Native with customizable overlays.",
5
5
  "license": "MIT",
6
6
  "main": "dist/index.js",