javaandroidcameracamera2

CameraCaptureSession abortCapture very bad performance


To update the camera capture session with a new state (focus, exposuretime) it seems i have to call abortCaptures on my current session. Calling this takes about 0.3 seconds though. The viewport also freezes during this time. It seems this other apps change focus without stuttering though, how do these apps do it?

If I don't call abortCaptures on my session it does eventually update to a new focus distance without stuttering, but only after about 10 seconds..

Source file: https://github.com/RuurdBijlsma/Camera/blob/master/app/src/main/java/com/ruurdbijlsma/camera/Camera.java#L166


Solution

  • You don't need to call abortCaptures to change camera capture parameters - you generally only need it if you want to change to a new capture session quickly, and that's only when you have new target Surfaces. Such as switching from photo mode to video mode.

    Just change your focus or exposure settings in your capture request builder, build the request, and submit it to the camera device (probably via setRepeatingRequest()).