Ensure non-started jobs are removed from jobs map when stopping #177
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The problem
Whenever a frame extraction gets cancelled by its request id, there were some cases when a subsequent extract call for the same request id was not reporting any result/error/cancellation.
The cause
The initial cancellation call was fired when the extraction job hadn't started yet, this was causing the job never being interrupted and never getting into a point of triggering a cancellation listener. The cancellation listener is the one in charge of removing the job from the
activeJobMap
, so since it was never removed, subsequent calls with the same request id were immediately discarded because the job still was in theactiveJobMap
.The solution
Add a
isStarted
property to theFrameExtractJob
, which gets set totrue
right at the beginning of therun
method of theRunnable
. This property is exposed toComparableFutureTask
, which at the same time can be read from theActiveExtractJob
in order to determine when the job is being cancelled but hasn't started yet.Visuals
Here's an example of this behavior, modifying a bit the
litr-demo
we can observe the issue and after the fix.