fix: NativeHLSTextTracks adopts dash.js text tracks a second time (stack overflow / hang with DASH subtitles) - #1856
Open
digwa-ing wants to merge 1 commit into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Related:
Fixes #1604 (likely also the unreproduced #1231).
Description:
NativeHLSTextTracksexists to discover text tracks that the native playback engine created (Safari + embedded HLS). It is constructed whenevercanPlayType('application/vnd.apple.mpegurl')is non-empty — which is"maybe"on Chromium/Chrome and Safari (Firefox answers"") — and it adopts every native track that has no<track>element.dash.js creates its text tracks the same way (
addTextTrack(), marked withmanualMode), and the DASH provider already registers those fromTEXT_TRACKS_ADDED. So on Chromium/Safari every DASH subtitle track ends up as twoTextTracks in the model (dash-captions-0and one with id"") bound to the same native track.TextTrackList's single-showing rule then disables one whileNativeTextRenderer#onChangere-derives "showing" from the shared native track — a synchronous flip-flop:With native controls this surfaces as a burst of thousands of
Maximum call stack size exceedederrors (playback recovers); with the default custom layout (<Captions />) the page hangs instead.This PR makes
NativeHLSTextTracksskip native tracks that a JS engine owns (manualModemarker) or that are already referenced by a registeredTextTrack.Ready?
Yes.
Anything Else?
Minimal reproduction, no application code — a static page using the CDN build and a public reference stream:
Open in Chrome →
RangeError: Maximum call stack size exceededin the console;p.textTrackslists the single English subtitle twice. Replacecontrolswith<media-video-layout>→ the page freezes. The same page with an HLS source (oneTextTrackper subtitle) is clean, and so is Firefox (noNativeHLSTextTracksthere becausecanPlayTypereturns"").Verified the fix against the built package (1.15.6 with this change applied to the dist chunks) on a real DASH stream with 12 subtitle languages: Chromium/Chrome go from ~6000 errors to 0 with correct track selection, Firefox unchanged, and the
<Captions />layout no longer hangs and renders cues.Review Process:
manualModeis the intended marker for dash.js-created tracks (it is the same check the DASH provider uses in#onTextTracksAdded).manualModeand are not pre-registered, so they still pass).