From 34770a2333dbcb448bdc7b7746373cee3a3c9d9c Mon Sep 17 00:00:00 2001 From: Greyson Parrelli Date: Mon, 1 Oct 2018 23:53:33 -0700 Subject: [PATCH] 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 --- .../thoughtcrime/securesms/camera/Camera1Fragment.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/org/thoughtcrime/securesms/camera/Camera1Fragment.java b/src/org/thoughtcrime/securesms/camera/Camera1Fragment.java index f648c81761..bc53462c1c 100644 --- a/src/org/thoughtcrime/securesms/camera/Camera1Fragment.java +++ b/src/org/thoughtcrime/securesms/camera/Camera1Fragment.java @@ -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());