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 { try {
controller = Futures.getDone(controllerFuture); controller = Futures.getDone(controllerFuture);
} catch (CancellationException | ExecutionException e) { } catch (CancellationException | ExecutionException e) {
Log.w(TAG, "MediaController future failed (so we couldn't release it)", e);
return; return;
} }
controller.release(); controller.release();

View File

@ -2282,9 +2282,11 @@ import org.checkerframework.checker.nullness.qual.NonNull;
SessionResult result; SessionResult result;
try { try {
result = checkNotNull(future.get(), "SessionResult must not be null"); 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); 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); result = new SessionResult(SessionResult.RESULT_ERROR_UNKNOWN);
} }
sendControllerResult(seq, result); sendControllerResult(seq, result);

View File

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

View File

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

View File

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

View File

@ -889,9 +889,11 @@ import org.checkerframework.checker.nullness.compatqual.NullableType;
SessionResult result; SessionResult result;
try { try {
result = checkNotNull(future.get(), "SessionResult must not be null"); 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); 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); result = new SessionResult(RESULT_ERROR_UNKNOWN);
} }
receiver.send(result.resultCode, result.extras); receiver.send(result.resultCode, result.extras);
@ -1208,7 +1210,7 @@ import org.checkerframework.checker.nullness.compatqual.NullableType;
try { try {
bitmap = Futures.getDone(future); bitmap = Futures.getDone(future);
} catch (CancellationException | ExecutionException e) { } 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)); queueItemList.add(MediaUtils.convertToQueueItem(mediaItems.get(i), i, bitmap));

View File

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