Repository navigation
Fix three bugs in the subtitle resync tool - #562
Merged
Andrews54757 merged 1 commit intoOct 9, 2026
Merged
Conversation
- renderTracks() picked the cues to draw with `start <= max || end >= min`, which is true for every cue, so the whole track was kept in the DOM and repositioned on every frame. It now uses `&&`, the cues that overlap the visible window. - shiftSubtitles() called this.onVideoTimeUpdate(), which SubtitleSyncer does not have, so every shift key press while the tool was open threw a TypeError (caught and logged by EventEmitter). - The track started a drag on any mouse button. After a right-click the context menu swallows the mouseup and the cues followed the pointer. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
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.
What breaks
Three bugs in the subtitle resync tool, all user-visible:
The whole track is redrawn every frame.
renderTracks()picked thecues to draw with
which is true for every cue: any cue starts before the right edge
(
start <= max) or ends after the left edge (end >= min). Theintended window test is the conjunction - cues that overlap the visible
range - so the entire track stayed in the DOM and every cue was
repositioned on every frame, instead of only the handful on screen.
Every shift key press threw a TypeError.
shiftSubtitles()calledthis.onVideoTimeUpdate(), a methodSubtitleSyncerdoes not have. TheEventEmitter caught and logged it, so the shift still applied, but the
console filled with
A right-click started a drag. The track started grabbing on any
mouse button. After a right-click, the context menu swallows the
mouseup, so the track kept following the pointer with no button held.The fix
Filter with
&&- the cues that overlap the visible window:Drop the call to the method that does not exist. The timeline redraws on
its own; the cues in view are refreshed immediately instead:
this.lastUpdate = 0(the render throttle) before re-rendering.Left button only, as the time ticks in the same UI already do:
if (e.button !== 0) return;After a keyboard shift,
lastUpdate = 0also makes cues that moved intoview appear right away instead of up to 500 ms later.
Diff: 1 file, 8 insertions, 2 deletions.
Why this can't break anything else
SubtitleSyncer.mjsis the resync tool'sown controller, instantiated only when the subtitle-resync UI is open.
Normal subtitle playback (SubtitlesManager) does not run this code.
every frame; now only the overlapping ones are. A cue either overlapped
the window or it did not -
||included all of them,&&includesexactly the intended set. Cues outside the window were invisible anyway;
they were just kept in the DOM.
behavior to preserve. The redraw it was meant to trigger is covered by
lastUpdate = 0on the next render tick, which is the file's ownthrottle mechanism.
strictly fewer grab starts, and the tick marks elsewhere in the same UI
already used the identical guard.
Verification
npm ci+node localescript.mjs+node build.mjs(thisrepo's own build path) - all three targets build.
visible range now renders only overlapping cues; shift keys - no
TypeErrorin the console, cues repositioned immediately; right-click onthe track - context menu opens, no drag follows.
eslintwith this repo's.eslintrc.js(google config): noproblems.
git diff --numstatagainstmain:8 2 chrome/player/ui/subtitles/SubtitleSyncer.mjs.