From a3629bd52c751b1129815baea031b7d6b8092453 Mon Sep 17 00:00:00 2001 From: Zak Cohen Date: Sun, 28 Jun 2020 20:34:48 -0700 Subject: [PATCH] Thumbnail Cache - check canceled status on the right thread. The cache was checking the canceled status on the background thread, but the cancel call was being made on the main thread. This was leading to canceled requests still delivering this thumbnail in some cases. Bug: 159840851 Test: local build and non-repo of bug Change-Id: I9a3556f6570eee1db39ebec202c115d58010d7f8 --- .../src/com/android/quickstep/TaskThumbnailCache.java | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/quickstep/src/com/android/quickstep/TaskThumbnailCache.java b/quickstep/src/com/android/quickstep/TaskThumbnailCache.java index ace674383e..2b7a8ec250 100644 --- a/quickstep/src/com/android/quickstep/TaskThumbnailCache.java +++ b/quickstep/src/com/android/quickstep/TaskThumbnailCache.java @@ -166,11 +166,13 @@ public class TaskThumbnailCache { public void run() { ThumbnailData thumbnail = ActivityManagerWrapper.getInstance().getTaskThumbnail( key.id, lowResolution); - if (isCanceled()) { - // We don't call back to the provided callback in this case - return; - } + MAIN_EXECUTOR.execute(() -> { + if (isCanceled()) { + // We don't call back to the provided callback in this case + return; + } + mCache.put(key, thumbnail); callback.accept(thumbnail); onEnd();