Skip to content

fix(spf): load final segment when seeking to exact end (#1828)#1852

Open
cjpillsbury wants to merge 1 commit into
feat/spf-non-zero-pts-relocationfrom
fix/spf-exact-end-seek-stall
Open

fix(spf): load final segment when seeking to exact end (#1828)#1852
cjpillsbury wants to merge 1 commit into
feat/spf-non-zero-pts-relocationfrom
fix/spf-exact-end-seek-stall

Conversation

@cjpillsbury

@cjpillsbury cjpillsbury commented Jul 17, 2026

Copy link
Copy Markdown
Collaborator

Fixes #1828.

Summary

Seeking to currentTime === duration exactly (while playing) stalled indefinitely — the final segment was never selected by the forward-load window, so endOfStream() never fired and the seek couldn't complete.

Root cause

getSegmentsToLoad filtered segments with a strict endTime > currentTime overlap test. At currentTime === duration the final segment's endTime === duration, so it was excluded, never loaded, and the MediaSource stayed open (readyState 1, seeking stuck true).

Fix

Include the final segment at the end boundary (isLast && endTime >= currentTime) in getSegmentsToLoad; interior boundaries keep strict > so a just-finished segment isn't reloaded. (packages/spf/src/media/buffer/forward-buffer.ts)

Testing

  • Unit: regression test (exact-end → loads final segment; fails before the fix) + guard test (mid-stream boundary does not re-select the finished segment). forward-buffer 21/21, segment-loader actor 5/5, typecheck + biome clean.
  • Browser smoke (sandbox /spf-segment-loading/, Mux VOD, seek to exact duration while playing): reaches ended in ~0.5s — last segment loads, MediaSourceended, buffered extends to the full end. On the same harness pre-fix: stalls (seeking stuck true, MediaSource open, buffered never reaches the end).

Notes

  • General segment-loader edge — reproduces on native 0-based sources, so it is not caused by the non-zero-PTS relocation work.
  • Branched off feat/spf-non-zero-pts-relocation and targets it for a clean diff, but touches only pre-existing code, so it's cleanly cherry-pickable to main if 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 === duration while playing no longer stalls because the forward buffer now selects the last segment for loading.

getSegmentsToLoad still uses strict segmentEnd > currentTime for overlap so a segment the playhead just finished is not reloaded at interior boundaries. For the final segment only, it also treats segmentEnd >= currentTime as in-range when the playhead is at the exact end (where end equals duration).

Adds unit tests: exact-end loads seg-12; at currentTime === 6 only seg-6 and seg-12 are 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.

`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>
@vercel

vercel Bot commented Jul 17, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
v10-sandbox Ready Ready Preview, Comment Jul 17, 2026 9:52pm

Request Review

@github-actions

Copy link
Copy Markdown
Contributor

📦 Bundle Size Report

🎨 @videojs/html — no changes
Presets (7)
Entry Initial Lazy
/video (default) 50.85 kB 54.24 kB
/video (default + hls) 190.10 kB 54.24 kB
/video (minimal) 50.83 kB 54.24 kB
/video (minimal + hls) 190.17 kB 54.24 kB
/audio (default) 44.12 kB 54.24 kB
/audio (minimal) 41.37 kB 54.24 kB
/background 4.20 kB
Media (10)
Entry Initial
/media/background-video 1.14 kB
/media/container 1.71 kB
/media/dash-video 214.79 kB
/media/hlsjs-video 141.52 kB
/media/mux-audio 164.00 kB
/media/mux-video 163.70 kB
/media/native-hls-video 9.05 kB
/media/simple-hls-audio-only 19.02 kB
/media/simple-hls-video 20.99 kB
/media/vimeo-video 12.31 kB
Players (5)
Entry Initial
/video/player 8.22 kB
/audio/player 5.38 kB
/background/player 3.92 kB
/live-video/player 7.63 kB
/live-audio/player 5.39 kB
Skins (30)
Entry Type Initial Lazy
/video/minimal-skin.css css 5.70 kB
/video/skin.css css 5.65 kB
/video/minimal-skin js 50.84 kB 54.24 kB
/video/minimal-skin.tailwind js 51.54 kB 54.24 kB
/video/skin js 50.87 kB 54.24 kB
/video/skin.tailwind js 51.57 kB 54.24 kB
/audio/minimal-skin.css css 3.97 kB
/audio/skin.css css 3.86 kB
/audio/minimal-skin js 41.35 kB 54.24 kB
/audio/minimal-skin.tailwind js 41.89 kB 54.24 kB
/audio/skin js 44.18 kB 54.24 kB
/audio/skin.tailwind js 44.66 kB 54.24 kB
/background/skin.css css 133 B
/background/skin js 1.14 kB
/live-video/minimal-skin.css css 5.70 kB
/live-video/skin.css css 5.65 kB
/live-video/minimal-skin js 47.73 kB 54.24 kB
/live-video/minimal-skin.tailwind js 48.29 kB 54.24 kB
/live-video/skin js 49.41 kB 54.24 kB
/live-video/skin.tailwind js 49.98 kB 54.24 kB
/live-audio/minimal-skin.css css 3.97 kB
/live-audio/skin.css css 3.86 kB
/live-audio/minimal-skin js 33.86 kB 54.24 kB
/live-audio/minimal-skin.tailwind js 33.22 kB 54.24 kB
/live-audio/skin js 36.79 kB 54.24 kB
/live-audio/skin.tailwind js 36.29 kB 54.24 kB
/global.css css 183 B
/shared.css css 153 B
/tailwind.css css 161 B
/skin-element js 1.51 kB
UI Components (39)
Entry Initial
/ui/airplay-button 2.52 kB
/ui/alert-dialog 2.83 kB
/ui/alert-dialog-close 2.24 kB
/ui/alert-dialog-description 2.26 kB
/ui/alert-dialog-title 2.28 kB
/ui/audio-track-radio-group 2.98 kB
/ui/buffering-indicator 2.62 kB
/ui/captions-button 2.57 kB
/ui/captions-radio-group 2.94 kB
/ui/cast-button 2.54 kB
/ui/compounds 3.09 kB
/ui/controls 2.91 kB
/ui/error-dialog 2.92 kB
/ui/fullscreen-button 2.55 kB
/ui/hotkey 2.45 kB
/ui/menu 2.95 kB
/ui/mute-button 2.49 kB
/ui/pip-button 2.50 kB
/ui/play-button 2.56 kB
/ui/playback-rate-button 2.68 kB
/ui/playback-rate-radio-group 2.83 kB
/ui/popover 3.13 kB
/ui/poster 2.47 kB
/ui/quality-radio-group 2.95 kB
/ui/seek-button 2.56 kB
/ui/seek-indicator 2.71 kB
/ui/seek-indicator-value 375 B
/ui/slider 2.94 kB
/ui/status-announcer 2.50 kB
/ui/status-indicator 2.62 kB
/ui/status-indicator-value 419 B
/ui/thumbnail 2.56 kB
/ui/time 2.92 kB
/ui/time-slider 2.95 kB
/ui/tooltip 2.85 kB
/ui/volume-indicator 2.53 kB
/ui/volume-indicator-fill 385 B
/ui/volume-indicator-value 371 B
/ui/volume-slider 2.94 kB

Sizes are marginal over the root entry point.

⚛️ @videojs/react — no changes
Presets (7)
Entry Initial Lazy
/video (default) 40.50 kB 54.24 kB
/video (default + hls) 178.58 kB 54.24 kB
/video (minimal) 40.85 kB 54.24 kB
/video (minimal + hls) 179.06 kB 54.24 kB
/audio (default) 33.64 kB 54.24 kB
/audio (minimal) 33.70 kB 54.24 kB
/background 579 B
Media (9)
Entry Initial
/media/background-video 403 B
/media/dash-video 212.98 kB
/media/hlsjs-video 139.79 kB
/media/mux-audio 162.38 kB
/media/mux-video 162.41 kB
/media/native-hls-video 7.26 kB
/media/simple-hls-audio-only 17.23 kB
/media/simple-hls-video 19.24 kB
/media/vimeo-video 10.44 kB
Skins (27)
Entry Type Initial Lazy
/tailwind.css css 161 B
/video/minimal-skin.css css 5.55 kB
/video/skin.css css 5.52 kB
/video/minimal-skin js 40.70 kB 54.24 kB
/video/minimal-skin.tailwind js 46.79 kB 54.24 kB
/video/skin js 40.35 kB 54.24 kB
/video/skin.tailwind js 46.46 kB 54.24 kB
/audio/minimal-skin.css css 3.79 kB
/audio/skin.css css 3.68 kB
/audio/minimal-skin js 33.57 kB 54.24 kB
/audio/minimal-skin.tailwind js 35.86 kB 54.24 kB
/audio/skin js 33.58 kB 54.24 kB
/audio/skin.tailwind js 37.76 kB 54.24 kB
/background/skin.css css 90 B
/background/skin js 272 B
/live-video/minimal-skin.css css 5.55 kB
/live-video/skin.css css 5.52 kB
/live-video/minimal-skin js 35.31 kB 54.24 kB
/live-video/minimal-skin.tailwind js 41.25 kB 54.24 kB
/live-video/skin js 35.31 kB 54.24 kB
/live-video/skin.tailwind js 41.29 kB 54.24 kB
/live-audio/minimal-skin.css css 3.79 kB
/live-audio/skin.css css 3.68 kB
/live-audio/minimal-skin js 24.25 kB 54.24 kB
/live-audio/minimal-skin.tailwind js 27.42 kB 54.24 kB
/live-audio/skin js 24.31 kB 54.24 kB
/live-audio/skin.tailwind js 27.45 kB 54.24 kB
UI Components (33)
Entry Initial
/ui/airplay-button 2.49 kB
/ui/alert-dialog 2.62 kB
/ui/audio-track 2.36 kB
/ui/buffering-indicator 2.54 kB
/ui/captions-button 2.49 kB
/ui/captions-radio-group 2.33 kB
/ui/cast-button 2.49 kB
/ui/controls 2.53 kB
/ui/error-dialog 2.51 kB
/ui/fullscreen-button 2.45 kB
/ui/gesture 2.33 kB
/ui/hotkey 2.32 kB
/ui/live-button 2.43 kB
/ui/menu 2.63 kB
/ui/mute-button 2.38 kB
/ui/pip-button 2.48 kB
/ui/play-button 2.47 kB
/ui/playback-rate 2.46 kB
/ui/playback-rate-button 2.40 kB
/ui/popover 3.12 kB
/ui/poster 2.47 kB
/ui/quality 2.31 kB
/ui/seek-button 2.41 kB
/ui/seek-indicator 2.63 kB
/ui/slider 2.71 kB
/ui/status-announcer 2.39 kB
/ui/status-indicator 2.43 kB
/ui/thumbnail 2.45 kB
/ui/time 2.25 kB
/ui/time-slider 2.55 kB
/ui/tooltip 3.04 kB
/ui/volume-indicator 2.38 kB
/ui/volume-slider 2.60 kB

Sizes are marginal over the root entry point.

🧩 @videojs/core — no changes
Entries (68)
Entry Initial Lazy
. 10.39 kB
/dom 17.56 kB
/dom/media/custom-media-element 2.09 kB
/dom/media/dash 208.97 kB
/dom/media/google-cast 4.03 kB
/dom/media/hls-js 135.87 kB
/dom/media/media-host 1.25 kB
/dom/media/media-played-ranges 576 B
/dom/media/mux 151.37 kB
/dom/media/native-hls 3.07 kB
/dom/media/simple-hls 18.78 kB
/dom/media/simple-hls-audio-only 16.75 kB
/dom/media/vimeo 9.87 kB
/media/predicate 563 B
/i18n 2.66 kB 54.24 kB
/i18n/locales/all 30.58 kB
/i18n/locales/ar 1.21 kB
/i18n/locales/az 1.08 kB
/i18n/locales/bg 1.25 kB
/i18n/locales/bn 1.27 kB
/i18n/locales/bs 1014 B
/i18n/locales/ca 1.05 kB
/i18n/locales/cs 1.04 kB
/i18n/locales/cy 1.00 kB
/i18n/locales/da 996 B
/i18n/locales/de 1.08 kB
/i18n/locales/el 1.45 kB
/i18n/locales/en 621 B
/i18n/locales/es 1010 B
/i18n/locales/et 1.05 kB
/i18n/locales/eu 1.01 kB
/i18n/locales/fa 1.20 kB
/i18n/locales/fi 1.03 kB
/i18n/locales/fr 1.07 kB
/i18n/locales/gd 1.10 kB
/i18n/locales/gl 1014 B
/i18n/locales/he 1.12 kB
/i18n/locales/hi 1.28 kB
/i18n/locales/hr 1.02 kB
/i18n/locales/hu 1.09 kB
/i18n/locales/it 1023 B
/i18n/locales/ja 1.17 kB
/i18n/locales/ko 1.11 kB
/i18n/locales/lv 1.08 kB
/i18n/locales/mr 1.28 kB
/i18n/locales/nb 1000 B
/i18n/locales/ne 1.28 kB
/i18n/locales/nl 1013 B
/i18n/locales/nn 996 B
/i18n/locales/oc 1.05 kB
/i18n/locales/pl 1.12 kB
/i18n/locales/pt 1.01 kB
/i18n/locales/pt-BR 1.01 kB
/i18n/locales/pt-PT 1009 B
/i18n/locales/ro 1.05 kB
/i18n/locales/ru 1.33 kB
/i18n/locales/sk 1.10 kB
/i18n/locales/sl 1.02 kB
/i18n/locales/sr 1.03 kB
/i18n/locales/sv 1022 B
/i18n/locales/te 1.31 kB
/i18n/locales/th 1.29 kB
/i18n/locales/tr 1.07 kB
/i18n/locales/uk 1.36 kB
/i18n/locales/vi 1.08 kB
/i18n/locales/zh 1.01 kB
/i18n/locales/zh-CN 1.01 kB
/i18n/locales/zh-TW 1.01 kB
🏷️ @videojs/element — no changes
Entries (2)
Entry Initial
. 996 B
/context 943 B
📦 @videojs/store — no changes
Entries (3)
Entry Initial
. 1.39 kB
/html 696 B
/react 360 B
🔧 @videojs/utils — no changes
Entries (11)
Entry Initial
/array 104 B
/dom 2.74 kB
/events 319 B
/function 327 B
/object 275 B
/predicate 265 B
/percent 281 B
/string 231 B
/style 190 B
/time 629 B
/number 158 B
📦 @videojs/spf — no changes
Entries (4)
Entry Initial
. 4.45 kB
/dom 6.49 kB
/hls 17.70 kB
/background-video 13.19 kB

ℹ️ How to interpret

JS sizes are initial static graph totals (minified + brotli). Lazy dynamic chunks are shown separately when present.

Icon Meaning
No change
🔺 Increased ≤ 10%
🔴 Increased > 10%
🔽 Decreased
🆕 New (no baseline)

Run pnpm size locally to check current initial sizes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant