From b7e24c444e35a894611fd45eabaea4e3988137e8 Mon Sep 17 00:00:00 2001 From: Marc Rousavy Date: Tue, 13 Feb 2024 15:15:19 +0100 Subject: [PATCH] fix: Check if session is still valid before resetting AF after focus (#2550) * fix: Check if session is still valid before resetting AF after focus * Update PersistentCameraCaptureSession.kt --- .../mrousavy/camera/core/PersistentCameraCaptureSession.kt | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/package/android/src/main/java/com/mrousavy/camera/core/PersistentCameraCaptureSession.kt b/package/android/src/main/java/com/mrousavy/camera/core/PersistentCameraCaptureSession.kt index d8d2ac9..3b6e056 100644 --- a/package/android/src/main/java/com/mrousavy/camera/core/PersistentCameraCaptureSession.kt +++ b/package/android/src/main/java/com/mrousavy/camera/core/PersistentCameraCaptureSession.kt @@ -238,6 +238,10 @@ class PersistentCameraCaptureSession(private val cameraManager: CameraManager, p // this job got canceled from the outside return@launch } + if (!isRunning || this@PersistentCameraCaptureSession.session != session) { + // the view/session has already been destroyed in the meantime + return@launch + } Log.i(TAG, "Resetting focus to auto-focus...") // 6. Reset AF/AE/AWB to continuous auto-focus again, which is the default here. repeatingRequest.createCaptureRequest(device, deviceDetails, outputs).also { request ->