Nacre/docs/engine/servo-removal.md
astar76 baa3b7f896 servo-cleanup: Servo removal inventory, drop the WPT MSE runner
docs/engine/servo-removal.md lists every Servo-dependent piece (deps, vendor
crates, src/ hooks with the WebKit replacement each needs, docs, tests/tools)
for the 08 WebKit plans. tools/wpt-mse.sh and tests/wpt-mse/ only tested
Nacre's Servo MSE and nothing else uses them. src/, Cargo.toml and vendor/
are untouched.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-12 23:41:37 -06:00

24 KiB

Servo removal inventory (D-032)

Everything in the repo that exists only because the engine is Servo 0.7, and what the WebKit glue must provide in its place. Written 2026-11-12 from the code at 8b11e5d. Nothing here is removed until the WebKit glue builds and the kept smoke scripts pass on it; the only removal done now is the WPT MSE runner (§6).

Legend: remove = goes with Servo; port = keep the idea/file, rewrite against WebKit; keep = engine-agnostic.

1. Cargo.toml and build.rs

Item Why it is there Fate
servo = "=0.7.0" (features bundled_freetype, clipboard, js_jit, webgl, webcrypto, brotli-compression-stream, gamepad, bluetooth, native-bluetooth) the engine remove
feature media = ["servo/media-gstreamer"] (default) <video>/<audio> through servo-media remove (WebKit has its own GStreamer media)
servo-net = "=0.7.0" direct dep so src/ can call the vendored net::nacre module (headers, third-party cookies, cookie jar) remove
[patch.crates-io] servo-net, servo-script, servo-script-bindings, servo-media, servo-media-player, servo-media-gstreamer vendored Servo crates (§2) remove
[patch.crates-io] epaint = vendor/epaint epaint 0.37.0 panics when Servo's canvas turns on vello_cpu multithreading; the copy renders glyphs single-threaded remove with Servo (only Servo triggers it); re-check egui text rendering afterwards
content-security-policy = "0.9" only for content_security_policy::Destination in hub.rs destination_name remove (WebKit gives no CSP type; resource type comes from the WebKit request)
euclid, dpi, keyboard-types, http Servo's geometry/scale types, W3C key events (keys::to_servo), WebResourceResponse headers check after glue: keyboard-types and euclid likely go; http may stay for net/
rusqlite = "0.38" comment "the same version Servo uses" version pin chosen to share Servo's keep, drop the pin reason
gilrs "(Servo gets gamepad input from the embedder)" Gamepad API input fed to Servo WebKitGTK reads gamepads itself (libmanette); remove gilrs + App::poll_gamepads unless WPE needs it
winit/egui_glow/glow version comment "follow what Servo 0.7 … use" shared GL types with Servo keep; free to update once Servo is gone
description = "… built on Servo" metadata change to WebKit
build.rs rpath $ORIGIN/lib:$ORIGIN/../gst-mse/lib makes the patched libgstmse-1.0.so.0 win over the system copy remove (WebKit uses the system GStreamer)

2. vendor/

Crate Why vendored Patch list Fate
vendor/servo-net HTTP/2 header limit 256 KiB (YouTube, D-012); chrome:allowcert for the certificate warning (D-014); memory→disk HTTP cache flush at quit (D-014); nacre.rs module: extra request headers DNT/Sec-GPC/Save-Data, third-party cookie blocking incl. WebSockets, top-level site per webview (S023); cookie jar to/from the embedder instead of plain cookie_jar.json (S025, D-019); Firefox-style Accept-Language in privacy mode (S024) DESIGN.md "Vendored servo-net patches" remove
vendor/servo-script timers rooted against GC (R5-01, S031); Media Source Extensions DOM (S022-S028) DESIGN.md "Vendored servo-script patches", grep -rn Nacre vendor/servo-script remove
vendor/servo-script-bindings MSE WebIDL (MediaSource, SourceBuffer, SourceBufferList) DESIGN.md "Media and Media Source Extensions" remove
vendor/servo-media, vendor/servo-media-player MSE backend traits, MseEvent, helpers same remove
vendor/servo-media-gstreamer MSE backend over gst_mse, byte-stream check, non-blocking player setup, codec table same remove
vendor/gst-mse patched gst-plugins-bad 1.28.9 libgstmse + msesrc (update-end after parse, no idle updates, wait for every init segment, …) docs/engine/gst-mse-patches.md, vendor/gst-mse/nacre.patch remove; keep docs/engine/gst-mse-patches.md as the upstream write-up (no MR opened yet)
vendor/epaint see §1 vendor/epaint/src/text/font_face.rs end remove with Servo

