fix: Catch errors in CaptureSession configuration

This commit is contained in:
Marc Rousavy 2023-10-10 19:18:54 +02:00
parent 727fb39f01
commit 18e69269d4
No known key found for this signature in database
GPG Key ID: 83BEF0F19E8F5321

View File

@ -159,7 +159,6 @@ class CameraView(context: Context) :
fun update(changedProps: ArrayList<String>) {
Log.i(TAG, "Props changed: $changedProps")
try {
val shouldReconfigurePreview = changedProps.containsAny(propsThatRequirePreviewReconfiguration)
val shouldReconfigureSession = shouldReconfigurePreview || changedProps.containsAny(propsThatRequireSessionReconfiguration)
val shouldReconfigureFormat = shouldReconfigureSession || changedProps.containsAny(propsThatRequireFormatReconfiguration)
@ -169,6 +168,7 @@ class CameraView(context: Context) :
val shouldReconfigureZoomGesture = changedProps.contains("enableZoomGesture")
launch {
try {
// Expensive Calls
if (shouldReconfigurePreview) {
setupPreviewView()
@ -192,12 +192,12 @@ class CameraView(context: Context) :
if (shouldReconfigureZoomGesture) {
updateZoomGesture()
}
}
} catch (e: Throwable) {
Log.e(TAG, "update() threw: ${e.message}")
invokeOnError(e)
}
}
}
private suspend fun configureSession() {
try {