Skip to content

Commit

Permalink
Only restart full request when restarting requests with thumbnails.
Browse files Browse the repository at this point in the history
When thumbnail requests finish after full requests complete, we discard
the thumbnail's resource to decrease memory usage and we set the
thumbnails status to complete. When requests are restarted after they
complete, we just call onLoadComplete with whatever resource they had
previously. As a result, thumbnail requests that completed after full
requests were calling onLoadComplete(null), causing spammy error logs
and potentially undesireable calls to onLoadFailed.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=177489960
  • Loading branch information
sjudd committed Nov 30, 2017
1 parent 2c7aa85 commit a1e3fa2
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,9 @@ private boolean parentIsAnyResourceSet() {
@Override
public void begin() {
isRunning = true;
if (!thumb.isRunning()) {
// If the request has completed previously, there's no need to restart both the full and the
// thumb, we can just restart the full.
if (!full.isComplete() && !thumb.isRunning()) {
thumb.begin();
}
if (isRunning && !full.isRunning()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,33 @@ public void testDoesNotStartThumbOnRunIfRunning() {
verify(thumb, never()).begin();
}

@Test
public void begin_whenFullIsComplete_startsFull() {
when(full.isComplete()).thenReturn(true);

coordinator.begin();

verify(full).begin();
}

@Test
public void begin_whenFullIsComplete_doesNotBeginThumb() {
when(full.isComplete()).thenReturn(true);

coordinator.begin();

verify(thumb, never()).begin();
}

@Test
public void begin_whenFullIsComplete_doesNotSetRunning() {
when(full.isComplete()).thenReturn(true);

coordinator.begin();

assertThat(coordinator.isRunning()).isFalse();
}

@Test
public void testDoesNotStartFullIfClearedByThumb() {
doAnswer(new Answer<Void>() {
Expand Down

0 comments on commit a1e3fa2

Please sign in to comment.