From 30ca054593da5117ed3d07e82a6b9459c4fe4c07 Mon Sep 17 00:00:00 2001 From: astar76 Date: Sat, 14 Nov 2026 12:52:03 -0600 Subject: [PATCH] S052: slow-connection pass, background tab check, Nacre memory on the tune sites, D-040 amended Co-Authored-By: Claude Sonnet 5.5 --- CLAUDE.md | 1 + .../08 WebKit engine/S052-tuning-defaults.md | 8 +- Plans/INDEX.md | 2 +- docs/DECISIONS.md | 2 +- docs/PROGRESS.md | 8 + docs/engine/engine-comparison.md | 24 +++ docs/engine/tune/nacre/default/samples.csv | 152 +++++++++++++++++ docs/engine/tune/nacre/pagecache/samples.csv | 153 +++++++++++++++++ docs/engine/tune/nacre/slow-default/back.json | 1 + .../engine/tune/nacre/slow-default/first.json | 1 + docs/engine/tune/nacre/slow-default/log.json | 1 + .../tune/nacre/slow-default/reload.json | 1 + .../tune/nacre/slow-default/revisit.json | 1 + .../tune/nacre/slow-pagecache/back.json | 1 + .../tune/nacre/slow-pagecache/first.json | 1 + .../engine/tune/nacre/slow-pagecache/log.json | 1 + .../tune/nacre/slow-pagecache/reload.json | 1 + .../tune/nacre/slow-pagecache/revisit.json | 1 + docs/engine/tune/nacre/slow-viewer/back.json | 1 + docs/engine/tune/nacre/slow-viewer/first.json | 1 + docs/engine/tune/nacre/slow-viewer/log.json | 1 + .../engine/tune/nacre/slow-viewer/reload.json | 1 + .../tune/nacre/slow-viewer/revisit.json | 1 + docs/engine/tune/nacre/viewer/samples.csv | 154 ++++++++++++++++++ src/app.rs | 4 +- src/ui/pages/settings.rs | 2 +- tests/smoke/bg-tabs.txt | 17 ++ tests/smoke/pages/bg.html | 11 ++ tests/smoke/slow.txt | 41 +++++ tests/smoke/slow/server.py | 84 ++++++++++ tests/smoke/tune-mem.txt | 24 +++ tools/mem-run.sh | 20 +++ 32 files changed, 713 insertions(+), 9 deletions(-) create mode 100644 docs/engine/tune/nacre/default/samples.csv create mode 100644 docs/engine/tune/nacre/pagecache/samples.csv create mode 100644 docs/engine/tune/nacre/slow-default/back.json create mode 100644 docs/engine/tune/nacre/slow-default/first.json create mode 100644 docs/engine/tune/nacre/slow-default/log.json create mode 100644 docs/engine/tune/nacre/slow-default/reload.json create mode 100644 docs/engine/tune/nacre/slow-default/revisit.json create mode 100644 docs/engine/tune/nacre/slow-pagecache/back.json create mode 100644 docs/engine/tune/nacre/slow-pagecache/first.json create mode 100644 docs/engine/tune/nacre/slow-pagecache/log.json create mode 100644 docs/engine/tune/nacre/slow-pagecache/reload.json create mode 100644 docs/engine/tune/nacre/slow-pagecache/revisit.json create mode 100644 docs/engine/tune/nacre/slow-viewer/back.json create mode 100644 docs/engine/tune/nacre/slow-viewer/first.json create mode 100644 docs/engine/tune/nacre/slow-viewer/log.json create mode 100644 docs/engine/tune/nacre/slow-viewer/reload.json create mode 100644 docs/engine/tune/nacre/slow-viewer/revisit.json create mode 100644 docs/engine/tune/nacre/viewer/samples.csv create mode 100644 tests/smoke/bg-tabs.txt create mode 100644 tests/smoke/pages/bg.html create mode 100644 tests/smoke/slow.txt create mode 100644 tests/smoke/slow/server.py create mode 100644 tests/smoke/tune-mem.txt create mode 100755 tools/mem-run.sh diff --git a/CLAUDE.md b/CLAUDE.md index 1c1847d..d529a94 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -74,6 +74,7 @@ Never modify: `~/Documents/Apps/Nacre` (the original Python Nacre, reference onl | `SMOKE_TIMEOUT=400 tools/smoke.sh tests/smoke/mse.txt`, `…/mse-player.txt` | plain MSE tests on WebKit: chunk-appended fMP4, WebM and split A/V play; `mse-spec.html` spec cases (attach/detach, duration, buffered/seekable, remove, removeSourceBuffer, changeType, abort, reopen, sequence); player integration (attach, seeks, rate, ended, decode error, garbage append; `?only=` in the page URL for one case). Offline, start `python3 -m http.server 8765 --bind 127.0.0.1 --directory tests/smoke/pages &` first (MSE needs an http origin). `youtube-mse.txt` is an internet probe | S022, S027, S028, S053 | | `tools/smoke.sh tests/smoke/privacy-mode.txt` (+ `SMOKE_ARGS=--incognito … privacy-incognito.txt`) | privacy mode: `pages/fingerprint.html` read off/on, `fp-off.json`/`fp-on.json` + shots (offline); `privacy-net.txt` (needs `tests/smoke/net/server.py`) frame cookies, per-site pause, Accept-Language; `SMOKE_TIMEOUT=700 … coveryourtracks.txt` EFF's test off/on (internet, direct). Selftest `save ` writes a JS string result to `.json`; `SMOKE_ARGS` passes browser arguments | now (S024) | | `python tools/icons.py` | rebuilds the icon font subset and `src/ui/icons.rs` from `tools/icons.txt` (needs fontTools and Arch's ttf-material-symbols-variable) | now (S015) | +| `tools/mem-run.sh [ENV=v…]` + `tools/smoke.sh tests/smoke/slow.txt` (+ `python3 tests/smoke/slow/server.py &`), `bg-tabs.txt` | Nacre's PSS/CPU on the tune sites (hidden, internet; `NACRE_WK_PAGE_CACHE=1`, `NACRE_WK_CACHE_MODEL=viewer` as variants); slow-line visit/revisit/reload/back with a paced local server (offline, `first/revisit/reload/back.json`, `log.json`); hidden tab gets no frames and slow timers | now (S052) | | `tools/engine-test/run.sh chromium\|webkit` + `analyze.py` | engine comparison: one browser visible on DP-1, throwaway profile, sites from `sites.txt`, per-second RAM (PSS), CPU, GPU of the whole process tree into `docs/engine/runs//samples.csv`; `webkit_shell.py` is the WebKitGTK 6.0 shell (needs `webkitgtk-6.0`); report `docs/engine/engine-comparison.md`. Never run two at once or alongside cargo | now | | `python3 tests/smoke/net/server.py &` + `tools/smoke.sh tests/smoke/site-data.txt`; `tools/smoke.sh tests/smoke/media-audio.txt` | site info cookie/data count, Clear data time range (stored data kept, cookies always whole); WebKit `is-playing-audio` → tab audible, tab mute via `set_is_muted` (`pages/sound.html`, `?element` plays `tone.ogg` with Media Session metadata; WebKit's MPRIS player shows on the run's bus: `busctl --address=unix:path=$(cat /session/runtime)/bus list`). Offline, hidden | now (S051) | | `tools/smoke.sh tests/smoke/pip.txt` (+ `tools/hidden.sh tests/smoke/pip.txt -- tests/smoke/pip-driver.sh`: `/windows.json` PiP floating), `bindings.txt` (side buttons, middle click; hidden only), `ctxmenu.txt` (site menu vs Nacre's; hidden only), `pip-return.txt` (page input after PiP and back; hidden only), selftest `pick x y` (GTK's pick at a page point + view state), `python3 tests/smoke/net/server.py &` + `SMOKE_SIZE=1280x900 tools/smoke.sh tests/smoke/auth.txt`, `tests/smoke/visible-ui.txt` (by hand, header) | PiP moves the live view and back (offline); HTTP sign-in cancel + saved login (offline); visible: portal file chooser, notification, page full screen, Web Inspector (`dialogs.txt` now also checks dialog answers, context menu, leave page, permission bars, notifications count) | now (S048, S056) | diff --git a/Plans/08 WebKit engine/S052-tuning-defaults.md b/Plans/08 WebKit engine/S052-tuning-defaults.md index 37b4515..a337b29 100644 --- a/Plans/08 WebKit engine/S052-tuning-defaults.md +++ b/Plans/08 WebKit engine/S052-tuning-defaults.md @@ -12,10 +12,10 @@ hidden views — the old "limited" setting row comes back); RAM of Nacre measure ## Steps - [x] Defaults: page cache off, memory pressure 500 MB, cache model DocumentViewer, HW policy default; `NACRE_WK_*` overrides; log the effective values at start. -- [ ] Background tabs: hidden views frozen/suspended after the setting's delay (check the WebKitGTK 2.54 API: `WebView` visibility already throttles; web process suspension if available); settings texts updated. -- [ ] Measure: Nacre hidden with the tune site list (`tools/engine-test/tune-sites.txt`, 10 tabs, idle phase) with `sample.py`; compare to the tune "mem500/no-page-cache" rows; write the row and the comparison (software GL caveat for VRAM). -- [ ] Slow-connection pass (user, 2026-11-13: "everything is slow with my internet … someone with my internet should be able to use the browser smoothly"; reloads and revisits felt uncached): with a throttled local server (e.g. `tc netem` on a veth/loopback test namespace or a server that paces bytes; never a proxy), measure first visit, revisit, reload and back/forward for the default cache model and page cache on/off; make sure revisits come from the HTTP disk cache (S050 moved the default to DocumentBrowser), DNS prefetch and preconnect are on, and back/forward doesn't refetch if the RAM cost of the page cache is acceptable (record the trade-off and pick; amend D-040). Times in PROGRESS. -- [ ] PROGRESS entry, INDEX line, tracker, commit `S052: …`, push. +- [x] Background tabs: hidden views frozen/suspended after the setting's delay (check the WebKitGTK 2.54 API: `WebView` visibility already throttles; web process suspension if available); settings texts updated. +- [x] Measure: Nacre hidden with the tune site list (`tools/engine-test/tune-sites.txt`, 10 tabs, idle phase) with `sample.py`; compare to the tune "mem500/no-page-cache" rows; write the row and the comparison (software GL caveat for VRAM). +- [x] Slow-connection pass (user, 2026-11-13: "everything is slow with my internet … someone with my internet should be able to use the browser smoothly"; reloads and revisits felt uncached): with a throttled local server (e.g. `tc netem` on a veth/loopback test namespace or a server that paces bytes; never a proxy), measure first visit, revisit, reload and back/forward for the default cache model and page cache on/off; make sure revisits come from the HTTP disk cache (S050 moved the default to DocumentBrowser), DNS prefetch and preconnect are on, and back/forward doesn't refetch if the RAM cost of the page cache is acceptable (record the trade-off and pick; amend D-040). Times in PROGRESS. +- [x] PROGRESS entry, INDEX line, tracker, commit `S052: …`, push. ## End criteria - Start log shows the four values; the measurement row is in the doc; `launch.txt`/`basics.txt` still green. diff --git a/Plans/INDEX.md b/Plans/INDEX.md index 42cd399..2c5ce88 100644 --- a/Plans/INDEX.md +++ b/Plans/INDEX.md @@ -12,7 +12,7 @@ Dropped with Servo (D-032): S011, S029, S030, S032, S033, S037, S038. - [x] [S057 — Small UI bugs: Customize panel scroll, site colour from the favicon, colour picker glyphs, beforeunload on quit](08%20WebKit%20engine/S057-small-ui-bugs.md) · Sonnet high - [x] [S058 — Ads vanish before your eyes: Pie-style cookie shield removal animation (port of the original)](08%20WebKit%20engine/S058-ad-removal-animation.md) · Opus medium - [x] [S051 — Profile folder, sealed cookies, site data, incognito, media source](08%20WebKit%20engine/S051-profile-cookies-media.md) · Opus medium -- [ ] [S052 — WebKit tuning defaults, background tabs, memory check](08%20WebKit%20engine/S052-tuning-defaults.md) · Sonnet high +- [x] [S052 — WebKit tuning defaults, background tabs, memory check](08%20WebKit%20engine/S052-tuning-defaults.md) · Sonnet high - [ ] [S054 — Site pass on WebKit vs Chromium reference](08%20WebKit%20engine/S054-site-pass.md) · Opus high ## 02 Verify / 03 Gaps (after 08; reviews need the user) diff --git a/docs/DECISIONS.md b/docs/DECISIONS.md index ca759e3..e63a78b 100644 --- a/docs/DECISIONS.md +++ b/docs/DECISIONS.md @@ -43,7 +43,7 @@ - D-037 — 2026-11-13 — Cookies at rest on WebKit (keeps D-019's rule "never plain on disk"): WebKit's SQLite cookie store lives in the per-run `$XDG_RUNTIME_DIR` (tmpfs, 0700) via `CookieManager::set_persistent_storage`; Nacre fills it from the sealed `cookies.bin` at start and seals it back (D-019 key, XChaCha20-Poly1305) at quit and every 60 s after a cookie change. No keyring → cookies for the run only, as before. Servo-era `cookies.bin` is converted when it parses, else moved aside. — keeps encryption without patching WebKit; tmpfs never touches the disk — S051 - D-038 — 2026-11-13 — Profile folder `nacre-servo` → `nacre-browser` (config, data, cache): on first start, if `nacre-browser` is missing and `nacre-servo` exists, it is renamed (one move, logged); Servo-only engine files inside are deleted after the move. `~/.config/nacre` belongs to the Python Nacre and is never touched (the importer reads it). — engine name out of the path; `nacre` is taken by the original — S051 - D-039 — 2026-11-13 — Media on WebKit: Nacre's page-script media probe (`inject.rs` `media.*`, mediaSession hook) stays the one source for the new tab card, Discord and MPRIS; WebKit's `is-playing-audio` and `set_is_muted` replace the mute script. If WebKitGTK publishes its own MPRIS player it is not left as a second player (turned off or Nacre's skipped, whichever the plan finds possible; one player only). — one engine-neutral source already feeds three features — S051, S013 -- D-040 — 2026-11-13 — WebKit tuning defaults (D-032 data, `docs/engine/tune/`): page cache off, memory pressure limit 500 MB per web process, cache model `DocumentBrowser` (amended in S050: `DocumentViewer` has no HTTP disk cache; hidden 4-tab check, nacre tree PSS median: viewer 1147 MB, browser 1128 MB; env `viewer` for the old one), hardware acceleration policy default (on demand; `never` broke JS checks), related views only for pop-ups. Env overrides for tests (`NACRE_WK_PAGE_CACHE`, `NACRE_WK_MEM_LIMIT`, `NACRE_WK_CACHE_MODEL`, `NACRE_WK_HW`). — lowest PSS/VRAM in the tune runs without failed sites — S052 +- D-040 — 2026-11-13 — WebKit tuning defaults (D-032 data, `docs/engine/tune/`): page cache off, memory pressure limit 500 MB per web process, cache model `DocumentBrowser` (amended in S050: `DocumentViewer` has no HTTP disk cache; hidden 4-tab check, nacre tree PSS median: viewer 1147 MB, browser 1128 MB; env `viewer` for the old one), hardware acceleration policy default (on demand; `never` broke JS checks), related views only for pop-ups. Env overrides for tests (`NACRE_WK_PAGE_CACHE`, `NACRE_WK_MEM_LIMIT`, `NACRE_WK_CACHE_MODEL`, `NACRE_WK_HW`); the effective values are printed at start (`engine tuning: …`). S052 slow-connection pass (paced local server, ~1 Mbit/s, 250 ms per request, `tests/smoke/slow.txt`): with DocumentBrowser a revisit, reload and back come from the disk cache (first visit 4.3 s; revisit costs the conditional request for the page plus resources without validators; back 38 ms with the page cache off), with DocumentViewer every visit refetches everything (5.7 s, twice the images too). The page cache adds nothing worth its RAM here (back is already near-instant), so it stays off; DNS prefetching is on. — lowest PSS/VRAM in the tune runs without failed sites — S052 - D-041 — 2026-11-13 — S044 boxes 3–5 (Nacre `ViewId`, engine-neutral `Event` payload types, selftest on them) move to S045 and are defined directly on WebKit; S044 closes with the privacy/policy move. — converting 56 Servo payload uses and 14 `WebViewId` sites now would only add Servo adapters that S045/S048 delete — orchestrator, 2026-11-13 — S044, S045 - D-042 — 2026-11-13 — S045 GTK host: the WebKit build ports page controls instead of stubbing them (script dialogs, `