Fixed Camera capture crash on API <= 19.

On older versions of Android, TextureView#getBitmap() needs to be called
on the main thread. On mid range phones, this is ~50ms. Normally that'd
be bad, but the UI isn't doing anything at that point anyway.

Fixes #8232
This commit is contained in:
Greyson Parrelli 2018-10-01 23:53:33 -07:00
parent 2c5fa155ae
commit 34770a2333

View File

@ -193,12 +193,12 @@ public class Camera1Fragment extends Fragment implements TextureView.SurfaceText
shutterSound.play();
orderEnforcer.reset();
Stopwatch fastCaptureTimer = new Stopwatch("Fast Capture");
Bitmap preview = cameraPreview.getBitmap();
fastCaptureTimer.split("captured");
LifecycleBoundTask.run(getLifecycle(), () -> {
Stopwatch fastCaptureTimer = new Stopwatch("Fast Capture");
Bitmap preview = cameraPreview.getBitmap();
fastCaptureTimer.split("captured");
Bitmap full = preview;
if (Build.VERSION.SDK_INT < 28) {
PointF scale = getScaleTransform(cameraPreview.getWidth(), cameraPreview.getHeight(), properties.getPreviewWidth(), properties.getPreviewHeight());