3. src/ — Servo hooks and what WebKit must provide

grep -rlE "servo::|use servo|WebView" src → app.rs, hub.rs, window.rs, tabs.rs, actions.rs, resources.rs, selftest.rs, inject.rs, ui/{mod,chrome,dialogs,menus}.rs, ui/pages/devtools.rs; plus store/cookies.rs (net::nacre). Engine-agnostic and kept: store/* (except cookies glue), net/* (bridge, fetch, tor, dns, download, dlm), adblock.rs, ui/* widgets/pages/paint/theme, media.rs, discord.rs, spell.rs, importer.rs, instance.rs, paths.rs, perf.rs, updates.rs, pdf.rs, util.rs.

The central design to keep: engine callbacks become hub::Events that App::handle_event handles after each spin (hub.rs header). The WebKit glue should produce the same Event enum (with a Nacre-owned tab/view id instead of WebViewId) so app.rs/actions.rs change as little as possible.

3.1 Engine start, event loop, shutdown (app.rs)

Function Servo use WebKit must provide
App::start_servo Preferences (UA, proxy = bridge, dom_* switches, webrender workers, lite mode: layout threads, history length, cache size; disk cache path; devtools server; background colour), Opts (config_dir, temporary_storage), ServoBuilder, set_delegate, UserContentManager a WebContext/NetworkSession per profile (persistent data dirs, ephemeral for incognito), proxy settings = bridge URL, UA, cache model + memory limit from docs/engine/tune/, inspector switch, background colour
Waker (EventLoopWaker), App::spin (spin_event_loop until quiet) Servo's run loop pumped from winit integrate the GLib main context with winit (pump g_main_context_iteration or run GLib on its own thread)
App::quit, exiting drop every WebView/request/UCM handle before GL contexts (SpiderMonkey teardown crash) orderly WebView/context teardown
servo_first_setup cookies loaded before Servo starts cookie storage setup (§3.8)
rustls_provider rustls provider before Servo/ureq TLS keep for ureq only
update_screen → hub.screen → WebViewDelegate::screen_geometry window.screen/outerWidth for pages WebKit reads the real screen; drop unless privacy mode needs a fixed size
web_dark, restyle_all → notify_theme_change(Theme) prefers-color-scheme WebKit settings/gtk-application-prefer-dark-theme or per-view colour scheme

3.2 Delegates (hub.rs impl WebViewDelegate/ServoDelegate for Hub, handled in app.rs handle_event)

Servo callback → Event App handler WebKit equivalent needed
notify_url_changed (+ net::nacre::set_top_level_url) UrlChanged notify::uri
notify_page_title_changed TitleChanged notify::title
notify_status_text_changed StatusText mouse-target-changed (link hover URL)
notify_load_status_changed (Started/HeadParsed/Complete) on_load_status (PiP start, mute, cosmetic filters) load-changed + estimated-load-progress (the chrome's load_estimate can use real progress)
notify_cursor_changed Cursor → window::cursor_icon with offscreen WPE: cursor from the view backend; with GTK widget: none needed
notify_favicon_changed + WebView::favicon() on_favicon (PixelFormat → RGBA) notify::favicon / FaviconDatabase (cairo surface → RGBA)
notify_new_frame_ready on_frame → paint frame-available from the view backend (§3.5)
notify_history_changed History (back/forward lists) BackForwardList changed
notify_closed, notify_crashed close tab / crash page close, web-process-terminated
notify_media_session_event (metadata, playback state, position) MPRIS/Discord/new tab media card WebKit has no embedder Media Session API: keep Nacre's page-script media probe (inject.rs media.*), or is-playing-audio
notify_fullscreen_state_changed Fullscreen enter-fullscreen / leave-fullscreen
notify_animating_changed Animating (redraw pacing) frame callbacks from the backend
request_navigation actions::on_navigation (app scope, external schemes, pop-up rules) decide-policy NAVIGATION_ACTION
request_unload leave-page dialog WebKit runs beforeunload itself (run-dialog BEFORE_UNLOAD_CONFIRM)
request_create_new on_create_new (pop-ups as tabs) create signal returning a new view (related view: same web process)
request_permission (PermissionFeature → store::permissions::Kind) on_permission permission-request (geolocation, notifications, user media, device info, pointer lock, media key system later)
request_authentication HTTP sign-in dialog authenticate
request_protocol_handler protocol handler prompt none in WebKitGTK: show as unavailable
request_resize_to ignored/handled none needed
show_bluetooth_device_dialog device picker WebKit has no Web Bluetooth: show as unavailable
show_embedder_control / hide_embedder_control (SelectElement, ColorPicker, FilePicker, InputMethod, SimpleDialog, ContextMenu) on_control → tabs::Dialog, ui/dialogs.rs, ui/menus.rs PageMenu run-dialog (alert/confirm/prompt), run-file-chooser, run-color-chooser, show-option-menu (select), context-menu (with HitTestResult), input-method context (WPE)
show_notification on_notification (system notification) show-notification
show_console_message devtools console (tabs::ConsoleLine) no signal in WebKitGTK: page script hooking console.* → script message, or drop for Web Inspector
notify_error log load-failed, load-failed-with-tls-errors
notify_devtools_server_started, request_devtools_connection remote debugging on 127.0.0.1:6080 Web Inspector (enable-developer-extras, webkit_web_inspector_show)
load_web_resource (both delegates) → Hub::decide HTTPS-only upgrade, tracking-param strip, Google UA quirk, image permission, ad blocker (block / replace body), blocked counts, network log see §3.6
GamepadDelegate::handle_haptic_effect_request (hub::Gamepads) rumble via gilrs WebKit handles gamepads itself

3.3 Navigation and page control (actions.rs, app.rs)

Where Servo call WebKit
App::build_webview_in, on_create_new WebViewBuilder (rendering context, hidpi, delegate, gamepad delegate, UCM), set_page_zoom, notify_theme_change create view with shared context/UCM, settings, zoom
actions::load_in_active_tab, new_tab, ensure_loaded load(Url) load_uri
go_back, check_app_scope can_go_back/go_back(1) (+ forward) can_go_back/go_back
reload / hard reload reload() reload / reload_bypass_cache
"stop" none in Servo 0.7 stop_loading (new feature)
zoom (actions.rs 410, 2505) set_page_zoom set_zoom_level
eval, eval_pip, cosmetic filters, autofill, media actions, find evaluate_javascript(script, cb) with JSValue evaluate_javascript (JSCValue → serde_json; selftest needs Bool/String/Number/Array)
on_page_message (inject::PageMessage) page → browser channel built on Servo UserContentManager script message handler nacre
install_page_scripts UserScript per document, user styles WebKitUserScript (document-start, all frames), WebKitUserStyleSheet
rest_background_tabs, close_tab, close_window hide(), hub.forget hide/suspend view; WebKit can actually freeze scripts (old "limited" row in settings)
on_favicon, save_page, pdf.rs favicon image, full-page screenshot get_snapshot, WebKitPrintOperation for real PDF (new)
menu_action (servo::ContextMenuAction back/forward/reload/cut/copy/paste/select all/open link/copy link/image) ContextMenu::select execute_editing_command + Nacre's own actions
enter_pip/exit_pip reloads page in a separate WebView (one painter per window, D-008) can move the view instead; page state kept

3.4 Input (window.rs, app.rs window_event, keys.rs, selftest.rs)

send_mouse_move, send_mouse_button, send_wheel, send_touch, page_point(_clamped), MouseLeftViewport, set_focused, keyboard (keys::to_servo → InputEvent::Keyboard), IME (CompositionEvent / ImeEvent, ui::mod ime_control), selftest click/pagetype/pagescroll. WebKit: with WPE, feed wpe_input_* events (pointer, axis, keyboard with XKB keysym, touch) and IME through the input-method context; with a GTK widget, events go to GTK directly and only the selftest needs synthetic events.

3.5 Painting / GL (window.rs, tabs.rs, app.rs on_frame)

BrowserWindow owns a WindowRenderingContext; each tab has an OffscreenRenderingContext (new_context, pip_context); paint_page/paint_unshown/paint_pip/present, page_callback (egui PaintCallback from render_to_parent_callback), take_pip_frame, resized → WebView::resize, hidpi() (Scale<DeviceIndependentPixel, DevicePixel>), device_rect_to_ui, css_point_to_ui, sync_webviews (show/hide, focus). WebKit: the spike decides (WPE + FDO/wpe-platform exporting dmabuf/EGLImage → egui texture, or WebKitGTK widget beside a GL area). Needed: a texture per tab for the egui page card, resize + device scale, frame-ready signal, PiP second surface.

3.6 Network interception (hub.rs decide, actions.rs request_headers)

Servo let the embedder answer every request synchronously (WebResourceLoad::intercept). WebKit has no synchronous embedder hook for subresources:

  • main-frame HTTPS-only and tracking-param strip → decide-policy (navigation) can rewrite/redirect;
  • ad blocker block → WebKitUserContentFilterStore (content blockers compiled from the adblock rules; DESIGN.md must document the conversion) or a web-process extension send-request (can cancel/redirect, no body replace);
  • ad blocker Replace(mime, body) (redirect resources) → web extension send-request redirect to a nacre-resource: URI scheme handler (register_uri_scheme);
  • image permission per site → content blocker rule or extension;
  • blocked counts / devtools network log (NetEntry) → web extension messages, or resource-load-started;
  • Google sign-in UA quirk (set_preference("user_agent")) → per-view user-agent setting;
  • serve_page (intercepted responses), certificate warning chrome:allowcert → load-failed-with-tls-errors + allow_tls_certificate_for_host. Proxy through the bridge stays (NetworkProxySettings).

3.7 Privacy (net::nacre in vendored servo-net, inject.rs PRIVACY_JS)

set_extra_request_headers (DNT, Sec-GPC, Save-Data) → web extension send-request adds headers; set_block_third_party_cookies → CookieManager accept policy NO_THIRD_PARTY (frame document.cookie covered natively, FRAME_COOKIE_JS can go); set_language_list/accept_language → set_preferred_languages; set_top_level_url/forget_webview → not needed. Per-WebView private mode was impossible in Servo; WebKit has ephemeral NetworkSession (incognito in-process). inject.rs Servo-specific shims to drop or re-check: Servo UA cleanup (mainstream_ua, without_servo), SVG_COLOR_JS, WebGL vendor "Mozilla/Servo", FONTS_CHECK_JS, COMPRESSOR_JS, caret/caretRangeFromPoint workaround (line 133), seek-then-play freeze workaround (line 296), navigator platform/version fixes. Unit tests in hub.rs (privacy_language_list_is_firefox_style, privacy_headers_follow_the_settings_and_reach_requests, third_party_matching_keeps_same_site_subdomains) use net::nacre: move the pure parts (privacy_headers, strip_tracking, language list) out of hub.rs first.

3.8 Cookies and site data (store/cookies.rs, app.rs clear_on_exit, actions.rs clear_data, site info)

net::nacre::set_cookie_persistence/cookie_jar_snapshot (encrypted cookies.bin, D-019), site_data_manager() (site_data, clear_site_data, clear_cookies, cookies_for_url for the site info flyout and request_headers), network_manager().clear_cache(), servo::StorageType. WebKit: WebsiteDataManager (fetch/remove by type and since-time — the "Servo keeps no dates" note in ui/pages/misc.rs goes away), CookieManager (get_cookies, persistent storage is SQLite: D-019 encryption-at-rest needs a new decision — keep cookies in memory and seal a dump, or accept WebKit's file).

3.9 Media (app.rs MediaSession, media.rs, PiP)

Servo MediaSession events feed MPRIS/Discord/new tab card; MSE came from the vendored crates. WebKit: native MSE/EME (Widevine later, own plan), is-playing-audio, set_is_muted (replaces media.act mute script); media metadata still via page script.

3.10 Devtools (ui/pages/devtools.rs)

Console (from show_console_message, ConsoleLogLevel colours) and network (hub.net_log) tabs. WebKit: Web Inspector replaces both or feeds them; keep the page if the log sources (§3.2, §3.6) are ported.

3.11 Selftest (selftest.rs)

Engine-agnostic commands; Servo bits only: JSValue matches (lines 166, 434, 452, 495), InputEvent::Keyboard for pagetype (558), fakeload sets servo::LoadStatus (669, 673). Port with the glue's JS-result and load-state types.

3.12 Other Servo references

  • resources.rs + assets/servo/* (gatt_blocklist, public_domains, hsts_preload, badcert, neterror, crash, directory-listing, about-memory, debugger.js, json-viewer, rippy.png): Servo's resource reader → remove; error pages become Nacre's own (load-failed → load_alternate_html), port neterror.html/badcert.html look.
  • tabs.rs: Web { webview, context }, Prompt/Dialog variants holding Servo request objects, ConsoleLine.level, Tab.cursor, load_status: Option<LoadStatus> → glue types.
  • ui/chrome.rs load_estimate (Servo stages) → real progress.
  • ui/menus.rs PageMenu (servo::ContextMenu, MenuAction::Servo), ui/dialogs.rs (SimpleDialog, SelectElement, device_rect), ui/mod.rs ime_control.
  • store/permissions.rs unavailable() reasons ("Servo 0.7 …") → recompute for WebKit (location, camera, mic, storage, per-site JavaScript are all possible in WebKit).
  • User-visible text: ui/pages/settings.rs (freeze tabs "Servo can't pause", Widevine row, About "built on the Servo engine", "Engine Servo 0.7.0 …"), ui/pages/misc.rs (clear data "Servo keeps no dates", about, licence "Servo and Nacre", task manager "Servo runs every page in Nacre's own process").
  • paths.rs APP_DIR = "nacre-servo": profile folder name; decide on a migration (D-needed) before renaming.
  • keys.rs to_servo name and header.

4. Docs

Doc / section Fate
DESIGN.md "Servo 0.7 embedding cheat sheet" replace with a WebKit API cheat sheet
DESIGN.md "Engine limits" rewrite: most Servo limits go (DRM later, printing, PiP state, SVG currentColor, mask-image, fingerprint gaps); keep the "shown as unavailable" rule
DESIGN.md "Vendored servo-net patches", "Vendored servo-script patches" (incl. the third-party rule text) remove; the third-party rule moves to WebKit's cookie policy note
DESIGN.md "Media and Media Source Extensions (S022-S028)" remove; one line: MSE/EME native in WebKit
DESIGN.md "Cookies at rest (S025)", "Privacy mode (S024)" rewrite for WebKit storage and switches
DESIGN.md "Layout", "How the pieces fit" update hub.rs/window.rs descriptions
REVIEW.md items on load_web_resource lock, intercepted responses skip redirects, global UA quirk, servo-net S023 note: remove with the glue; discord/rfd/autofill items stay
FEATURES.md every "verified Sxxx" state was on Servo: reset to "to re-verify on WebKit" when the glue lands; rows citing Servo limits ("stop has no Servo API", assets/servo/*.html, "no printing in Servo", "Servo can't pause scripts", "vendored servo-net") need new states
docs/S027-handoff.md Servo MSE handoff, obsolete → remove with the vendored crates
docs/engine/mse-spike.md Servo MSE spike background → remove with the vendored crates
docs/engine/gst-mse-patches.md keep (upstream write-up for GStreamer)
docs/engine/privacy-mode.md rewrite the Servo surfaces part after re-measuring on WebKit
docs/engine/engine-comparison*, docs/engine/tune/, runs/ keep (decision record)
docs/review/phase*.md, PROGRESS.md, DECISIONS.md history, keep
CLAUDE.md §2 Servo facts, §4 pitfalls (clang, lock versions, Servo 0.7 can't…, several painters), §5 rows below rewrite with the glue plan

5. Tests and tools

Kept and ported (engine-agnostic): tools/smoke.sh, tools/check-shots.py, tools/icons.py, tools/refshot.py (Chromium reference shots), tools/engine-test/ (comparison record; servo_script.py and the servo arm of run.sh become dead once Servo is gone — the engine-test session owns that folder), src/selftest.rs commands, every tests/smoke/pages/*.html/.js, tests/smoke/net/, tests/smoke/cache/, tests/smoke/data/, and the smoke scripts not listed below (launch, restore, chrome, colours, input, basics, keys, dialogs, gallery, newtab*, backgrounds, settings*, sliders*, pages-ui, stores-, integ-, net-, cache, cookies*, privacy-, coveryourtracks, site-memory, site-doctor, heavy-web, https).

Servo-only, remove with the glue (they test code that stays in today's build, so they stay until then):

Item Why Servo-only
tools/gst-mse.sh, tests/gst-mse/ (C tests + data) build/test the patched gst_mse that build.rs loads for Servo's MSE
tests/smoke/mse-off.txt NACRE_DOM_MEDIA_SOURCE_ENABLED is a Servo pref override
tests/smoke/mse-leak-check.sh reads vendored servo-script's "MSE: MediaSource … created/freed" log lines
tests/smoke/mse.txt, mse-player.txt, youtube-mse.txt port: the pages (mse-basic.html, mse-spec.html, mse-player.html) are plain MSE tests and stay useful on WebKit; drop the leak case/log checks
tests/smoke/painters.txt, painters-perf.txt Servo's one-painter-per-tab GL question (S005, D-008); port the idea (N tabs paint the right page) to the WebKit surface
tests/smoke/crash-adblock.txt R5-01 Servo timer GC crash regression; keep the page as a blocking stress test if cheap
tests/smoke/privacy-net.txt header comment cites vendored servo-net; the checks (headers, third-party cookies, Accept-Language) are what the WebKit port must pass: keep, update the comment

Removed now (§6): tools/wpt-mse.sh, tests/wpt-mse/ (driver, server, testharnessreport).

6. Removed in servo-cleanup (2026-11-12)

  • tools/wpt-mse.sh and tests/wpt-mse/: WPT media-source conformance of Nacre's own Servo MSE (S027, 239/407). Nothing in the build or another test uses them; WebKit's MSE is tested upstream. Last result stays in PROGRESS.md.
  • CLAUDE.md §5 row for tools/wpt-mse.sh; the mention in DESIGN.md "Media and Media Source Extensions".

7. Suggested removal order (for the 08 plan)

  1. Move pure logic out of Servo files (hub.rs privacy_headers, strip_tracking, HubConfig, adblock decision; language list from net::nacre) with their unit tests, so it survives.
  2. Glue lands behind the same hub::Event surface; tabs.rs/window.rs types swapped.
  3. Delete servo, servo-net, content-security-policy, the media feature, [patch.crates-io], vendor/servo-*, vendor/epaint, vendor/gst-mse, build.rs rpath, resources.rs, assets/servo/, gilrs if unused.
  4. Delete the §5 Servo-only tests/tools, rewrite DESIGN/REVIEW/FEATURES/CLAUDE.md sections (§4), user-visible text (§3.12).
  5. cargo build + the kept smoke scripts on WebKit.