Merge pull request 'Fix IllegalStateException crash when camera device closes during focus' (#22) from loewy/fix-camera-device-closed-crash into main
Reviewed-on: #22
This commit is contained in:
@@ -243,6 +243,10 @@ class PersistentCameraCaptureSession(private val cameraManager: CameraManager, p
|
||||
} catch (e: CaptureTimedOutError) {
|
||||
// Focus timed out - this is non-fatal, just log and continue
|
||||
Log.w(TAG, "Focus timed out at point $point, continuing without focus lock")
|
||||
} catch (e: IllegalStateException) {
|
||||
Log.w(TAG, "Focus failed, camera device was already closed: ${e.message}")
|
||||
} catch (e: CameraAccessException) {
|
||||
Log.w(TAG, "Focus failed, camera not accessible: ${e.message}")
|
||||
}
|
||||
}
|
||||
focusJob?.join()
|
||||
@@ -259,9 +263,15 @@ class PersistentCameraCaptureSession(private val cameraManager: CameraManager, p
|
||||
return@launch
|
||||
}
|
||||
Log.i(TAG, "Resetting focus to auto-focus...")
|
||||
try {
|
||||
repeatingRequest.createCaptureRequest(device, deviceDetails, outputs).also { request ->
|
||||
session.setRepeatingRequest(request.build(), null, null)
|
||||
}
|
||||
} catch (e: IllegalStateException) {
|
||||
Log.w(TAG, "Failed to reset focus, camera device was already closed: ${e.message}")
|
||||
} catch (e: CameraAccessException) {
|
||||
Log.w(TAG, "Failed to reset focus, camera not accessible: ${e.message}")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user