fix(spf): load final segment when seeking to exact end (#1828)#1852
Open
cjpillsbury wants to merge 1 commit into
Open
fix(spf): load final segment when seeking to exact end (#1828)#1852cjpillsbury wants to merge 1 commit into
cjpillsbury wants to merge 1 commit into
Conversation
`getSegmentsToLoad` used a strict `endTime > currentTime` overlap test, so seeking to `currentTime === duration` selected no segment: the final segment's end equals `currentTime`. The last segment never loaded, `endOfStream()` never fired, the MediaSource stayed `open`, and the seek stalled indefinitely (readyState 1, seeking stuck true). Include the final segment at the end boundary (`isLast && endTime >= currentTime`); interior boundaries keep strict `>` so a just-finished segment isn't reloaded. General segment-loader edge — reproduces on native 0-based sources, independent of non-zero-PTS relocation. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Contributor
📦 Bundle Size Report🎨 @videojs/html — no changesPresets (7)
Media (10)
Players (5)
Skins (30)
UI Components (39)
Sizes are marginal over the root entry point. ⚛️ @videojs/react — no changesPresets (7)
Media (9)
Skins (27)
UI Components (33)
Sizes are marginal over the root entry point. 🧩 @videojs/core — no changesEntries (68)
🏷️ @videojs/element — no changesEntries (2)
📦 @videojs/store — no changesEntries (3)
🔧 @videojs/utils — no changesEntries (11)
📦 @videojs/spf — no changesEntries (4)
ℹ️ How to interpretJS sizes are initial static graph totals (minified + brotli). Lazy dynamic chunks are shown separately when present.
Run |
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.
Fixes #1828.
Summary
Seeking to
currentTime === durationexactly (while playing) stalled indefinitely — the final segment was never selected by the forward-load window, soendOfStream()never fired and the seek couldn't complete.Root cause
getSegmentsToLoadfiltered segments with a strictendTime > currentTimeoverlap test. AtcurrentTime === durationthe final segment'sendTime === duration, so it was excluded, never loaded, and theMediaSourcestayedopen(readyState 1,seekingstuck true).Fix
Include the final segment at the end boundary (
isLast && endTime >= currentTime) ingetSegmentsToLoad; interior boundaries keep strict>so a just-finished segment isn't reloaded. (packages/spf/src/media/buffer/forward-buffer.ts)Testing
forward-buffer21/21,segment-loaderactor 5/5, typecheck + biome clean./spf-segment-loading/, Mux VOD, seek to exactdurationwhile playing): reachesendedin ~0.5s — last segment loads,MediaSource→ended, buffered extends to the full end. On the same harness pre-fix: stalls (seekingstuck true,MediaSourceopen, buffered never reaches the end).Notes
feat/spf-non-zero-pts-relocationand targets it for a clean diff, but touches only pre-existing code, so it's cleanly cherry-pickable tomainif it should land independently.🤖 Generated with Claude Code
Note
Low Risk
Small, targeted change to forward-buffer segment selection with regression tests; no auth, security, or data-handling impact.
Overview
Fixes #1828: seeking to
currentTime === durationwhile playing no longer stalls because the forward buffer now selects the last segment for loading.getSegmentsToLoadstill uses strictsegmentEnd > currentTimefor overlap so a segment the playhead just finished is not reloaded at interior boundaries. For the final segment only, it also treatssegmentEnd >= currentTimeas in-range when the playhead is at the exact end (where end equals duration).Adds unit tests: exact-end loads
seg-12; atcurrentTime === 6onlyseg-6andseg-12are chosen, not the finished first segment.Reviewed by Cursor Bugbot for commit 5d0f367. Bugbot is set up for automated code reviews on this repo. Configure here.