Skip to content

Commit a9f80ea

Browse files
committed
Fix bitmap re-use bug cross fading from thumb.
1 parent 93a7613 commit a9f80ea

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

library/src/androidTest/java/com/bumptech/glide/request/ThumbnailRequestCoordinatorTest.java

+7
Original file line numberDiff line numberDiff line change
@@ -295,6 +295,13 @@ public void testDoesNotClearThumbOnThumbRequestComplete() {
295295
verify(thumb, never()).clear();
296296
}
297297

298+
@Test
299+
public void testDoesNotClearThumbOnFullComplete_whenThumbIsComplete() {
300+
when(thumb.isComplete()).thenReturn(true);
301+
coordinator.onRequestSuccess(full);
302+
verify(thumb, never()).clear();
303+
}
304+
298305
@Test
299306
public void testDoesNotNotifyParentOnThumbRequestComplete() {
300307
coordinator = new ThumbnailRequestCoordinator(parent);

library/src/main/java/com/bumptech/glide/request/ThumbnailRequestCoordinator.java

+6-1
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,12 @@ public void onRequestSuccess(Request request) {
6666
if (coordinator != null) {
6767
coordinator.onRequestSuccess(this);
6868
}
69-
thumb.clear();
69+
// Clearing the thumb is not necessarily safe if the thumb is being displayed in the Target,
70+
// as a layer in a cross fade for example. The only way we know the thumb is not being
71+
// displayed and is therefore safe to clear is if the thumb request has not yet completed.
72+
if (!thumb.isComplete()) {
73+
thumb.clear();
74+
}
7075
}
7176

7277
private boolean parentIsAnyResourceSet() {

0 commit comments

Comments
 (0)