fix(web): forward cues that already exist when a text track is added - #891
Open
tvanlaerhoven wants to merge 4 commits into
Open
fix(web): forward cues that already exist when a text track is added#891tvanlaerhoven wants to merge 4 commits into
tvanlaerhoven wants to merge 4 commits into
Conversation
Contributor
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
wvanhaevre
approved these changes
Aug 6, 2026
devin-ai-integration
Bot
force-pushed
the
devin/1786011178-web-addcue-ordering
branch
from
August 6, 2026 10:42
daf590e to
f66dde5
Compare
devin-ai-integration
Bot
force-pushed
the
devin/1786011178-web-addcue-ordering
branch
from
August 12, 2026 19:27
9504684 to
461c47e
Compare
Co-Authored-By: tom.vanlaerhoven <tom.vanlaerhoven@dolby.com>
Co-Authored-By: tom.vanlaerhoven <tom.vanlaerhoven@dolby.com>
Co-Authored-By: tom.vanlaerhoven <tom.vanlaerhoven@dolby.com>
Co-Authored-By: tom.vanlaerhoven <tom.vanlaerhoven@dolby.com>
tvanlaerhoven
force-pushed
the
devin/1786011178-web-addcue-ordering
branch
from
August 17, 2026 09:13
461c47e to
de6d634
Compare
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.
Summary
WebEventForwarder.onAddTextTrackattached the track-leveladdcuelistener only whenaddtrackfired, so any cue already present on the track at that moment produced no player-levelTEXT_TRACK/addcueevent. On iOS Safari the web SDK populates daterange cues before firingaddtrack, so consumers listening onPlayerEventType.TEXT_TRACKnever received them (the cues were only visible viaevent.track.cueson theTEXT_TRACK_LISTevent).Fix: after dispatching
ADD_TRACK, replay the cues already on the track asADD_CUEplayer events. Their uids are remembered so a nativeaddcuearriving later for one of those same cues is not forwarded twice; a uid is dropped from that set onremovecue, so a genuine remove/re-add still forwards. The set only ever holds cues that existed ataddtracktime — cues arriving afterwards are forwarded with no bookkeeping.dispatchEvent(ADD_TRACK, fromNativeTextTrack(track)); + track.cues?.forEach((cue) => dispatchEvent(ADD_CUE, track.uid, fromNativeCue(cue)));Second, unrelated-but-adjacent fix: track listener removal never worked.
onRemoveTextTrack/onRemoveMediaTrackcalledremoveEventListenerwith a freshly created closure (this.onAddTextTrackCue(track)), a different function identity than the one registered — so cue andactivequalitychangedlisteners stayed attached for the life of the player, leaking and dispatching events for removed tracks. The listeners are now kept per track uid and the exact registered reference is removed;removeEventListeners()also detaches tracks that were never explicitly removed.Note the same attach-on-
ADD_TRACKpattern exists in the iOS (THEOplayerRCTTextTrackEventHandler) and Android (PlayerEventEmitter) handlers; those are left alone since the native SDKs fireaddcueafteraddtrack.Verification
No JS test framework exists in this repo, so this was verified with a standalone script driving the compiled forwarder against a fake player/track emitter, covering: cues present at
addtrackare forwarded afterADD_TRACK; a duplicate nativeaddcuefor a replayed cue is suppressed; remove-then-re-add of the same cue is forwarded again; no cue events afterremovetrack.npm run lint,npm run prettierandtsc -p tsconfig.build.jsonpass.Link to Devin session: https://dolby.devinenterprise.com/sessions/fc9bf7b3e83e4f2bafb75a3d70edcb3c
Requested by: @tvanlaerhoven