Skip to content

fix: Keep TTML subtitles visible until their end time when they extend past a segment#10264

Open
abolfazl-moeini wants to merge 1 commit into
shaka-project:mainfrom
abolfazl-moeini:fix/keep-ttml-cues-visible-past-segment
Open

fix: Keep TTML subtitles visible until their end time when they extend past a segment#10264
abolfazl-moeini wants to merge 1 commit into
shaka-project:mainfrom
abolfazl-moeini:fix/keep-ttml-cues-visible-past-segment

Conversation

@abolfazl-moeini

Copy link
Copy Markdown

Description

On DASH streams using fragmented MP4 containers for TTML subtitles, cues with an explicit end attribute that extends past the current segment boundary were being clipped at segmentEnd. This caused subtitles to disappear roughly 0.7 s early in the reported case (and similar for other streams).

ExoPlayer / Media3 handles these cues correctly.

Root cause and changes

A previous fix for duplicate cues across segments (#4631) applied:

start = Math.max(start, segmentStart)
end   = Math.min(end,   segmentEnd)

for non-HLS content. While this eliminated duplicates, it also truncated cues that legitimately continue past the segment and are not repeated in the following segment.

This patch:

  • Only clips the start time (and only when the cue begins before the current segment — i.e. a continuation).
  • Removes the unconditional end clipping for DASH.
  • Adds shaka.text.Utils.isCueStrictSubset + logic in UITextDisplayer.append() so that when the full cue and a tail copy both arrive we only keep the longer one and avoid on-screen duplicates (preserving the EBU subtitles regression in 4.1.3 - duplicate line on screen #4631 behaviour).
  • Leaves the HLS path untouched.

Testing

  • python3 build/check.py — clean.
  • python3 build/test.py --quick --filter="trims cues to segment boundaries|isCueStrictSubset" --uncompiled — 8/8 passing on Chrome & Edge (other browser launcher failures are local env only).
  • Red/green: the updated expectations fail against the old clipping logic and pass with this patch.

Fixes #10172

…d past a segment

On DASH streams with fragmented MP4 TTML subtitle tracks, cues that have
an explicit end time extending past the current segment boundary were
clipped to the segment end. This caused them to disappear early.

A prior change to avoid duplicates (shaka-project#4631) clipped both start and end.
This patch only clips the start (for cues continuing from a prior
segment) and relies on strict-subset deduplication at display time
to suppress duplicates when the same cue payload is present in
adjacent segments.

The HLS path is unchanged.

Fixes shaka-project#10172
@google-cla

google-cla Bot commented Jun 24, 2026

Copy link
Copy Markdown

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.

@shaka-bot

Copy link
Copy Markdown
Collaborator

Bundle Size Report for PR #10264

File HEAD Base Diff
controls.css 38.4 KiB (6.7 KiB) 38.4 KiB (6.7 KiB) 0.0 KiB
controls.modern.css 30.5 KiB (6.1 KiB) 30.5 KiB (6.1 KiB) 0.0 KiB
demo.compiled.debug.js 265.6 KiB (53.8 KiB) 265.6 KiB (53.8 KiB) 0.0 KiB
demo.compiled.js 265.6 KiB (53.8 KiB) 265.6 KiB (53.8 KiB) 0.0 KiB
demo.css 160.2 KiB (25.7 KiB) 160.2 KiB (25.7 KiB) 0.0 KiB
demo.modern.css 144.1 KiB (24.7 KiB) 144.1 KiB (24.7 KiB) 0.0 KiB
locales.js 44.1 KiB (10.9 KiB) 44.1 KiB (10.9 KiB) 0.0 KiB
receiver.compiled.debug.js 151.1 KiB (24.4 KiB) 151.1 KiB (24.4 KiB) 0.0 KiB
receiver.compiled.js 151.1 KiB (24.4 KiB) 151.1 KiB (24.4 KiB) 0.0 KiB
shaka-player.compiled-es2021.debug.js 1285.7 KiB (318.7 KiB) 1285.4 KiB (318.6 KiB) +0.3 KiB
shaka-player.compiled-es2021.js 682.0 KiB (228.9 KiB) 681.8 KiB (228.8 KiB) +0.2 KiB
shaka-player.compiled.debug.js 1568.7 KiB (361.0 KiB) 1568.3 KiB (360.9 KiB) +0.4 KiB
shaka-player.compiled.js 791.1 KiB (258.6 KiB) 790.8 KiB (258.5 KiB) +0.3 KiB
shaka-player.dash-es2021.debug.js 955.6 KiB (241.6 KiB) 955.3 KiB (241.5 KiB) +0.3 KiB
shaka-player.dash-es2021.js 478.5 KiB (163.9 KiB) 478.3 KiB (163.8 KiB) +0.2 KiB
shaka-player.dash.debug.js 1164.8 KiB (273.2 KiB) 1164.4 KiB (273.1 KiB) +0.4 KiB
shaka-player.dash.js 557.6 KiB (185.1 KiB) 557.3 KiB (185.0 KiB) +0.3 KiB
shaka-player.experimental-es2021.debug.js 1679.3 KiB (405.1 KiB) 1679.0 KiB (405.0 KiB) +0.3 KiB
shaka-player.experimental-es2021.js 939.1 KiB (299.9 KiB) 938.8 KiB (299.9 KiB) +0.2 KiB
shaka-player.experimental.debug.js 2028.8 KiB (456.9 KiB) 2028.4 KiB (456.9 KiB) +0.4 KiB
shaka-player.experimental.js 1071.7 KiB (335.6 KiB) 1071.4 KiB (335.5 KiB) +0.3 KiB
shaka-player.hls-es2021.debug.js 979.1 KiB (245.6 KiB) 978.8 KiB (245.5 KiB) +0.3 KiB
shaka-player.hls-es2021.js 506.7 KiB (172.9 KiB) 506.5 KiB (172.8 KiB) +0.2 KiB
shaka-player.hls.debug.js 1192.4 KiB (277.7 KiB) 1191.9 KiB (277.6 KiB) +0.4 KiB
shaka-player.hls.js 588.6 KiB (195.4 KiB) 588.2 KiB (195.3 KiB) +0.3 KiB
shaka-player.transmuxer-worker.debug.js 190.2 KiB (46.5 KiB) 190.2 KiB (46.5 KiB) -0.0 KiB
shaka-player.transmuxer-worker.js 83.5 KiB (28.4 KiB) 83.5 KiB (28.4 KiB) 0.0 KiB
shaka-player.ui-es2021.debug.js 1597.1 KiB (387.6 KiB) 1596.8 KiB (387.5 KiB) +0.3 KiB
shaka-player.ui-es2021.js 899.0 KiB (288.3 KiB) 898.7 KiB (288.2 KiB) +0.2 KiB
shaka-player.ui.debug.js 1916.5 KiB (435.4 KiB) 1916.1 KiB (435.3 KiB) +0.4 KiB
shaka-player.ui.js 1020.0 KiB (321.4 KiB) 1019.7 KiB (321.3 KiB) +0.3 KiB

@shaka-bot

Copy link
Copy Markdown
Collaborator

Incremental code coverage: 97.37%

@avelad

avelad commented Jun 25, 2026

Copy link
Copy Markdown
Member

The behavior is changing because the layout tests are failing

@avelad avelad added type: bug Something isn't working correctly component: TTML The issue involves TTML subtitles specifically priority: P2 Smaller impact or easy workaround labels Jun 25, 2026
@avelad avelad requested a review from a team June 25, 2026 07:26
@avelad avelad added the status: waiting on response Waiting on a response from the reporter(s) of the issue label Jun 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

component: TTML The issue involves TTML subtitles specifically priority: P2 Smaller impact or easy workaround status: waiting on response Waiting on a response from the reporter(s) of the issue type: bug Something isn't working correctly

Projects

None yet

Development

Successfully merging this pull request may close these issues.

TTML cues are clipped to DASH segment boundaries and disappear early

3 participants