From 26d9aecb6f444e2d5d0543b238de78a13fc87558 Mon Sep 17 00:00:00 2001 From: Valerio Pilo Date: Wed, 17 May 2017 11:15:04 +0200 Subject: Fixed camera crash on exit This is just a copy of a fix already done long time ago (commit c3d5c2c5) only for videos, now also for photos. Original description follows: CameraNext: don't call Glide to load image after Camera exits There is a race condition where the filmstrip can still be trying to load a new image just as the camera exit, and Glide gets upset if it is handed a destroyed activity context to work with. So just check for that condition and go home. Change-Id: If7f2b2e4d23189d3c6876d47d5f2046d9e02c7b0 --- src/com/android/camera/data/LocalMediaData.java | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/com/android/camera/data/LocalMediaData.java b/src/com/android/camera/data/LocalMediaData.java index c32d6ccf9..f8b45da47 100644 --- a/src/com/android/camera/data/LocalMediaData.java +++ b/src/com/android/camera/data/LocalMediaData.java @@ -493,6 +493,13 @@ public abstract class LocalMediaData implements LocalData { return; } + // band-aid over a race condition where the filmstrip is in the process + // of refreshing because of new media just as the camera exits + if ((context instanceof Activity) && ((Activity)context).isDestroyed()) { + Log.d(TAG, "aborted loadImage because context was destroyed"); + return; + } + final int overrideWidth; final int overrideHeight; final BitmapRequestBuilder thumbnailRequest; -- cgit v1.2.3