S022: D-015 MSE go (option A), plans S026-S030, PROGRESS, INDEX

Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
astar76 2026-11-12 10:59:36 -06:00
commit c50d76f020
9 changed files with 266 additions and 2 deletions

View file

@ -19,7 +19,7 @@ YouTube's player needs Media Source Extensions; Servo 0.7 has none, so videos sh
- [x] Try YouTube with the prototype (heavy-web.txt YouTube steps): record exactly how far it gets and what breaks next
- [x] Windows: what GStreamer the Windows build needs (bundled runtime size, plugins) for MSE playback
- [x] Write `docs/engine/mse-spike.md`: findings, sized task list (sessions per part), risks, recommendation; then 🧑 ask the user (through the orchestrator) go / no-go
- [ ] PROGRESS entry, DECISIONS (go/no-go), INDEX line, commit `S022: …` and push
- [x] PROGRESS entry, DECISIONS (go/no-go), INDEX line, commit `S022: …` and push
## End criteria
- `docs/engine/mse-spike.md` exists with the upstream state, the sized plan and a recommendation.

View file

@ -0,0 +1,64 @@
# S026 — Fix gst_mse for split audio/video MSE
> Category 05 Engine · Model: Opus · Effort: high · Depends on: S022, S009 · Size: L · Human: no
> Files touched: `vendor/gst-mse/**` (new), `tools/gst-mse.sh` (new), `vendor/servo-media-gstreamer/mse.rs`, `src/main.rs` (library/plugin path), `tests/gst-mse/**` (new)
## Goal
GStreamer's MSE library (gst_mse 1.28.9) has three defects that block YouTube (docs/engine/mse-spike.md "gst_mse
1.28.9 defects"): (1) `update-end` fires before the appended bytes are parsed, so `buffered` is stale; (2) idle
`update`/`update-end` ticks every second; (3) `msesrc` exposes streams before every SourceBuffer has its init
segment, so YouTube's separate audio and video buffers hang at readyState 0. Fix all three in our own copy of the
library and plugin, load that copy from Nacre, and drop the prototype's settle work-around. D-015, option A.
**Branch and worktree:** continue on branch `s022-mse-proto` in the worktree `~/Projects/Nacre-s022`, which has its
own `target/` (never build it in the main checkout's `target/`). First step: `git merge main` into the branch. The
branch lands on main at the end of S028 (see S028), not here.
## Read
- `docs/engine/mse-spike.md` (all of it); D-012 and D-015 in `docs/DECISIONS.md`
- gst-plugins-bad 1.28.9 sources: `gst-libs/gst/mse/` (gstsourcebuffer.c `append_to_buffer_task_func`,
`append_successful_unlocked`; gstappendpipeline.c `consume_all_samples`, END_OF_APPEND; gstmsesrc.c
`append_stream`, `gst_mse_src_emit_streams`) and `ext/mse/` (the plugin). Get them from
`https://sources.debian.org/data/main/g/gst-plugins-bad1.0/1.28.9-1/` (gitlab.freedesktop.org blocks fetches).
- Reference behaviour, read and don't copy: WebKit `Source/WebCore/platform/graphics/gstreamer/mse/` (waits for
all init segments), the MSE spec "init segment received" and HAVE_METADATA steps.
## Steps
- [ ] `git merge main` into `s022-mse-proto` (worktree), build, `tools/smoke.sh tests/smoke/mse.txt` still green
- [ ] Vendor the gst_mse library + mse plugin sources (1.28.9, LGPL-2.1, keep headers and COPYING) into
`vendor/gst-mse/` with a small meson (or cc) build; `tools/gst-mse.sh` builds `libgstmse-1.0.so.0` and the
plugin into `target/gst-mse/`. Mark every change "Nacre patch".
- [ ] Load our copy: the library ahead of the system one (rpath or `LD_LIBRARY_PATH` set before GStreamer
init — check which works with gstreamer-mse-sys) and the plugin via `GST_PLUGIN_PATH`/registry; log the
loaded path once. Decide and record how release builds find it.
- [ ] Bug 1: signal update/update-end only after the end-of-append for that append has been consumed
(`consume_all_samples` done); C test: buffered is non-empty at the first update-end after a media segment
- [ ] Bug 2: no update/update-end without an outstanding append/removal; C test: no signals while idle for 3 s
- [ ] Bug 3: msesrc exposes no streams (and stays HAVE_NOTHING) until every SourceBuffer of the attached
MediaSource has received its first init segment; C test with two SourceBuffers (audio fMP4 + video WebM),
video init appended 2 s before audio, then both play
- [ ] Remove the settle work-around (`SETTLE`, `pending`) from `vendor/servo-media-gstreamer/mse.rs`; rebuild;
`tests/smoke/mse.txt` green
- [ ] Add a two-SourceBuffer case to `tests/smoke/pages/mse-basic.html` (`?split`: audio-only + video-only clips,
video appended first); smoke asserts it plays
- [ ] YouTube probe (heavy-web.txt watch-page steps): record codecs, readyState, currentTime, picture in the shot
- [ ] Write the patches up for upstream (`docs/engine/gst-mse-patches.md`: what, why, test), no MR opened
without the user's OK
- [ ] PROGRESS entry, DECISIONS if the loading scheme binds S030, INDEX line, commit `S026: …` on the branch, push the branch
## End criteria
- `tools/gst-mse.sh` builds; the C tests for bugs 1–3 pass (command in the plan's PROGRESS entry).
- `tools/smoke.sh tests/smoke/mse.txt` passes including the split A/V case.
- Nacre's log shows our libgstmse/plugin path; `SETTLE` is gone from `mse.rs`.
- YouTube result recorded (picture or the next blocker, exactly).
## Pitfalls
- One cargo command at a time per `target/`; the worktree has its own. A `servo-script` edit rebuilds in ~10 min,
a backend-only edit in ~2 min.
- LGPL: keep our gst_mse a separate shared library (dynamic linking), keep its licence files, publish our changes.
- Don't use gitlab.freedesktop.org raw URLs (bot wall); Debian sources work.
- Hidden smoke runs have no audio device; audio sinks fail over to fakesink paths. Don't mistake that for MSE bugs.
- Never connect to Tor or proxies in tests.
## Handoff (→ PROGRESS.md)
How the patched gst_mse is built and loaded (S030 packages it), what YouTube does now, anything left for S027/S028.

View file

@ -0,0 +1,52 @@
# S027 — MSE DOM to spec
> Category 05 Engine · Model: Opus · Effort: high · Depends on: S026 · Size: L · Human: no
> Files touched: `vendor/servo-script/dom/media/{mediasource,sourcebuffer,sourcebufferlist}.rs`, `vendor/servo-script/dom/html/embedded_content/htmlmediaelement.rs`, `vendor/servo-script/dom/url/url.rs`, `vendor/servo-script-bindings/webidls/*.webidl`, `vendor/servo-script-bindings/codegen/Bindings.conf`, `vendor/servo-media-player/mse.rs`, `vendor/servo-media-gstreamer/mse.rs`, `tests/smoke/mse*.txt`, `tests/smoke/pages/mse-*`
## Goal
Replace the S022 spike shortcuts (docs/engine/mse-spike.md "Spike shortcuts") with the spec algorithms, so sites
other than the happy path work: ready-state and event order, duration change, removeSourceBuffer,
activeSourceBuffers, changeType, sequence mode, abort, `HTMLMediaElement.buffered`/`seekable` from the
MediaSource, object URL lifetime, no reference leak, a pref switch. D-015.
**Branch and worktree:** `s022-mse-proto` in `~/Projects/Nacre-s022` (own `target/`); `git merge main` first.
## Read
- `docs/engine/mse-spike.md`; the S026 PROGRESS entry
- MSE spec (w3c.github.io/media-source): attach/detach, appendBuffer, coded frame removal, duration change,
endOfStream, buffered, seeking; HTML "media element load algorithm" for MSE
- Servo issue #40749 (MediaSource in the Blob URL store); Firefox `dom/media/mediasource/` (MPL-2.0) for structure,
ideas only
- WPT `media-source/` tests list (pick the subset that needs no workers, ManagedMediaSource or EME)
## Steps
- [ ] `git merge main` into the branch; build; mse smoke green
- [ ] Object URLs: register in the Blob URL store (or a per-global map freed on revoke after attach and on
document unload); no `Trusted` cycle (weak reference from the event sink); test: a MediaSource is collected
after the page drops it (count via a debug counter in the log)
- [ ] Attach/detach steps: readyState transitions, `sourceopen`/`sourceended`/`sourceclose` queued in spec
order; detach on `src` change/load(); duration change algorithm (`durationchange` on the element)
- [ ] `HTMLMediaElement.buffered` and `seekable` from the MediaSource (intersection of active buffers; live
seekable range); `activeSourceBuffers` tracks selected tracks
- [ ] `removeSourceBuffer` (backend removal, abort first), `changeType` (backend support or NotSupported),
`mode = "sequence"` through the backend append mode, `abort` resets the parser state
- [ ] `dom_media_source_enabled` pref (on by default in Nacre); `MediaSource` absent when off
- [ ] Smoke: mse.txt grows cases (remove + re-append, duration change, changeType same type, abort mid-append,
endOfStream then append reopens) with asserts; a WPT subset page or script run that reports pass counts
- [ ] PROGRESS entry, INDEX line, commit `S027: …` on the branch, push the branch
## End criteria
- `tools/smoke.sh tests/smoke/mse.txt` passes with every new case asserted.
- The leak check shows the MediaSource freed.
- WPT subset pass count recorded in PROGRESS (target ≥ the 293 subtests #47269 reported, minus worker/managed ones).
## Pitfalls
- `servo-script` edits rebuild in ~10 min: batch them. Event firing must go through tasks (never fire from a
GStreamer thread).
- `ReadyState`/`AppendMode` are generated binding enums: map them, don't store them in `#[no_trace]` fields without
`ignore_malloc_size_of`.
- Static WebIDL members on `[Exposed=Window]` take `&Window`, not `&GlobalScope`.
- `[Throws]` attributes get `Get…` names and lose the `cx` config: check Bindings.conf names.
## Handoff (→ PROGRESS.md)
What is still not to spec and why (worker MSE, ManagedMediaSource are out of scope), WPT numbers.

View file

@ -0,0 +1,50 @@
# S028 — MSE player integration and merge to main
> Category 05 Engine · Model: Opus · Effort: high · Depends on: S027 · Size: M · Human: no
> Files touched: `vendor/servo-media-gstreamer/{player,mse,lib}.rs`, `vendor/servo-media-player/*.rs`, `vendor/servo-script/dom/html/embedded_content/htmlmediaelement.rs`, `tests/smoke/mse*.txt`, `Cargo.toml`, `docs/DESIGN.md`, `docs/FEATURES.md`
## Goal
Make MSE playback robust in the player: seeking through msesrc, playback rate, errors, no blocking of the script
thread during attach (S022 saw a page stop answering scripts; `GStreamerPlayer::setup` blocks until
`source-setup`), and a correct codec table for `isTypeSupported` (Opus in WebM reads false today; AV1 when a dav1d
decoder exists). Then land the MSE branch on main. D-015.
**Branch and worktree:** `s022-mse-proto` in `~/Projects/Nacre-s022`; `git merge main` first. **Landing:** at the
end, with every smoke script green on the branch, merge `s022-mse-proto` into main (a merge commit, no
rebase or force push). Then remove the worktree (`git worktree remove`), keep the branch on origin. From S029 on,
work happens on main.
## Read
- `docs/engine/mse-spike.md`; S026/S027 PROGRESS entries
- `vendor/servo-media-gstreamer/player.rs` (`setup`, `source-setup`, seek, `is_ready`), `registry_scanner.rs`
- `docs/DESIGN.md` media section and "Engine limits"
## Steps
- [ ] `git merge main` into the branch; build; mse smoke green
- [ ] Attach without blocking the script thread: setup for `StreamType::MediaSource` returns at once; readiness
arrives as a player event; test: a page appends while the player starts and the `js` probe answers in <1 s
- [ ] Seeking: `currentTime =` inside and outside buffered ranges (waits for an append, then `seeked`); playback
rate; `ended` after endOfStream; smoke asserts each
- [ ] Errors: decode error → `MediaError` + `sourceended`/error events; append of garbage → SourceBuffer `error`
- [ ] Codec table: `isTypeSupported` consistent with `canPlayType` (registry scanner learns opus/webm, vp09.*, av01
when dav1d is installed); unit test for the mime/codec mapping
- [ ] Full smoke set green on the branch (launch, basics, input, chrome, keys, mse, settings; heavy-web where
the network allows) and `nice cargo test --release -j 2`
- [ ] Merge `s022-mse-proto` into main; build main; mse smoke green on main; remove the worktree
- [ ] DESIGN.md: media section (MSE path, vendored crates, patched gst_mse); "Engine limits": drop the MSE line,
keep DRM; FEATURES rows
- [ ] PROGRESS entry, INDEX line, commit `S028: …`, push main
## End criteria
- mse smoke (seek, rate, ended, errors, split A/V) passes on main; `cargo test` green; no smoke regressions.
- The script thread never blocks on attach (probe answers in <1 s).
- main contains the MSE work; the worktree is gone; DESIGN/FEATURES updated.
## Pitfalls
- The merge touches `Cargo.toml` `[patch.crates-io]` and maybe vendored servo-net (S023): resolve by keeping both.
- Main's `target/` will rebuild script and everything downstream after the merge (~10 min + the rest); one cargo
command at a time, and tell the orchestrator before building in the shared checkout.
- Seeking into an unbuffered range must not deadlock msesrc's pad tasks.
## Handoff (→ PROGRESS.md)
MSE on main; known gaps for the YouTube pass (S029).

View file

@ -0,0 +1,41 @@
# S029 — YouTube and Reddit video pass
> Category 05 Engine · Model: Opus · Effort: high · Depends on: S028 · Size: M · Human: 🧑 watches a visible run
> Files touched: `tests/smoke/heavy-web.txt`, `tests/smoke/site-doctor.txt`, `src/**` and `vendor/**` only for fixes found, `docs/FEATURES.md`, `docs/REVIEW.md`
## Goal
Real YouTube playback in the page, with YouTube's own controls, quality menu, captions, seeking, picture in
picture and ad blocking, and Reddit's HLS video (hls.js over MSE). Plus the video sites in site-doctor. Fix what
breaks, or record it exactly. The user's goal from D-013/D-015.
**Branch:** main (MSE merged in S028).
## Read
- `docs/engine/mse-spike.md` "YouTube with the prototype"; S026–S028 PROGRESS entries
- `tests/smoke/heavy-web.txt` (YouTube block), `tests/smoke/site-doctor.txt`; D-008 (PiP reloads the page)
## Steps
- [ ] heavy-web YouTube steps: drop the "can't play" notes; assert `currentTime > 5`, picture (videoWidth > 0 and
the shot shows frames), seek to 50 %, quality change via the settings menu, captions on/off
- [ ] PiP with MSE (D-008: the PiP view reloads the page and seeks), the media button, Discord presence and
MPRIS state from the MSE video
- [ ] Ad blocking still holds on the watch page (no ad slots, shield count > 0)
- [ ] Reddit video post (hls.js): plays, seeks; record the codec path
- [ ] site-doctor video sites: record each as plays / fails (why)
- [ ] Fix the blockers found (each with a smoke assert); anything big goes to PROGRESS "Later" with exact symptoms
- [ ] 🧑 Visible run for the user (`SMOKE_VISIBLE=1`, D-009) of the YouTube steps
- [ ] FEATURES/REVIEW rows; PROGRESS entry, INDEX line, commit `S029: …`, push
## End criteria
- `SMOKE_TIMEOUT=900 tools/smoke.sh tests/smoke/heavy-web.txt` passes the YouTube playback, seek and PiP checks.
- Reddit and site-doctor video results recorded in PROGRESS with shots.
## Pitfalls
- Needs internet; direct connections only, never Tor, VPN or proxy (keep Nacre's VPN off).
- YouTube A/B tests and SABR change behaviour between runs: run each check 3 times before calling it flaky or fixed.
- Hidden runs have no audio device; YouTube may stall on audio-clock issues that don't happen on the user's PC.
Confirm with a visible run.
- DRM videos stay unavailable (no EME).
## Handoff (→ PROGRESS.md)
What plays, what doesn't and why; anything for packaging (codecs the bundle must carry).

View file

@ -0,0 +1,43 @@
# S030 — Ship GStreamer with MSE (AppImage and Windows)
> Category 05 Engine · Model: Opus · Effort: medium · Depends on: S029 · Size: M · Human: no
> Files touched: packaging scripts (AppImage / tar.gz / Inno Setup, wherever the release plans put them), `tools/gst-mse.sh`, `docs/DESIGN.md`, `docs/engine/mse-spike.md` (Windows section)
## Goal
Release builds play MSE video on machines whose system GStreamer is old or missing: the AppImage and tar.gz bundle
GStreamer ≥ 1.26.11 with the mse plugin, our patched gst_mse (S026) and a dav1d AV1 decoder. The Windows installer
and portable zip bundle a subset of the official MSVC runtime (1.28.x) plus our patched gst_mse. Check it in the VM.
D-015.
**Branch:** main.
## Read
- `docs/engine/mse-spike.md` "Windows"; the S026 PROGRESS entry (how the patched gst_mse is built and loaded)
- The user's global CLAUDE.md "Building" (AppImage rules, Inno Setup in wine, the VM "Windows 10")
- GStreamer docs "Deploying on Windows" (which DLLs and plugin dir; `GST_PLUGIN_PATH`, registry)
## Steps
- [ ] List the plugins MSE playback needs (from the S029 runs: mse, isomp4, matroska, vpx, dav1d, libav, opus,
audio sinks, videoconvert/scale, gl if used) and their libraries
- [ ] Linux: bundle that GStreamer set (built or taken from a distro with ≥ 1.26.11) into the AppImage and tar.gz.
Make sure nothing is taken from /usr/lib at run time (`GST_PLUGIN_SYSTEM_PATH` empty, own registry file).
Smoke the AppImage with the mse smoke
- [ ] Windows: build the patched gst_mse with MSVC (in the VM) or MinGW; copy the runtime subset (1.28.x MSVC) next to
`nacre.exe`; measure the bundle size
- [ ] VM test: the installer and portable zip play `mse-basic.html` (software rendering), screenshot + status file
written through `Z:`
- [ ] Record sizes and the plugin list in DESIGN.md; licences (LGPL notices for GStreamer and gst_mse) in the bundle
- [ ] PROGRESS entry, INDEX line, commit `S030: …`, push (no release published; that is the release plan's job)
## End criteria
- The AppImage plays `tests/smoke/pages/mse-basic.html` on a hidden run with the host's GStreamer plugin path empty.
- The Windows build plays it in the VM (shot read and recorded); bundle size recorded.
## Pitfalls
- The 1.28 Windows runtime ships as a 517 MB exe (no merge modules): extract it, don't make users install it.
- Don't bundle /usr/lib system libraries outside GStreamer's own set (user rule); keep glibc from the host.
- VMs have no real GPU: software GL only. PowerShell rules from the global CLAUDE.md apply.
- LGPL: dynamic linking, ship licence texts and our gst_mse source changes.
## Handoff (→ PROGRESS.md)
Bundle sizes, plugin list, anything the release plan must know.

View file

@ -34,7 +34,12 @@ Tracker: https://claude.ai/artifact/9AD7fPfwJ4ASFzVTJGKU4h
- [x] [S021 — Phase 4 review with the user](04%20UI%20redesign/S021-phase4-review.md) · Sonnet medium · 🧑
## 05 Engine
- [ ] [S022 — MediaSource (MSE) spike](05%20Engine/S022-mse-spike.md) · Opus high · 🧑
- [x] [S022 — MediaSource (MSE) spike](05%20Engine/S022-mse-spike.md) · Opus high · 🧑
- [ ] [S026 — Fix gst_mse for split audio/video MSE](05%20Engine/S026-gst-mse-fixes.md) · Opus high
- [ ] [S027 — MSE DOM to spec](05%20Engine/S027-mse-dom-spec.md) · Opus high
- [ ] [S028 — MSE player integration and merge to main](05%20Engine/S028-mse-player.md) · Opus high
- [ ] [S029 — YouTube and Reddit video pass](05%20Engine/S029-youtube-reddit-pass.md) · Opus high · 🧑
- [ ] [S030 — Ship GStreamer with MSE (AppImage and Windows)](05%20Engine/S030-media-packaging.md) · Opus medium
## 06 Privacy
- [ ] [S023 — Request headers and third-party cookies in servo-net](06%20Privacy/S023-net-headers-cookies.md) · Opus medium

View file

@ -17,3 +17,4 @@
- D-012 — 2026-11-12 — servo-net is vendored (`vendor/servo-net`, 0.7.0 + `http2_max_header_list_size(256 KiB)` in `connector.rs` `create_http_client`) via `[patch.crates-io]`. — hyper's 16 KiB HTTP/2 default rejects YouTube's ~19 KiB response headers; Servo can't configure it from the embedder. — any plan that upgrades Servo: drop the patch when servo-net sets the limit, re-run `tests/smoke/heavy-web.txt`
- D-013 — 2026-11-12 — New plans: S022 MSE spike (05 Engine) runs right after S006; privacy plans S023 (request headers + third-party cookies in the vendored servo-net), S024 (privacy mode, R1-16), S025 (encrypted cookies, R1-19) run after S009, before the S010 review. — The user wants real YouTube playback in the page (no yt-dlp workaround) and asked whether missing Servo features can be added from reference engines; the spike sizes MSE before committing weeks to it. — S006–S025 run order
- D-014 — 2026-11-12 — Two more Nacre patches in the vendored servo-net (D-012), marked "Nacre patch": `fetch/methods.rs` lets the certificate warning's `chrome:allowcert` request through (it ended as UnsupportedScheme, so "Open anyway" never worked); `http_cache.rs` `flush_to_disk` + `resource_thread.rs` Exit write the memory HTTP cache to the disk cache at quit (Servo only wrote evicted entries, so a session's cache was lost). — Both are Servo 0.7 bugs the embedder can't work around. — any plan that upgrades Servo: re-check both, re-run `tests/smoke/net-privacy.txt` and `cache.txt` + `cache-restart.txt`
- D-015 — 2026-11-12 — MSE: go, option A (S022). Keep GStreamer's gst_mse library for parsing and coded frame processing; Nacre fixes its three 1.28.9 defects (early update-end, idle ticks, split A/V init segments) in its own copy of the library and plugin, plus a thin MSE DOM in the vendored `servo-script`/`servo-script-bindings`/`servo-media*` crates (`[patch.crates-io]`, like D-012). Option B (an own MSE core in Rust feeding appsrc) is the fallback only if bug 3 can't be fixed in msesrc. Plans S026–S030 run after S009 and before S023–S025. The prototype branch `s022-mse-proto` carries S026–S027 and merges into main in S028. — Decided by the orchestrator overnight on the user's standing OK; the user wants engine fixes, not workarounds (no yt-dlp). The spike showed gst_mse does the hard parts, and the blockers are concrete (docs/engine/mse-spike.md). — S026–S030, any Servo upgrade (drop the patches when Servo ships MSE)

View file

@ -257,6 +257,14 @@ One entry per session, newest last, ≤ 15 lines: done, verified how, not done,
- Not done: Tor/proxy routing and kill switch (never in tests), real filter list downloads, YouTube ad blocking,
ask-where dialog, retry, `<a download>`, IDM, "Always for this site".
## S022 — MediaSource (MSE) spike (2026-11-12)
- Done: upstream check (nothing merged; servo#40423 draft, #47269 closed); docs/engine/mse-spike.md with findings, sized plan, risks and recommendation. Prototype on branch `s022-mse-proto` (worktree ~/Projects/Nacre-s022, own target): MediaSource/SourceBuffer/SourceBufferList over gst_mse, vendored script, script-bindings, servo-media, player and gstreamer. `tests/smoke/mse.txt` passes on the branch (chunk-appended fMP4 and WebM play, frames shown).
- YouTube: own player, blob MediaSource. AV1 run: time 0→12 s with no picture (no AV1 decoder). isTypeSupported now needs a decoder. VP9+AAC stalls at readyState 0 (gst_mse bug 3: split A/V init segments).
- Rebuild cost: script edit 566 s, backend-only edit 106 s, first vendored build 593 s.
- Decision D-015: go, option A; follow-up plans S026–S030 written.
- Not done: Windows runtime not tried in the VM (sizes from the release index only); seeking and quality switches untested.
- Later: Servo refuses fetch/XHR of file:// from file:// pages (smoke clips are base64 scripts); the selftest `js` probe can hang when the script thread blocks (seen once on YouTube).
## Later
- Turnstile widget paints as a black half-disc (Servo painting of its iframe/shadow DOM, S006 site doctor).
- Google sign-in past the email step: press Next with a real account, by the user (S006).