Fix flickering/blinking IMSC Subtitles #4359
Merged
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.
This is detailed further in issue #4358.
This is a proposed fix to prevent subtitle flickering, where the time between removal and appending of divs representing subtitle cues can have gaps in between. Using the stream in the reference player titled “[BBC] On-demand Elephant's Dream - with EBU-TT-D 'Snaking' Subtitle Track (random text) - lines grow over time simulating live subtitles”, it’s clear to see the effect before and after this code is applied.
These changes preserve the work done by @bbert in #4103 & #4155. Extending identical cues is still preserved and I have checked the test stream mentioned in the PR still operates as expected. Additionally, this PR doesn’t affect the operation of WebVTT subtitles or CEA608 captions. The intent is to just target imsc subtitles where this flickering effect has been witnessed.
The following changes have been made:
captionsContainer
immediately before adding new elements in_renderCaption()
._renderCaption()
happens in the same frame (it should if not available anyway now)._renderCaption()
and not at a different time by theonexit
event. Ensure this only happens for imsc subs._extendLastCue()
for clarity.renderHTML
function, for readability. I have not changed the arguments, just the formatting.