ExoPlayer icon indicating copy to clipboard operation
ExoPlayer copied to clipboard

fix ProgressiveDownloader infinite loop

Open Artemych opened this issue 3 years ago • 2 comments

We could get an infinite loop inside the ProgressiveDownloader as downloadRunnable(RunnableFutureTask) could cache the PriorityTooLowException and then we would loop forever until the ProgressiveDownloader would be cancelled.

Detailed explanation: Thread 1 - ProgressiveDownloader working thread Thread 2 - ExoPlayerImpl working thread

  1. ProgressiveDownloader adds C.PRIORITY_DOWNLOAD (Thread 1)
  2. ProgressiveDownloader proceeds with C.PRIORITY_DOWNLOAD (Thread 1)
  3. ExoPlayerImpl add C.PRIORITY_PLAYBACK (Thread 2)
  4. ProgressiveDownloader using PriorityDataSource trying proceedOrThrow and receives an PriorityTooLowException
  5. RunnableFutureTask caches the PriorityTooLowException
  6. ExoPlayerImpl removes C.PRIORITY_PLAYBACK
  7. infinite loop as RunnableFutureTask on get check the cached error state.

Artemych avatar Aug 30 '22 11:08 Artemych

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

google-cla[bot] avatar Aug 30 '22 11:08 google-cla[bot]

Thanks for reporting! We interestingly already fixed a similar issue in https://github.com/roblav96/ExoPlayer/commit/18f7d85c91996c0b6109b2bdec6f8e5ed7a50e44, but only for external retry loops that call the download method again. The internal loop after a PriorityTooLowException has the same problem of course and needs to be fixed as well.

tonihei avatar Sep 06 '22 13:09 tonihei