Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Consider InterruptedException as cancellations #86

Merged
merged 1 commit into from
Aug 16, 2024

Conversation

stoyicker
Copy link
Member

This can happen if you call load repeatedly too fast.

To reproduce, wrap the load call in a repeat statement

class Load(private val mediaProduct: MediaProduct) : Pure<PlayerInitialized>() {

    override suspend fun invokePure(state: PlayerInitialized) {
        repeat(100) {
            state.player.playbackEngine.load(mediaProduct.copy(productId = it.toString()))
        }
    }
}

And add some log calls in PlaybackInfoLoadable to understand what's happening:

} catch (throwable: Throwable) {
    when (throwable) {
        is CancellationException, is InterruptedException -> Unit.also {
            Log.d("HOLA", "Cancelled ${forwardingMediaProduct.productId}")
            return
        }
        else -> throw PlaybackInfoFetchException.Error(forwardingMediaProduct, throwable).also {
            Log.d("HOLA", "Errored ${forwardingMediaProduct.productId}", throwable)
        }
    }
}
Log.d("HOLA", "Succeeded ${forwardingMediaProduct.productId}")

You're going to see 100 loads, 99 cancellations and an error (due to the product id not being found, which is correct/intended).

This can happen if you call load repeatedly too fast.
@stoyicker stoyicker requested a review from a team as a code owner August 8, 2024 14:07
@stoyicker stoyicker added this pull request to the merge queue Aug 16, 2024
Merged via the queue into main with commit 53d60b8 Aug 16, 2024
7 checks passed
@stoyicker stoyicker deleted the jantonio/fix_load_cancellation branch August 16, 2024 14:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants