Add logging where we were swallowing failed futures in media3.session

This may not be completely exhaustive, but it's better than before!

#minor-release

PiperOrigin-RevId: 533457167
This commit is contained in:
ibaker 2023-05-19 16:10:18 +01:00 committed by Ian Baker
parent 0e09c0041f
commit fe19dc421d
7 changed files with 28 additions and 15 deletions

View File

@ -529,6 +529,7 @@ public class MediaController implements Player {
try {
controller = Futures.getDone(controllerFuture);
} catch (CancellationException | ExecutionException e) {
Log.w(TAG, "MediaController future failed (so we couldn't release it)", e);
return;
}
controller.release();

View File

@ -2282,9 +2282,11 @@ import org.checkerframework.checker.nullness.qual.NonNull;
SessionResult result;
try {
result = checkNotNull(future.get(), "SessionResult must not be null");
} catch (CancellationException unused) {
} catch (CancellationException e) {
Log.w(TAG, "Session operation cancelled", e);
result = new SessionResult(SessionResult.RESULT_INFO_SKIPPED);
} catch (ExecutionException | InterruptedException unused) {
} catch (ExecutionException | InterruptedException e) {
Log.w(TAG, "Session operation failed", e);
result = new SessionResult(SessionResult.RESULT_ERROR_UNKNOWN);
}
sendControllerResult(seq, result);

View File

@ -1429,7 +1429,7 @@ import org.checkerframework.checker.nullness.compatqual.NullableType;
try {
bitmap = Futures.getDone(future);
} catch (CancellationException | ExecutionException e) {
Log.d(TAG, "Failed to get bitmap");
Log.d(TAG, "Failed to get bitmap", e);
}
}
controllerCompat.addQueueItem(

View File

@ -371,7 +371,8 @@ import org.checkerframework.checker.nullness.compatqual.NullableType;
SessionResult sessionResult =
checkNotNull(future.get(), "SessionResult must not be null");
result.sendResult(sessionResult.extras);
} catch (CancellationException | ExecutionException | InterruptedException unused) {
} catch (CancellationException | ExecutionException | InterruptedException e) {
Log.w(TAG, "Custom action failed", e);
result.sendError(/* extras= */ null);
}
},
@ -386,7 +387,8 @@ import org.checkerframework.checker.nullness.compatqual.NullableType;
try {
MediaBrowserCompat.MediaItem mediaItem = future.get();
result.sendResult(mediaItem);
} catch (CancellationException | ExecutionException | InterruptedException unused) {
} catch (CancellationException | ExecutionException | InterruptedException e) {
Log.w(TAG, "Library operation failed", e);
result.sendError(/* extras= */ null);
}
},
@ -404,7 +406,8 @@ import org.checkerframework.checker.nullness.compatqual.NullableType;
(mediaItems == null)
? null
: MediaUtils.truncateListBySize(mediaItems, TRANSACTION_SIZE_LIMIT_IN_BYTES));
} catch (CancellationException | ExecutionException | InterruptedException unused) {
} catch (CancellationException | ExecutionException | InterruptedException e) {
Log.w(TAG, "Library operation failed", e);
result.sendError(/* extras= */ null);
}
},
@ -477,7 +480,7 @@ import org.checkerframework.checker.nullness.compatqual.NullableType;
try {
bitmap = Futures.getDone(future);
} catch (CancellationException | ExecutionException e) {
Log.d(TAG, "Failed to get bitmap");
Log.d(TAG, "Failed to get bitmap", e);
}
}
outputMediaItems.add(MediaUtils.convertToBrowserItem(mediaItems.get(i), bitmap));
@ -526,7 +529,7 @@ import org.checkerframework.checker.nullness.compatqual.NullableType;
try {
bitmap = Futures.getDone(bitmapFuture);
} catch (CancellationException | ExecutionException e) {
Log.d(TAG, "failed to get bitmap");
Log.d(TAG, "failed to get bitmap", e);
}
outputFuture.set(MediaUtils.convertToBrowserItem(mediaItem, bitmap));
},

View File

@ -359,7 +359,8 @@ import java.util.concurrent.Future;
checkState(future.isDone());
try {
return future.get();
} catch (CancellationException | ExecutionException | InterruptedException unused) {
} catch (CancellationException | ExecutionException | InterruptedException e) {
Log.w(TAG, "Library operation failed", e);
return null;
}
}

View File

@ -889,9 +889,11 @@ import org.checkerframework.checker.nullness.compatqual.NullableType;
SessionResult result;
try {
result = checkNotNull(future.get(), "SessionResult must not be null");
} catch (CancellationException unused) {
} catch (CancellationException e) {
Log.w(TAG, "Custom command cancelled", e);
result = new SessionResult(RESULT_INFO_SKIPPED);
} catch (ExecutionException | InterruptedException unused) {
} catch (ExecutionException | InterruptedException e) {
Log.w(TAG, "Custom command failed", e);
result = new SessionResult(RESULT_ERROR_UNKNOWN);
}
receiver.send(result.resultCode, result.extras);
@ -1208,7 +1210,7 @@ import org.checkerframework.checker.nullness.compatqual.NullableType;
try {
bitmap = Futures.getDone(future);
} catch (CancellationException | ExecutionException e) {
Log.d(TAG, "Failed to get bitmap");
Log.d(TAG, "Failed to get bitmap", e);
}
}
queueItemList.add(MediaUtils.convertToQueueItem(mediaItems.get(i), i, bitmap));

View File

@ -178,9 +178,11 @@ import java.util.concurrent.ExecutionException;
SessionResult result;
try {
result = checkNotNull(future.get(), "SessionResult must not be null");
} catch (CancellationException unused) {
} catch (CancellationException e) {
Log.w(TAG, "Session operation cancelled", e);
result = new SessionResult(SessionResult.RESULT_INFO_SKIPPED);
} catch (ExecutionException | InterruptedException exception) {
Log.w(TAG, "Session operation failed", exception);
result =
new SessionResult(
exception.getCause() instanceof UnsupportedOperationException
@ -265,9 +267,11 @@ import java.util.concurrent.ExecutionException;
LibraryResult<V> result;
try {
result = checkNotNull(future.get(), "LibraryResult must not be null");
} catch (CancellationException unused) {
} catch (CancellationException e) {
Log.w(TAG, "Library operation cancelled", e);
result = LibraryResult.ofError(LibraryResult.RESULT_INFO_SKIPPED);
} catch (ExecutionException | InterruptedException unused) {
} catch (ExecutionException | InterruptedException e) {
Log.w(TAG, "Library operation failed", e);
result = LibraryResult.ofError(LibraryResult.RESULT_ERROR_UNKNOWN);
}
sendLibraryResult(controller, sequenceNumber, result);