Catch UnsupportedOperationException for High Speed Sessions
When a high speed session is closed, and then a new one is opened, the
resources from the previous session may not be avilable yet, resulting
in an UnsupportedOperationException. Catch the exception and return
null so that Camera2CaptureSequenceProcessor will attempt to create the
session again.
Bug: 358592149
Test: ./gradlew --info --strict \
:camera:camera-camera2-pipe:testDebugUnitTest \
:camera:camera-camera2-pipe:compileDebugUnitTestKotlin \
:camera:camera-camera2-pipe-testing:testDebugUnitTest \
:camera:camera-camera2-pipe-testing:compileDebugUnitTestKotlin \
:camera:camera-camera2-pipe-integration:testDebugUnitTest \
:camera:camera-camera2-pipe-integration:compileDebugUnitTestKotlin \
:camera:integration-tests:camera-testapp-camera2-pipe:testDebugUnitTest \
:camera:integration-tests:camera-testapp-camera2-pipe:compileDebugUnitTestKotlin
Change-Id: Ic23f02d15a0025bd76491a451488aa27fef880eb
diff --git a/camera/camera-camera2-pipe/src/main/java/androidx/camera/camera2/pipe/compat/CaptureSessionWrapper.kt b/camera/camera-camera2-pipe/src/main/java/androidx/camera/camera2/pipe/compat/CaptureSessionWrapper.kt
index 8f405d7..9fb3bcc 100644
--- a/camera/camera-camera2-pipe/src/main/java/androidx/camera/camera2/pipe/compat/CaptureSessionWrapper.kt
+++ b/camera/camera-camera2-pipe/src/main/java/androidx/camera/camera2/pipe/compat/CaptureSessionWrapper.kt
@@ -393,6 +393,17 @@
" was destroyed before calling createHighSpeedRequestList."
}
null
+ } catch (e: UnsupportedOperationException) {
+
+ // b/358592149: When a high speed session is closed, and then another high speed session
+ // is opened, the resources from the previous session might not be available yet.
+ // Since Camera2CaptureSequenceProcessor will try to create the session again, log
+ // and rethrow the error as a standard exception that can be ignored.
+ Log.warn {
+ "Failed to createHighSpeedRequestList from $device because the output surface" +
+ " was not available."
+ }
+ null
}
@Suppress("UNCHECKED_CAST")