Verify device autosave behavior across frontend revisions

This commit is contained in:
Jonathan Sykes
2026-10-09 09:16:58 +08:00
parent 21c12733d3
commit b59fc7264a
12 changed files with 1249 additions and 0 deletions

View File

@@ -335,3 +335,71 @@ No product behavior changes are involved in these measurement corrections.
Keep browser/build/test processes idle during full timing measurements. WebKit's
zero long-task field means unavailable, not zero work. Autoplay-blocked/media-ready
null results do not establish playback performance or iPhone audio continuity.
## Device autosave investigation (2026-10-09)
`autosave.mjs` starts an isolated real Bun server inside this worktree, seeds its
media-cache DB with a three-second H.264/AAC clip, and uses 414×896 Playwright
contexts with the Framework7 Swipe layout. It checks OPFS bytes, `cachedIds`,
Saved and Downloads views, and both Settings handlers. Public network requests
are blocked. No production access or YouTube download is needed.
```bash
bash perf/make-shell-fixture.sh b77938a 1175f1a1d2c1
node perf/autosave.mjs --frontend perf/fixtures/shell-1175f1a1d2c1 \
--asset-hashing 0 --asset-sync 0 --allow-unsupported-webkit \
--out perf/results/autosave-b77938a.json
node perf/autosave.mjs --frontend-commit main --allow-unsupported-webkit \
--out perf/results/autosave-main.json
node perf/autosave.mjs --browser chromium --out perf/results/autosave-current.json
node --test frontend/autosave.test.js
```
Options: `--frontend <directory>` or `--frontend-commit <revision>`;
`--browser chromium|webkit|all`; `--scenarios <comma-separated names>`;
`--asset-hashing 0|1`, `--asset-sync 0|1`; `--out <json>`.
A failed assertion exits 1. Missing native OPFS exits 2 unless explicitly
allowed with `--allow-unsupported-webkit`. On this Linux Playwright WebKit build,
`navigator.storage` is absent, including in persistent contexts; enabling its
MiniBrowser storage feature flags also did not expose it. WebKit therefore
checks real UI/settings/save guards and records `supported:false`; those results
**do not establish a successful WebKit OPFS save**. No storage shim is installed.
Run without the allowance on a Safari-capable environment to require native OPFS.
Observed contracts in both b77938a and current code:
| Action | Device save |
| --- | --- |
| Open a video with default settings | No |
| Open with `saveBeforePlay:true`, video mode | Yes |
| Open audio-only, or `preferStream:true` | No |
| Create/add to a playlist, even with `autoPreload:false` | Yes |
| Launch with playlist videos and `autoPreload:true` | Yes |
| Launch with `autoPreload:false`, unpinned playlist | No |
| Launch with a pinned playlist, even with auto-preload off | Yes |
| Enable either save setting through Settings | Saves as above; persisted |
Chromium: all 12 cases pass for old/current builds and Phase 1/2 tips.
Phase 3/4/5 tips and both rollback flags pass the six positive cases
(`open-save-first,playlist-add,playlist-boot,pinned-boot,settings-enable,settings-save-first`).
JSON evidence is in `perf/results/autosave-*.json`. No old=saves/new=doesn't
transition was found, so there is no defensible breaking commit or product fix.
The unit tests cover playlist/pinning policy, duplicate saves, and failed or
paused saves remaining retryable without being marked Saved.
Neighbour audit: Downloads, Saved, OPFS, download controls and error helpers
remain eager core assets. Export awaits `feature:export`; Share/External await
`feature:share-external`; worker creation is synchronous and receives build-local
hash/resume URLs. DirectMedia's unloaded `hasSource()` facade returns false, so
an early paired-source lookup can choose the server instead; this does not
prevent the server save. P2P settings counts queried before its delayed lazy
startup can initially show no registration. These remain follow-up candidates,
not demonstrated causes of missing OPFS saves. The scout's proposed Data Saver
cause was rejected: its guards affect static warming and stream pre-resolution,
not `preload()` or `saveBeforePlay`.
Still required on the owner's installed iPhone PWA: record the running build,
check Save before playing / Audio-only / Auto-save settings, open a fresh video,
add it to a playlist, and inspect Downloads failure details and Saved after a
relaunch/offline playback. Verify available storage and whether iOS evicted
previous copies. A failing iPhone sequence is needed to continue the bisect.