Skip to content

Commit 98e9766

Browse files
NianJiuZststeipete
andauthored
[codex] Fix Android camera snap cleanup (#98040)
* fix: release Android camera snap use case * fix(android): release one-shot camera capture promptly --------- Co-authored-by: NianJiuZst <180004567+users.noreply.github.com> Co-authored-by: Peter Steinberger <[email protected]>
1 parent 496ce0e commit 98e9766

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

apps/android/app/src/main/java/ai/openclaw/app/node/CameraCaptureManager.kt

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,13 @@ class CameraCaptureManager(
137137
// Bind only the still capture use case; CameraX owns camera open/close through the lifecycle owner.
138138
provider.bindToLifecycle(owner, selector, capture)
139139

140-
val (bytes, orientation) = capture.takeJpegWithExif(context.mainExecutor(), context.cacheDir)
140+
val (bytes, orientation) =
141+
try {
142+
capture.takeJpegWithExif(context.mainExecutor(), context.cacheDir)
143+
} finally {
144+
// The JPEG bytes are self-contained; release CameraX before decoding and recompressing them.
145+
provider.unbind(capture)
146+
}
141147
val decoded =
142148
BitmapFactory.decodeByteArray(bytes, 0, bytes.size)
143149
?: throw IllegalStateException("UNAVAILABLE: failed to decode captured image")

0 commit comments

Comments
 (0)