-
Notifications
You must be signed in to change notification settings - Fork 16
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
Race condition in HlsDownloader leading to ConcurrentModificationException & NPE #101
Comments
Hi @Ilya-Gh, Thank for you reporting an issue and helping improve Kaltura! To get the fastest response time, and help the maintainers review and test your reported issues or suggestions, please ensure that your issue includes the following (please comment with more info if you have not included all this info in your original issue):
and paste the output.
For general troubleshooting see: If you only have a general question rather than a bug report, please close this issue and post at: Thank you in advance, |
Can you please share a sample of your scenario ? Better if you share a fork branch. |
@GouravSna The closer I could get. Ilya-Gh@0756be0 Steps to reproduce:
It crashes 20-30% of times for me with the following exception. I guess it can be
|
Hi @Ilya-Gh , As per our architecture , once you call
Please move your |
Hey @GouravSna. Thanks for taking a look at the issue, but it's reproducible on our end. I have double-checked our project. We already call I have remade the sample project by removing I have added the code that restarts the download when it finish so it will be easier for you to notice the crash (the reproducibility rate is about 5% for me). The line that makes the app crash is Ilya-Gh@e21576d#diff-d59630304bf15fb3aa1e3709f4ca60a982485601c69b7eff2d94c94e37cad140R501 The stack trace with the crash:
Could you please check the first part of the issue, where I described the potential concurrency issue in the code?
|
@GouravSna As this issue is closed. Lets continue the discussion in #115 |
The Race condition in HlsDownloader leading to ConcurrentModificationException & NPE ocurred after update from v2.6.4 to v2.6.9.
Currently, the
HlsDownloader#createDownloadTasks
function can be called from 2 places which are run in 2 separate Threads.TrackSelectorImp.apply
, which uses AsyncTaskssDefaultExecutor
.playkit-dtg-android/dtglib/src/main/java/com/kaltura/dtg/TrackSelectorImp.java
Line 39 in d92e41e
ThreadPoolExecutor
to invokeHlsDownloader#createDownloadTasks
further down the stack viaAbrDownloader#apply
call.playkit-dtg-android/dtglib/src/main/java/com/kaltura/dtg/DownloadService.java
Line 395 in d92e41e
playkit-dtg-android/dtglib/src/main/java/com/kaltura/dtg/AbrDownloader.java
Line 93 in d92e41e
The race condition appeared after metadata fetching was moved to a dedicated
ThreadPoolExecutor
from AsyncTaskssDefaultExecutor
which was reused reusing the same Thread for both calls.Steps to reproduce
Expected Results
The download should start.
Actual Results
The following exceptions are thrown from dtg:
The text was updated successfully, but these errors were encountered: