camera-samples icon indicating copy to clipboard operation
camera-samples copied to clipboard

CameraXVideo: Sample crashes when back button is pressed while recording

Open codejunk1e opened this issue 2 years ago • 1 comments

Issue with sample-CameraXVideo When the camera is recording and the back button is pressed, app crashes. This is unhandled

codejunk1e avatar Jul 27 '22 13:07 codejunk1e

Hey, codejunk1e. Sorry this issue has been open for so long. I just tried this on a Pixel and a Galaxy, and when recording, pressing the back button on the action bar (or the equivalent back gesture) exits the app. When I go back into the app, I see that the video was saved.

This is in line with my expectations for CameraX. The video recording will always have a finalize event, which specifies how the video stopped. For example, if the video was stopped normally, you'd see ERROR_NONE. In the case where the back button is pressed and the app is closed, I'd expect the error to be ERROR_SOURCE_INACTIVE, which happens when the "camera is closed due to lifecycle stopped, [and] the active recording will be finalized with this error, and the output will be generated, containing the frames produced before camera closing."

If you're seeing some other behavior on a different device, can you tell me which device so I can further my testing?

donovanfm avatar Jan 02 '23 22:01 donovanfm