Repository navigation
cargo: Enable GStreamer by default on desktop platforms - #48934
Conversation
|
🔨 Triggering try run (#38770749166) for OpenHarmony |
|
| Project | Servo |
| Branch | 48934/PR |
| Testbed | HUAWEI Mate 80 Pro |
⚠️ WARNING: Truncated view!The full continuous benchmarking report exceeds the maximum length allowed on this platform.
🐰 View full continuous benchmarking report in Bencher
⚠️ WARNING: No Threshold found!Without a Threshold, no Alerts will ever be generated.
|
✨ Try run (#38770749166) succeeded. |
| default_without_allocator = ["default_without_media", "media-gstreamer"] | ||
| # default features, without GStreamer media support. | ||
| default_without_media = ["bundled", "default_web_features", "default_tooling", "max_log_level", "multiprocess", "js_jit"] |
There was a problem hiding this comment.
what about having just one default_without_media_and_allocator and then creating alias jemalloc = ["servo-allocator/use-jemalloc"]
There was a problem hiding this comment.
Good idea. I've renamed this to be default_base and it now does not include jemalloc or media-gstreamer. The feature is now additive, which allows cleaning up some of the Python.
5aea009 to
73433ac
Compare
73433ac to
2ea838c
Compare
This change enables GStreamer by default on all platforms other than Android and OHOS in an effort to try to make `./mach build` do the same thing as `cargo build`. There is more work to do here, but this is an important step. Signed-off-by: Martin Robinson <[email protected]>
2ea838c to
2b8757c
Compare
|
It seems this change has the side-effect of turning GStreamer on for unit tests. This should be good as it will eliminate one difference between |
…ndexeddb
Add an OpenHarmony RDB backend behind the `ohos-rdb-backend` feature: OHOS
builds can use the system database through ohos-rdb-sys C FFI instead of the
bundled sqlite3. The sqlite modules keep their upstream logic; the RDB
implementation lives in new files with its own copy of the schema and CRUD, a
deliberate duplication that keeps rebases trivial, wired in through a small set
of cfg hooks. The FFI wrappers free their native handles on drop. A cursor
borrows its transaction, so the compiler rejects reads after commit. Strings
with interior NUL bytes are stored as blobs and read back unchanged.
Backend selection is a feature choice rather than a target choice, so a plain
`./mach build --ohos` keeps the upstream SQLite behaviour and no configuration
fails to compile:
./mach build --ohos # SQLite, as before
./mach build --ohos --features ohos-rdb-backend
# both, chosen at runtime
./mach build --ohos --no-default-features \
--features "base,ohos-rdb-backend"
# RDB only
Dropping sqlite is what makes the third configuration worth having: when
first measured (base 79e2c7a) the stripped aarch64 release
`libservoshell.so` went from 127,736,736 to 125,736,080 bytes, 1.91 MiB
less. Since the 2026-08-29 sync this no longer holds: upstream fb04f8f
(servo#43819, on-disk HTTP cache) makes rusqlite an unconditional dependency of
components/net, so the RDB-only configuration still links sqlite. The saving
needs remeasuring, and the configuration is only worth keeping if servo#43819's
sqlite use becomes optional.
With both backends compiled in, `storage_ohos_rdb_backend_enabled` (default
true) picks one per store as it is opened, so a single binary can A/B them
without reinstalling. The two backends keep disjoint on-disk stores — sqlite
files versus RDB's nested `rdb/<store>` — so flipping the pref switches to the
other backend's data, which starts out empty. That is intended for A/B
comparison; there is no migration between them.
Deliberate difference from the SQLite twin: RDB delivers the callbacks of a
batch after its commit, so the whole batch lands or errors together (SQLite
reports each operation in autocommit). Schema operations join that batch
transaction and follow the same rule. A second deliberate difference: after a
failed webstorage load on OHOS the session's final save is skipped, so a
partially loaded state cannot overwrite the store.
On a HarmonyOS phone the two legs of the pref agree exactly. One signed HAP,
`storage_ohos_rdb_backend_enabled` flipped between runs, over the ten WPT
storage tests the backend touches: 1188 subtests pass and 37 fail on each
side, test for test, and the failures are the ones tests/wpt/meta already
expects. The stores confirm the switch rather than assuming it — with the pref
on the app writes only `rdb/reg.rdb` and `rdb/webstorage.rdb`, with it off only
`reg.sqlite` and `webstorage.sqlite`.
One RDB limitation is worth recording. Opening a second client_storage registry
fails (14800001 / 14800011) about two runs in three, on DAYU200 and PLR-AL00
alike, when the process is not an application: `new_storage_threads` with no
`config_dir` falls back to `tempfile::tempdir()`, which outside an application
sandbox is `/data/local/tmp`. Neither half alone is enough — a single registry
under `/data/local/tmp` is reliable, and so are two registries inside the
application, which a phone confirmed over ten launches of the default
configuration and five of `--temporary-storage`, the latter being the same
two-registry shape that fails in a bare process. Servo always passes the
application's cache dir, so it never meets the condition;
`test_new_storage_threads_create_independent_groups`, which does, is ignored
when the RDB backend is compiled in.
The RDB copies of the IndexedDB and client-storage schemas are checked
against the SQLite ones by `tests/schema_parity.rs`, a host test that builds
both in an in-memory SQLite database and compares tables, columns, keys,
foreign keys and indexes, so an upstream schema change that is not mirrored
fails on the host instead of diverging on devices. The webstorage `data`
tables differ on purpose and are not compared.
Validation: Parallel twin of the sqlite backend — revalidate on every rebase even when it merges cleanly, since upstream storage changes never conflict with the RDB engine files. (1) `./mach check --ohos -- -p servo-storage --all-targets --features ohos-rdb-backend` must pass warning-free, as must the plain and the `--no-default-features --features ohos-rdb-backend` configurations; a new `AsyncOperation`/engine-trait variant fails here loudly and must be implemented in the RDB twins, not wildcarded. (2) Diff upstream changes since the previous base with `git log -p <old-base>..<new-base> -- components/storage` and mirror any sqlite-engine semantics changes into `engines/ohos_rdb.rs` / `webstorage/engines/ohos_rdb.rs` / `client_storage_ohos_rdb.rs`. (3) Host `./mach test-unit -p servo-storage` pins the sqlite reference behaviour. (4) On a device, run the same suite against both backends with `CARGO_TARGET_AARCH64_UNKNOWN_LINUX_OHOS_RUNNER=ohos-test-runner cargo nextest run -p servo-storage --target aarch64-unknown-linux-ohos [--no-default-features --features ohos-rdb-backend]` (raise nextest's slow-timeout: every test is pushed to the device), then the same-HAP A/B: build servoshell with `--features ohos-rdb-backend` (flavor and signing per the device: `harmonyos`/`hos` for a phone whose UDID is in the profile, default/OpenHarmony for the DAYU200), install it, and run `./mach test-wpt --ohos --release --no-headless --ohos-device <serial> --pref dom_indexeddb_enabled=true --pref storage_ohos_rdb_backend_enabled=<bool> --log-wptreport <leg>.json <subset>` (the `servo_ohos` wptrunner product of the `wpt-ohos` runner branch, cherry-picked onto the stack) once per pref value with `bm clean -n org.servo.servo -d` before each leg. Subset = all of `webstorage/` plus `IndexedDB/{idbobjectstore_put,idbobjectstore_get,idbobjectstore_delete,idbobjectstore_createIndex,idbindex_get,idbcursor_continue_objectstore,keypath,key_valid,transaction-abort-generator-revert,upgrade-transaction-lifecycle-committed,idbfactory_open,idbfactory_deleteDatabase}.any.{html,worker.html}` (78 tests). Compare the two wptreports subtest by subtest: no subtest may differ (crash/timeout-truncated tests are re-run in isolation on both legs), and the app data dir must contain only `*.rdb` stores after the true leg and only `*.sqlite` after the false leg (a lone `reg.rdb` from the runner's pref-less first launch and the HTTP cache's `cache.sqlite3` are expected). (5) Host `cargo nextest run -p servo-storage schema_parity` must pass; it fails when an upstream schema change is not mirrored into `indexeddb/engines/shared.rs` or `client_storage_shared.rs`. `./mach clippy --locked -- -- --deny warnings` must pass.
AI-assisted: Yes (agent session; implementation and on-device testing)
AI-assisted: Yes (agent session; 2026-08-29 rebase conflict resolution -- components/servo/Cargo.toml and components/storage/Cargo.toml resolved to the upstream side with only the fork's `ohos-rdb-backend` feature and optional-dependency markers re-added: upstream's `no-wgl = ["dep:mozangle", ...]` (servo#47198) is kept and `ohos-rdb-backend = ["storage/ohos-rdb-backend"]` re-added after it, and servo#43819 moved rusqlite's `bundled` feature onto the workspace dependency, so components/storage now carries only `rusqlite = { workspace = true, optional = true }`. Validation step (2): of the three upstream commits touching components/storage, only 7bea9ed (`ImmutableOrigin::ascii_serialization` now returns `Cow<'_, str>`) reaches the RDB twins, and it is a type change with no behaviour change; mirrored into `client_storage_shared.rs`, whose `create_a_storage_shelf` now hands the `Cow` to `push_text` by deref instead of the gone `as_str()`; `indexeddb/engines/shared.rs` already coerced, and no other twin site serializes an origin. fb04f8f touches only the Cargo.toml line above and 39f05ac only sqlite-side destructuring, so no semantics were mirrored into `engines/ohos_rdb.rs`, `webstorage/engines/ohos_rdb.rs` or `client_storage_ohos_rdb.rs`. Note: fb04f8f gave components/net an unconditional rusqlite dependency, so the 1.91 MiB saving quoted above for the RDB-only configuration no longer holds and needs remeasuring)
AI-assisted: Yes (agent session; 2026-10-08 sync -- conflict resolution in Cargo.toml, components/servo/Cargo.toml and components/storage/Cargo.toml: upstream's 0.7.0 versions with the fork's `default-features = false` re-added, upstream's new `multiprocess` default kept in servo's `default` and servoshell's `base` group, the fork's `[lints.rust]` table dropped for upstream's `[lints] workspace = true`; mirrored servo#47936 (index names unique per object store) into the RDB schema copy, adapted the tests to servo#48037's `GenericCallback::new`, added tests/schema_parity.rs and Validation step (5), updated step (4) for the current WPT runner, folded the clippy `duplicate_mod` squash commit; Cargo.lock regenerated from upstream's so that `cargo metadata --locked` passes at this commit)
AI-assisted: Yes (agent session; 2026-10-13 sync -- upstream servo#47255 added the default_tooling feature group: kept it in servo's default set and servoshell's base group next to the storage backend features)
AI-assisted: Yes (agent session; 2026-10-22 sync -- upstream servo#48934 and servo#49065 renamed servoshell's `default_without_allocator` group to `default_base` (which mach selects with `--no-default-features` for dummy-media builds) and moved jemalloc into it: `default_base` = `base` + `sqlite-backend`, and `base` takes upstream's list including `jemalloc`, so the RDB-only command above no longer names the allocator; servo's `default` merged next to upstream's blank line)
Signed-off-by: Jonathan Schwender <[email protected]>
With the js-quickjs feature, Servo runs on servo-quickjs (https://github.com/openharmony-rs/servo-quickjs), which implements the mozjs API on QuickJS. The feature builds only with mozjs patched to the shim, e.g. in .cargo/config.toml: [patch.crates-io] mozjs = { git = "https://github.com/openharmony-rs/servo-quickjs", rev = "..." } QuickJS frees objects by reference counting and collects cycles, so under js-quickjs: - Dom<T> and DomRoot<T> hold a reference count on their target, also when the target's reflector is set later (a DissimilarOriginWindow's WindowProxy), and roots go through no root list; - the reflector of a DOM object holds none on its own object, and is neither traced nor released by the Heap drop barrier; the reflector of a TracedPromise holds a counted, traced one; - finalizers drop the Dom<T> fields of an object while the collector knows which objects it frees, so WindowProxy finalizes through finalize_common; - live Trusted references are counted until swept, and the shim's autorelease pool is drained between tasks, on the script thread and on worker threads; - reflectors are initialized before they are rooted, DOM objects are left alone once the runtime is destroyed, and the Debugger API is left out. Under SpiderMonkey, WindowProxy's finalizer does what it did before, and MutDom and MutNullableDom no longer copy Dom<T> bitwise, which is equivalent. Fork note: experimental, to evaluate QuickJS as the engine of a smaller profile (servo-quickjs docs/design.md). All QuickJS code is behind the feature, and the QuickJS workflow builds it and runs WPT with it. Not meant for upstream in this form. Rebasing: under js-quickjs a Dom<T> holds a count, so a bitwise copy of one, as upstream's ptr::read in MutDom and MutNullableDom was, releases it twice. This must find nothing; clone or borrow instead: git grep ptr::read components/script_bindings components/script Removing such a copy can leave a crown unrooted_must_root expectation unfulfilled, which fails the Linux CI build (-D warnings) but no local build. Check with crown installed from the tree (cargo install --path support/crown): RUSTFLAGS="-D warnings" ./mach check --use-crown Validation: On ohos-main 8fab166, before folding: servo-quickjs `just test`, `just test-verify` and `just test-asan` (79 tests each) and `just fuzz-smoke 60` pass; `./mach fmt` and `./mach test-tidy` are clean, and servoshell builds without warnings with and without js-quickjs. WPT with debug builds of the same commit, QuickJS with QJS_VERIFY_TRACING=1 against SpiderMonkey, `--processes 2`, html/semantics/scripting-1, html/webappapis/microtask-queuing, html/webappapis/scripting, import-maps, workers/modules, webidl and dom/events (1087 tests): no panics or verifier aborts; worse with QuickJS only the three dynamic-import/microtasks/basic variants, which time out in a debug build and pass with `--timeout-multiplier 4`; better on 3 tests. On af58e60: release builds with both engines, the QuickJS one through the QuickJS workflow's patch step (servo-quickjs 0605066), and `./mach smoketest` passes with both. The worker sweep was added after these runs, from the ownership review: with it, 1000 XHRs in a worker no longer leave 1000 XMLHttpRequest objects alive (probe build of the spike). Full WPT on this stack, release builds with servo-quickjs ed76452, 58,101 tests, then 3 reruns per engine of every difference: outside the WebAssembly-dependent tests, QuickJS is consistently worse only in the three autoplay-*-permissions-policy tests, two WebGL conformance tests that time out on SpiderMonkey without JIT too, and single subtests of structured-cloning-error-stack and localeCompare (no Intl on desktop). After a review of these fixes, workers also release the pool after each batch, not only before the next one. With servo-quickjs 3286cd6, release build: `./mach smoketest` passes, and 2138 tests (cross-origin objects, WindowProxy, Location, history, windows, forms, structured cloning, WebIDL, DOM, fetch responses, workers) match the full run's QuickJS results, except one subtest that now passes and three tests that are flaky with SpiderMonkey too. Rebased onto 7f6279e (the TimerListener and closed-pipeline leak fixes, and servo#48739, which this stack had carried as a backport): release builds with both engines and a checked-release QuickJS build pass the smoketest without warnings, and 2464 WPT tests (the 2138 above plus timers, iframes and cross-document navigation) match the full run's QuickJS results, except one test now passing, as on SpiderMonkey, and two customizable-select tests that are flaky on both engines (select-appearance-hover crashed once under load and fails 5 of 5 alone on both). `RUSTFLAGS="-D warnings" ./mach check --use-crown`, as the Linux CI job builds, passes: the crown expectation on `MutNullableDom::get_unrooted` went away with the `ptr::read` it covered. AI-assisted: Yes (agent session; agent sessions wrote and tested the js-quickjs commits, and the agent folded them into this patch and added the worker sweep) AI-assisted: Yes (agent session; 2026-10-13 sync -- mechanical conflict resolution in components/servo/Cargo.toml, next to upstream's new default_tooling feature (servo#47255), no semantic change) AI-assisted: Yes (agent session; 2026-10-22 sync -- mechanical conflict resolution, no semantic change: the `js-quickjs` features next to upstream's new `default` lines of servo and servoshell (servo#48934)) Signed-off-by: Jonathan Schwender <[email protected]>
`./mach build --js-engine quickjs`, or `js-engine = "quickjs"` in .servobuild, builds Servo on servo-quickjs, the QuickJS implementation of the mozjs API. mach passes support/quickjs/cargo-config.toml, which patches mozjs to the servo-quickjs commit it pins, to every cargo command of a build configuration, also with `-p`, and enables the js-quickjs feature where it passes features. Before, a QuickJS build needed a hand-written patch in .cargo/config.toml, and the pinned commit lived in quickjs.yml, from where the runner image and the servo-ohos-wpt nightly had to extract it. The patch replaces mozjs in Cargo.lock, so a QuickJS build can't be `--locked`, and a cargo command without the configuration, e.g. from rust-analyzer, switches Cargo.lock back to SpiderMonkey. SpiderMonkey builds are unchanged. quickjs.yml builds with the option, and its servo-quickjs-ref input now replaces the commit in the file. A change under support/quickjs/ runs only the QuickJS build. Fork note: the pinned commit is bumped with mozjs at each sync, as it was in quickjs.yml. Validation: `./mach build --release --js-engine quickjs` built servoshell on servo-quickjs 72fa2b6 (cargo's command had the configuration and js-quickjs; the binary has the QuickJS symbols and no SpiderMonkey ones) and `xvfb-run ./mach smoketest --release` passed. With a nonexistent extra `--config`, mach printed the expected cargo commands for `--js-engine quickjs`, for js-engine = "quickjs" in .servobuild, for no option (unchanged) and for `--js-engine spidermonkey` overriding .servobuild; an unknown value in .servobuild is an error. `./mach check --js-engine quickjs -p servo-url` left the QuickJS Cargo.lock. `./mach test-scripts` and `./mach test-tidy` pass; actionlint reports for quickjs.yml only its two findings on ohos-main. AI-assisted: Yes (agent session; written by the agent, which also ran the builds and checks above) AI-assisted: Yes (agent session; 2026-10-22 sync -- upstream servo#48934 no longer adds `media-gstreamer` in mach (it is a default feature now; dummy-media builds switch to `--no-default-features` + `default_base`): the `js-quickjs` feature is appended after that block) Signed-off-by: Jonathan Schwender <[email protected]>
main brings servo#48934, which makes GStreamer a default feature of the ports and builds `--media-stack dummy` with `--no-default-features` plus `default_base`. - components/servo: `media-mpv` uses a `dep:` prefix like `media-gstreamer`, and the OHOS and Dummy backends are only selected without `media-mpv`. - mach: `--media-stack mpv` and `dummy` build without the default features, then add `default_base` back (and `media-mpv` for mpv). `auto` resolves to `gstreamer` again, which main had dropped along with `is_media_enabled`. Signed-off-by: Mambokara <[email protected]>
…ndexeddb
Add an OpenHarmony RDB backend behind the `ohos-rdb-backend` feature: OHOS
builds can use the system database through ohos-rdb-sys C FFI instead of the
bundled sqlite3. The sqlite modules keep their upstream logic; the RDB
implementation lives in new files with its own copy of the schema and CRUD, a
deliberate duplication that keeps rebases trivial, wired in through a small set
of cfg hooks. The FFI wrappers free their native handles on drop. A cursor
borrows its transaction, so the compiler rejects reads after commit. Strings
with interior NUL bytes are stored as blobs and read back unchanged.
Backend selection is a feature choice rather than a target choice, so a plain
`./mach build --ohos` keeps the upstream SQLite behaviour and no configuration
fails to compile:
./mach build --ohos # SQLite, as before
./mach build --ohos --features ohos-rdb-backend
# both, chosen at runtime
./mach build --ohos --no-default-features \
--features "base,ohos-rdb-backend"
# RDB only
Dropping sqlite is what makes the third configuration worth having: when
first measured (base 79e2c7a) the stripped aarch64 release
`libservoshell.so` went from 127,736,736 to 125,736,080 bytes, 1.91 MiB
less. Since the 2026-08-29 sync this no longer holds: upstream fb04f8f
(servo#43819, on-disk HTTP cache) makes rusqlite an unconditional dependency of
components/net, so the RDB-only configuration still links sqlite. The saving
needs remeasuring, and the configuration is only worth keeping if servo#43819's
sqlite use becomes optional.
With both backends compiled in, `storage_ohos_rdb_backend_enabled` (default
true) picks one per store as it is opened, so a single binary can A/B them
without reinstalling. The two backends keep disjoint on-disk stores — sqlite
files versus RDB's nested `rdb/<store>` — so flipping the pref switches to the
other backend's data, which starts out empty. That is intended for A/B
comparison; there is no migration between them.
Deliberate difference from the SQLite twin: RDB delivers the callbacks of a
batch after its commit, so the whole batch lands or errors together (SQLite
reports each operation in autocommit). Schema operations join that batch
transaction and follow the same rule. A second deliberate difference: after a
failed webstorage load on OHOS the session's final save is skipped, so a
partially loaded state cannot overwrite the store.
On a HarmonyOS phone the two legs of the pref agree exactly. One signed HAP,
`storage_ohos_rdb_backend_enabled` flipped between runs, over the ten WPT
storage tests the backend touches: 1188 subtests pass and 37 fail on each
side, test for test, and the failures are the ones tests/wpt/meta already
expects. The stores confirm the switch rather than assuming it — with the pref
on the app writes only `rdb/reg.rdb` and `rdb/webstorage.rdb`, with it off only
`reg.sqlite` and `webstorage.sqlite`.
One RDB limitation is worth recording. Opening a second client_storage registry
fails (14800001 / 14800011) about two runs in three, on DAYU200 and PLR-AL00
alike, when the process is not an application: `new_storage_threads` with no
`config_dir` falls back to `tempfile::tempdir()`, which outside an application
sandbox is `/data/local/tmp`. Neither half alone is enough — a single registry
under `/data/local/tmp` is reliable, and so are two registries inside the
application, which a phone confirmed over ten launches of the default
configuration and five of `--temporary-storage`, the latter being the same
two-registry shape that fails in a bare process. Servo always passes the
application's cache dir, so it never meets the condition;
`test_new_storage_threads_create_independent_groups`, which does, is ignored
when the RDB backend is compiled in.
The RDB copies of the IndexedDB and client-storage schemas are checked
against the SQLite ones by `tests/schema_parity.rs`, a host test that builds
both in an in-memory SQLite database and compares tables, columns, keys,
foreign keys and indexes, so an upstream schema change that is not mirrored
fails on the host instead of diverging on devices. The webstorage `data`
tables differ on purpose and are not compared.
Validation: Parallel twin of the sqlite backend — revalidate on every rebase even when it merges cleanly, since upstream storage changes never conflict with the RDB engine files. (1) `./mach check --ohos -- -p servo-storage --all-targets --features ohos-rdb-backend` must pass warning-free, as must the plain and the `--no-default-features --features ohos-rdb-backend` configurations; a new `AsyncOperation`/engine-trait variant fails here loudly and must be implemented in the RDB twins, not wildcarded. (2) Diff upstream changes since the previous base with `git log -p <old-base>..<new-base> -- components/storage` and mirror any sqlite-engine semantics changes into `engines/ohos_rdb.rs` / `webstorage/engines/ohos_rdb.rs` / `client_storage_ohos_rdb.rs`. (3) Host `./mach test-unit -p servo-storage` pins the sqlite reference behaviour. (4) On a device, run the same suite against both backends with `CARGO_TARGET_AARCH64_UNKNOWN_LINUX_OHOS_RUNNER=ohos-test-runner cargo nextest run -p servo-storage --target aarch64-unknown-linux-ohos [--no-default-features --features ohos-rdb-backend]` (raise nextest's slow-timeout: every test is pushed to the device), then the same-HAP A/B: build servoshell with `--features ohos-rdb-backend` (flavor and signing per the device: `harmonyos`/`hos` for a phone whose UDID is in the profile, default/OpenHarmony for the DAYU200), install it, and run `./mach test-wpt --ohos --release --no-headless --ohos-device <serial> --pref dom_indexeddb_enabled=true --pref storage_ohos_rdb_backend_enabled=<bool> --log-wptreport <leg>.json <subset>` (the `servo_ohos` wptrunner product of the `wpt-ohos` runner branch, cherry-picked onto the stack) once per pref value with `bm clean -n org.servo.servo -d` before each leg. Subset = all of `webstorage/` plus `IndexedDB/{idbobjectstore_put,idbobjectstore_get,idbobjectstore_delete,idbobjectstore_createIndex,idbindex_get,idbcursor_continue_objectstore,keypath,key_valid,transaction-abort-generator-revert,upgrade-transaction-lifecycle-committed,idbfactory_open,idbfactory_deleteDatabase}.any.{html,worker.html}` (78 tests). Compare the two wptreports subtest by subtest: no subtest may differ (crash/timeout-truncated tests are re-run in isolation on both legs), and the app data dir must contain only `*.rdb` stores after the true leg and only `*.sqlite` after the false leg (a lone `reg.rdb` from the runner's pref-less first launch and the HTTP cache's `cache.sqlite3` are expected). (5) Host `cargo nextest run -p servo-storage schema_parity` must pass; it fails when an upstream schema change is not mirrored into `indexeddb/engines/shared.rs` or `client_storage_shared.rs`. `./mach clippy --locked -- -- --deny warnings` must pass.
AI-assisted: Yes (agent session; implementation and on-device testing)
AI-assisted: Yes (agent session; 2026-08-29 rebase conflict resolution -- components/servo/Cargo.toml and components/storage/Cargo.toml resolved to the upstream side with only the fork's `ohos-rdb-backend` feature and optional-dependency markers re-added: upstream's `no-wgl = ["dep:mozangle", ...]` (servo#47198) is kept and `ohos-rdb-backend = ["storage/ohos-rdb-backend"]` re-added after it, and servo#43819 moved rusqlite's `bundled` feature onto the workspace dependency, so components/storage now carries only `rusqlite = { workspace = true, optional = true }`. Validation step (2): of the three upstream commits touching components/storage, only 7bea9ed (`ImmutableOrigin::ascii_serialization` now returns `Cow<'_, str>`) reaches the RDB twins, and it is a type change with no behaviour change; mirrored into `client_storage_shared.rs`, whose `create_a_storage_shelf` now hands the `Cow` to `push_text` by deref instead of the gone `as_str()`; `indexeddb/engines/shared.rs` already coerced, and no other twin site serializes an origin. fb04f8f touches only the Cargo.toml line above and 39f05ac only sqlite-side destructuring, so no semantics were mirrored into `engines/ohos_rdb.rs`, `webstorage/engines/ohos_rdb.rs` or `client_storage_ohos_rdb.rs`. Note: fb04f8f gave components/net an unconditional rusqlite dependency, so the 1.91 MiB saving quoted above for the RDB-only configuration no longer holds and needs remeasuring)
AI-assisted: Yes (agent session; 2026-10-08 sync -- conflict resolution in Cargo.toml, components/servo/Cargo.toml and components/storage/Cargo.toml: upstream's 0.7.0 versions with the fork's `default-features = false` re-added, upstream's new `multiprocess` default kept in servo's `default` and servoshell's `base` group, the fork's `[lints.rust]` table dropped for upstream's `[lints] workspace = true`; mirrored servo#47936 (index names unique per object store) into the RDB schema copy, adapted the tests to servo#48037's `GenericCallback::new`, added tests/schema_parity.rs and Validation step (5), updated step (4) for the current WPT runner, folded the clippy `duplicate_mod` squash commit; Cargo.lock regenerated from upstream's so that `cargo metadata --locked` passes at this commit)
AI-assisted: Yes (agent session; 2026-10-13 sync -- upstream servo#47255 added the default_tooling feature group: kept it in servo's default set and servoshell's base group next to the storage backend features)
AI-assisted: Yes (agent session; 2026-10-22 sync -- upstream servo#48934 and servo#49065 renamed servoshell's `default_without_allocator` group to `default_base` (which mach selects with `--no-default-features` for dummy-media builds) and moved jemalloc into it: `default_base` = `base` + `sqlite-backend`, and `base` takes upstream's list including `jemalloc`, so the RDB-only command above no longer names the allocator; servo's `default` merged next to upstream's blank line)
Signed-off-by: Jonathan Schwender <[email protected]>
With the js-quickjs feature, Servo runs on servo-quickjs (https://github.com/openharmony-rs/servo-quickjs), which implements the mozjs API on QuickJS. The feature builds only with mozjs patched to the shim, e.g. in .cargo/config.toml: [patch.crates-io] mozjs = { git = "https://github.com/openharmony-rs/servo-quickjs", rev = "..." } QuickJS frees objects by reference counting and collects cycles, so under js-quickjs: - Dom<T> and DomRoot<T> hold a reference count on their target, also when the target's reflector is set later (a DissimilarOriginWindow's WindowProxy), and roots go through no root list; - the reflector of a DOM object holds none on its own object, and is neither traced nor released by the Heap drop barrier; the reflector of a TracedPromise holds a counted, traced one; - finalizers drop the Dom<T> fields of an object while the collector knows which objects it frees, so WindowProxy finalizes through finalize_common; - live Trusted references are counted until swept, and the shim's autorelease pool is drained between tasks, on the script thread and on worker threads; - reflectors are initialized before they are rooted, DOM objects are left alone once the runtime is destroyed, and the Debugger API is left out. Under SpiderMonkey, WindowProxy's finalizer does what it did before, and MutDom and MutNullableDom no longer copy Dom<T> bitwise, which is equivalent. Fork note: experimental, to evaluate QuickJS as the engine of a smaller profile (servo-quickjs docs/design.md). All QuickJS code is behind the feature, and the QuickJS workflow builds it and runs WPT with it. Not meant for upstream in this form. Rebasing: under js-quickjs a Dom<T> holds a count, so a bitwise copy of one, as upstream's ptr::read in MutDom and MutNullableDom was, releases it twice. This must find nothing; clone or borrow instead: git grep ptr::read components/script_bindings components/script Removing such a copy can leave a crown unrooted_must_root expectation unfulfilled, which fails the Linux CI build (-D warnings) but no local build. Check with crown installed from the tree (cargo install --path support/crown): RUSTFLAGS="-D warnings" ./mach check --use-crown Validation: On ohos-main 8fab166, before folding: servo-quickjs `just test`, `just test-verify` and `just test-asan` (79 tests each) and `just fuzz-smoke 60` pass; `./mach fmt` and `./mach test-tidy` are clean, and servoshell builds without warnings with and without js-quickjs. WPT with debug builds of the same commit, QuickJS with QJS_VERIFY_TRACING=1 against SpiderMonkey, `--processes 2`, html/semantics/scripting-1, html/webappapis/microtask-queuing, html/webappapis/scripting, import-maps, workers/modules, webidl and dom/events (1087 tests): no panics or verifier aborts; worse with QuickJS only the three dynamic-import/microtasks/basic variants, which time out in a debug build and pass with `--timeout-multiplier 4`; better on 3 tests. On af58e60: release builds with both engines, the QuickJS one through the QuickJS workflow's patch step (servo-quickjs 0605066), and `./mach smoketest` passes with both. The worker sweep was added after these runs, from the ownership review: with it, 1000 XHRs in a worker no longer leave 1000 XMLHttpRequest objects alive (probe build of the spike). Full WPT on this stack, release builds with servo-quickjs ed76452, 58,101 tests, then 3 reruns per engine of every difference: outside the WebAssembly-dependent tests, QuickJS is consistently worse only in the three autoplay-*-permissions-policy tests, two WebGL conformance tests that time out on SpiderMonkey without JIT too, and single subtests of structured-cloning-error-stack and localeCompare (no Intl on desktop). After a review of these fixes, workers also release the pool after each batch, not only before the next one. With servo-quickjs 3286cd6, release build: `./mach smoketest` passes, and 2138 tests (cross-origin objects, WindowProxy, Location, history, windows, forms, structured cloning, WebIDL, DOM, fetch responses, workers) match the full run's QuickJS results, except one subtest that now passes and three tests that are flaky with SpiderMonkey too. Rebased onto 7f6279e (the TimerListener and closed-pipeline leak fixes, and servo#48739, which this stack had carried as a backport): release builds with both engines and a checked-release QuickJS build pass the smoketest without warnings, and 2464 WPT tests (the 2138 above plus timers, iframes and cross-document navigation) match the full run's QuickJS results, except one test now passing, as on SpiderMonkey, and two customizable-select tests that are flaky on both engines (select-appearance-hover crashed once under load and fails 5 of 5 alone on both). `RUSTFLAGS="-D warnings" ./mach check --use-crown`, as the Linux CI job builds, passes: the crown expectation on `MutNullableDom::get_unrooted` went away with the `ptr::read` it covered. AI-assisted: Yes (agent session; agent sessions wrote and tested the js-quickjs commits, and the agent folded them into this patch and added the worker sweep) AI-assisted: Yes (agent session; 2026-10-13 sync -- mechanical conflict resolution in components/servo/Cargo.toml, next to upstream's new default_tooling feature (servo#47255), no semantic change) AI-assisted: Yes (agent session; 2026-10-22 sync -- mechanical conflict resolution, no semantic change: the `js-quickjs` features next to upstream's new `default` lines of servo and servoshell (servo#48934)) Signed-off-by: Jonathan Schwender <[email protected]>
`./mach build --js-engine quickjs`, or `js-engine = "quickjs"` in .servobuild, builds Servo on servo-quickjs, the QuickJS implementation of the mozjs API. mach passes support/quickjs/cargo-config.toml, which patches mozjs to the servo-quickjs commit it pins, to every cargo command of a build configuration, also with `-p`, and enables the js-quickjs feature where it passes features. Before, a QuickJS build needed a hand-written patch in .cargo/config.toml, and the pinned commit lived in quickjs.yml, from where the runner image and the servo-ohos-wpt nightly had to extract it. The patch replaces mozjs in Cargo.lock, so a QuickJS build can't be `--locked`, and a cargo command without the configuration, e.g. from rust-analyzer, switches Cargo.lock back to SpiderMonkey. SpiderMonkey builds are unchanged. quickjs.yml builds with the option, and its servo-quickjs-ref input now replaces the commit in the file. A change under support/quickjs/ runs only the QuickJS build. Fork note: the pinned commit is bumped with mozjs at each sync, as it was in quickjs.yml. Validation: `./mach build --release --js-engine quickjs` built servoshell on servo-quickjs 72fa2b6 (cargo's command had the configuration and js-quickjs; the binary has the QuickJS symbols and no SpiderMonkey ones) and `xvfb-run ./mach smoketest --release` passed. With a nonexistent extra `--config`, mach printed the expected cargo commands for `--js-engine quickjs`, for js-engine = "quickjs" in .servobuild, for no option (unchanged) and for `--js-engine spidermonkey` overriding .servobuild; an unknown value in .servobuild is an error. `./mach check --js-engine quickjs -p servo-url` left the QuickJS Cargo.lock. `./mach test-scripts` and `./mach test-tidy` pass; actionlint reports for quickjs.yml only its two findings on ohos-main. AI-assisted: Yes (agent session; written by the agent, which also ran the builds and checks above) AI-assisted: Yes (agent session; 2026-10-22 sync -- upstream servo#48934 no longer adds `media-gstreamer` in mach (it is a default feature now; dummy-media builds switch to `--no-default-features` + `default_base`): the `js-quickjs` feature is appended after that block) Signed-off-by: Jonathan Schwender <[email protected]>
…ndexeddb
Add an OpenHarmony RDB backend behind the `ohos-rdb-backend` feature: OHOS
builds can use the system database through ohos-rdb-sys C FFI instead of the
bundled sqlite3. The sqlite modules keep their upstream logic; the RDB
implementation lives in new files with its own copy of the schema and CRUD, a
deliberate duplication that keeps rebases trivial, wired in through a small set
of cfg hooks. The FFI wrappers free their native handles on drop. A cursor
borrows its transaction, so the compiler rejects reads after commit. Strings
with interior NUL bytes are stored as blobs and read back unchanged.
Backend selection is a feature choice rather than a target choice, so a plain
`./mach build --ohos` keeps the upstream SQLite behaviour and no configuration
fails to compile:
./mach build --ohos # SQLite, as before
./mach build --ohos --features ohos-rdb-backend
# both, chosen at runtime
./mach build --ohos --no-default-features \
--features "base,ohos-rdb-backend"
# RDB only
Dropping sqlite is what makes the third configuration worth having: when
first measured (base 79e2c7a) the stripped aarch64 release
`libservoshell.so` went from 127,736,736 to 125,736,080 bytes, 1.91 MiB
less. Since the 2026-08-29 sync this no longer holds: upstream fb04f8f
(servo#43819, on-disk HTTP cache) makes rusqlite an unconditional dependency of
components/net, so the RDB-only configuration still links sqlite. The saving
needs remeasuring, and the configuration is only worth keeping if servo#43819's
sqlite use becomes optional.
With both backends compiled in, `storage_ohos_rdb_backend_enabled` (default
true) picks one per store as it is opened, so a single binary can A/B them
without reinstalling. The two backends keep disjoint on-disk stores — sqlite
files versus RDB's nested `rdb/<store>` — so flipping the pref switches to the
other backend's data, which starts out empty. That is intended for A/B
comparison; there is no migration between them.
Deliberate difference from the SQLite twin: RDB delivers the callbacks of a
batch after its commit, so the whole batch lands or errors together (SQLite
reports each operation in autocommit). Schema operations join that batch
transaction and follow the same rule. A second deliberate difference: after a
failed webstorage load on OHOS the session's final save is skipped, so a
partially loaded state cannot overwrite the store.
On a HarmonyOS phone the two legs of the pref agree exactly. One signed HAP,
`storage_ohos_rdb_backend_enabled` flipped between runs, over the ten WPT
storage tests the backend touches: 1188 subtests pass and 37 fail on each
side, test for test, and the failures are the ones tests/wpt/meta already
expects. The stores confirm the switch rather than assuming it — with the pref
on the app writes only `rdb/reg.rdb` and `rdb/webstorage.rdb`, with it off only
`reg.sqlite` and `webstorage.sqlite`.
One RDB limitation is worth recording. Opening a second client_storage registry
fails (14800001 / 14800011) about two runs in three, on DAYU200 and a HarmonyOS phone
alike, when the process is not an application: `new_storage_threads` with no
`config_dir` falls back to `tempfile::tempdir()`, which outside an application
sandbox is `/data/local/tmp`. Neither half alone is enough — a single registry
under `/data/local/tmp` is reliable, and so are two registries inside the
application, which a phone confirmed over ten launches of the default
configuration and five of `--temporary-storage`, the latter being the same
two-registry shape that fails in a bare process. Servo always passes the
application's cache dir, so it never meets the condition;
`test_new_storage_threads_create_independent_groups`, which does, is ignored
when the RDB backend is compiled in.
The RDB copies of the IndexedDB and client-storage schemas are checked
against the SQLite ones by `tests/schema_parity.rs`, a host test that builds
both in an in-memory SQLite database and compares tables, columns, keys,
foreign keys and indexes, so an upstream schema change that is not mirrored
fails on the host instead of diverging on devices. The webstorage `data`
tables differ on purpose and are not compared.
Validation: Parallel twin of the sqlite backend — revalidate on every rebase even when it merges cleanly, since upstream storage changes never conflict with the RDB engine files. (1) `./mach check --ohos -- -p servo-storage --all-targets --features ohos-rdb-backend` must pass warning-free, as must the plain and the `--no-default-features --features ohos-rdb-backend` configurations; a new `AsyncOperation`/engine-trait variant fails here loudly and must be implemented in the RDB twins, not wildcarded. (2) Diff upstream changes since the previous base with `git log -p <old-base>..<new-base> -- components/storage` and mirror any sqlite-engine semantics changes into `engines/ohos_rdb.rs` / `webstorage/engines/ohos_rdb.rs` / `client_storage_ohos_rdb.rs`. (3) Host `./mach test-unit -p servo-storage` pins the sqlite reference behaviour. (4) On a device, run the same suite against both backends with `CARGO_TARGET_AARCH64_UNKNOWN_LINUX_OHOS_RUNNER=ohos-test-runner cargo nextest run -p servo-storage --target aarch64-unknown-linux-ohos [--no-default-features --features ohos-rdb-backend]` (raise nextest's slow-timeout: every test is pushed to the device), then the same-HAP A/B: build servoshell with `--features ohos-rdb-backend` (flavor and signing per the device: `harmonyos`/`hos` for a phone whose UDID is in the profile, default/OpenHarmony for the DAYU200), install it, and run `./mach test-wpt --ohos --release --no-headless --ohos-device <serial> --pref dom_indexeddb_enabled=true --pref storage_ohos_rdb_backend_enabled=<bool> --log-wptreport <leg>.json <subset>` (the `servo_ohos` wptrunner product of the `wpt-ohos` runner branch, cherry-picked onto the stack) once per pref value with `bm clean -n org.servo.servo -d` before each leg. Subset = all of `webstorage/` plus `IndexedDB/{idbobjectstore_put,idbobjectstore_get,idbobjectstore_delete,idbobjectstore_createIndex,idbindex_get,idbcursor_continue_objectstore,keypath,key_valid,transaction-abort-generator-revert,upgrade-transaction-lifecycle-committed,idbfactory_open,idbfactory_deleteDatabase}.any.{html,worker.html}` (78 tests). Compare the two wptreports subtest by subtest: no subtest may differ (crash/timeout-truncated tests are re-run in isolation on both legs), and the app data dir must contain only `*.rdb` stores after the true leg and only `*.sqlite` after the false leg (a lone `reg.rdb` from the runner's pref-less first launch and the HTTP cache's `cache.sqlite3` are expected). (5) Host `cargo nextest run -p servo-storage schema_parity` must pass; it fails when an upstream schema change is not mirrored into `indexeddb/engines/shared.rs` or `client_storage_shared.rs`. `./mach clippy --locked -- -- --deny warnings` must pass.
AI-assisted: Yes (agent session; implementation and on-device testing)
AI-assisted: Yes (agent session; 2026-08-29 rebase conflict resolution -- components/servo/Cargo.toml and components/storage/Cargo.toml resolved to the upstream side with only the fork's `ohos-rdb-backend` feature and optional-dependency markers re-added: upstream's `no-wgl = ["dep:mozangle", ...]` (servo#47198) is kept and `ohos-rdb-backend = ["storage/ohos-rdb-backend"]` re-added after it, and servo#43819 moved rusqlite's `bundled` feature onto the workspace dependency, so components/storage now carries only `rusqlite = { workspace = true, optional = true }`. Validation step (2): of the three upstream commits touching components/storage, only 7bea9ed (`ImmutableOrigin::ascii_serialization` now returns `Cow<'_, str>`) reaches the RDB twins, and it is a type change with no behaviour change; mirrored into `client_storage_shared.rs`, whose `create_a_storage_shelf` now hands the `Cow` to `push_text` by deref instead of the gone `as_str()`; `indexeddb/engines/shared.rs` already coerced, and no other twin site serializes an origin. fb04f8f touches only the Cargo.toml line above and 39f05ac only sqlite-side destructuring, so no semantics were mirrored into `engines/ohos_rdb.rs`, `webstorage/engines/ohos_rdb.rs` or `client_storage_ohos_rdb.rs`. Note: fb04f8f gave components/net an unconditional rusqlite dependency, so the 1.91 MiB saving quoted above for the RDB-only configuration no longer holds and needs remeasuring)
AI-assisted: Yes (agent session; 2026-10-08 sync -- conflict resolution in Cargo.toml, components/servo/Cargo.toml and components/storage/Cargo.toml: upstream's 0.7.0 versions with the fork's `default-features = false` re-added, upstream's new `multiprocess` default kept in servo's `default` and servoshell's `base` group, the fork's `[lints.rust]` table dropped for upstream's `[lints] workspace = true`; mirrored servo#47936 (index names unique per object store) into the RDB schema copy, adapted the tests to servo#48037's `GenericCallback::new`, added tests/schema_parity.rs and Validation step (5), updated step (4) for the current WPT runner, folded the clippy `duplicate_mod` squash commit; Cargo.lock regenerated from upstream's so that `cargo metadata --locked` passes at this commit)
AI-assisted: Yes (agent session; 2026-10-13 sync -- upstream servo#47255 added the default_tooling feature group: kept it in servo's default set and servoshell's base group next to the storage backend features)
AI-assisted: Yes (agent session; 2026-10-22 sync -- upstream servo#48934 and servo#49065 renamed servoshell's `default_without_allocator` group to `default_base` (which mach selects with `--no-default-features` for dummy-media builds) and moved jemalloc into it: `default_base` = `base` + `sqlite-backend`, and `base` takes upstream's list including `jemalloc`, so the RDB-only command above no longer names the allocator; servo's `default` merged next to upstream's blank line)
AI-assisted: Yes (agent session; 2026-11-09 sync -- the storage crate joins upstream's 0.8.0 workspace version block (servo#49467), keeping default-features = false; the sqlite-backend feature next to upstream's subtlecrypto (servo#48860))
Signed-off-by: Jonathan Schwender <[email protected]>
With the js-quickjs feature, Servo runs on servo-quickjs (https://github.com/openharmony-rs/servo-quickjs), which implements the mozjs API on QuickJS. The feature builds only with mozjs patched to the shim, e.g. in .cargo/config.toml: [patch.crates-io] mozjs = { git = "https://github.com/openharmony-rs/servo-quickjs", rev = "..." } QuickJS frees objects by reference counting and collects cycles, so under js-quickjs: - Dom<T> and DomRoot<T> hold a reference count on their target, also when the target's reflector is set later (a DissimilarOriginWindow's WindowProxy), and roots go through no root list; - the reflector of a DOM object holds none on its own object, and is neither traced nor released by the Heap drop barrier; the reflector of a TracedPromise holds a counted, traced one; - finalizers drop the Dom<T> fields of an object while the collector knows which objects it frees, so WindowProxy finalizes through finalize_common; - live Trusted references are counted until swept, and the shim's autorelease pool is drained between tasks, on the script thread and on worker threads; - reflectors are initialized before they are rooted, DOM objects are left alone once the runtime is destroyed, and the Debugger API is left out. Under SpiderMonkey, WindowProxy's finalizer does what it did before, and MutDom and MutNullableDom no longer copy Dom<T> bitwise, which is equivalent. Fork note: experimental, to evaluate QuickJS as the engine of a smaller profile (servo-quickjs docs/design.md). All QuickJS code is behind the feature, and the QuickJS workflow builds it and runs WPT with it. Not meant for upstream in this form. Rebasing: under js-quickjs a Dom<T> holds a count, so a bitwise copy of one, as upstream's ptr::read in MutDom and MutNullableDom was, releases it twice. This must find nothing; clone or borrow instead: git grep ptr::read components/script_bindings components/script Removing such a copy can leave a crown unrooted_must_root expectation unfulfilled, which fails the Linux CI build (-D warnings) but no local build. Check with crown installed from the tree (cargo install --path support/crown): RUSTFLAGS="-D warnings" ./mach check --use-crown Validation: On ohos-main 8fab166, before folding: servo-quickjs `just test`, `just test-verify` and `just test-asan` (79 tests each) and `just fuzz-smoke 60` pass; `./mach fmt` and `./mach test-tidy` are clean, and servoshell builds without warnings with and without js-quickjs. WPT with debug builds of the same commit, QuickJS with QJS_VERIFY_TRACING=1 against SpiderMonkey, `--processes 2`, html/semantics/scripting-1, html/webappapis/microtask-queuing, html/webappapis/scripting, import-maps, workers/modules, webidl and dom/events (1087 tests): no panics or verifier aborts; worse with QuickJS only the three dynamic-import/microtasks/basic variants, which time out in a debug build and pass with `--timeout-multiplier 4`; better on 3 tests. On af58e60: release builds with both engines, the QuickJS one through the QuickJS workflow's patch step (servo-quickjs 0605066), and `./mach smoketest` passes with both. The worker sweep was added after these runs, from the ownership review: with it, 1000 XHRs in a worker no longer leave 1000 XMLHttpRequest objects alive (probe build of the spike). Full WPT on this stack, release builds with servo-quickjs ed76452, 58,101 tests, then 3 reruns per engine of every difference: outside the WebAssembly-dependent tests, QuickJS is consistently worse only in the three autoplay-*-permissions-policy tests, two WebGL conformance tests that time out on SpiderMonkey without JIT too, and single subtests of structured-cloning-error-stack and localeCompare (no Intl on desktop). After a review of these fixes, workers also release the pool after each batch, not only before the next one. With servo-quickjs 3286cd6, release build: `./mach smoketest` passes, and 2138 tests (cross-origin objects, WindowProxy, Location, history, windows, forms, structured cloning, WebIDL, DOM, fetch responses, workers) match the full run's QuickJS results, except one subtest that now passes and three tests that are flaky with SpiderMonkey too. Rebased onto 7f6279e (the TimerListener and closed-pipeline leak fixes, and servo#48739, which this stack had carried as a backport): release builds with both engines and a checked-release QuickJS build pass the smoketest without warnings, and 2464 WPT tests (the 2138 above plus timers, iframes and cross-document navigation) match the full run's QuickJS results, except one test now passing, as on SpiderMonkey, and two customizable-select tests that are flaky on both engines (select-appearance-hover crashed once under load and fails 5 of 5 alone on both). `RUSTFLAGS="-D warnings" ./mach check --use-crown`, as the Linux CI job builds, passes: the crown expectation on `MutNullableDom::get_unrooted` went away with the `ptr::read` it covered. AI-assisted: Yes (agent session; agent sessions wrote and tested the js-quickjs commits, and the agent folded them into this patch and added the worker sweep) AI-assisted: Yes (agent session; 2026-10-13 sync -- mechanical conflict resolution in components/servo/Cargo.toml, next to upstream's new default_tooling feature (servo#47255), no semantic change) AI-assisted: Yes (agent session; 2026-10-22 sync -- mechanical conflict resolution, no semantic change: the `js-quickjs` features next to upstream's new `default` lines of servo and servoshell (servo#48934)) AI-assisted: Yes (agent session; 2026-11-09 sync -- the task-end sweep sits in upstream's renamed handle_messages() loop; the feature next to upstream's subtlecrypto (servo#48860)) Signed-off-by: Jonathan Schwender <[email protected]>
`./mach build --js-engine quickjs`, or `js-engine = "quickjs"` in .servobuild, builds Servo on servo-quickjs, the QuickJS implementation of the mozjs API. mach passes support/quickjs/cargo-config.toml, which patches mozjs to the servo-quickjs commit it pins, to every cargo command of a build configuration, also with `-p`, and enables the js-quickjs feature where it passes features. Before, a QuickJS build needed a hand-written patch in .cargo/config.toml, and the pinned commit lived in quickjs.yml, from where the runner image and the servo-ohos-wpt nightly had to extract it. The patch replaces mozjs in Cargo.lock, so a QuickJS build can't be `--locked`, and a cargo command without the configuration, e.g. from rust-analyzer, switches Cargo.lock back to SpiderMonkey. SpiderMonkey builds are unchanged. quickjs.yml builds with the option, and its servo-quickjs-ref input now replaces the commit in the file. A change under support/quickjs/ runs only the QuickJS build. Fork note: the pinned commit is bumped with mozjs at each sync, as it was in quickjs.yml. Validation: `./mach build --release --js-engine quickjs` built servoshell on servo-quickjs 72fa2b6 (cargo's command had the configuration and js-quickjs; the binary has the QuickJS symbols and no SpiderMonkey ones) and `xvfb-run ./mach smoketest --release` passed. With a nonexistent extra `--config`, mach printed the expected cargo commands for `--js-engine quickjs`, for js-engine = "quickjs" in .servobuild, for no option (unchanged) and for `--js-engine spidermonkey` overriding .servobuild; an unknown value in .servobuild is an error. `./mach check --js-engine quickjs -p servo-url` left the QuickJS Cargo.lock. `./mach test-scripts` and `./mach test-tidy` pass; actionlint reports for quickjs.yml only its two findings on ohos-main. AI-assisted: Yes (agent session; written by the agent, which also ran the builds and checks above) AI-assisted: Yes (agent session; 2026-10-22 sync -- upstream servo#48934 no longer adds `media-gstreamer` in mach (it is a default feature now; dummy-media builds switch to `--no-default-features` + `default_base`): the `js-quickjs` feature is appended after that block) Signed-off-by: Jonathan Schwender <[email protected]>
…ndexeddb
Add an OpenHarmony RDB backend behind the `ohos-rdb-backend` feature: OHOS
builds can use the system database through ohos-rdb-sys C FFI instead of the
bundled sqlite3. The sqlite modules keep their upstream logic; the RDB
implementation lives in new files with its own copy of the schema and CRUD, a
deliberate duplication that keeps rebases trivial, wired in through a small set
of cfg hooks. The FFI wrappers free their native handles on drop. A cursor
borrows its transaction, so the compiler rejects reads after commit. Strings
with interior NUL bytes are stored as blobs and read back unchanged.
Backend selection is a feature choice rather than a target choice, so a plain
`./mach build --ohos` keeps the upstream SQLite behaviour and no configuration
fails to compile:
./mach build --ohos # SQLite, as before
./mach build --ohos --features ohos-rdb-backend
# both, chosen at runtime
./mach build --ohos --no-default-features \
--features "base,ohos-rdb-backend"
# RDB only
Dropping sqlite is what makes the third configuration worth having: when
first measured (base 79e2c7a) the stripped aarch64 release
`libservoshell.so` went from 127,736,736 to 125,736,080 bytes, 1.91 MiB
less. Since the 2026-08-29 sync this no longer holds: upstream fb04f8f
(servo#43819, on-disk HTTP cache) makes rusqlite an unconditional dependency of
components/net, so the RDB-only configuration still links sqlite. The saving
needs remeasuring, and the configuration is only worth keeping if servo#43819's
sqlite use becomes optional.
With both backends compiled in, `storage_ohos_rdb_backend_enabled` (default
true) picks one per store as it is opened, so a single binary can A/B them
without reinstalling. The two backends keep disjoint on-disk stores — sqlite
files versus RDB's nested `rdb/<store>` — so flipping the pref switches to the
other backend's data, which starts out empty. That is intended for A/B
comparison; there is no migration between them.
Deliberate difference from the SQLite twin: RDB delivers the callbacks of a
batch after its commit, so the whole batch lands or errors together (SQLite
reports each operation in autocommit). Schema operations join that batch
transaction and follow the same rule. A second deliberate difference: after a
failed webstorage load on OHOS the session's final save is skipped, so a
partially loaded state cannot overwrite the store.
On a HarmonyOS phone the two legs of the pref agree exactly. One signed HAP,
`storage_ohos_rdb_backend_enabled` flipped between runs, over the ten WPT
storage tests the backend touches: 1188 subtests pass and 37 fail on each
side, test for test, and the failures are the ones tests/wpt/meta already
expects. The stores confirm the switch rather than assuming it — with the pref
on the app writes only `rdb/reg.rdb` and `rdb/webstorage.rdb`, with it off only
`reg.sqlite` and `webstorage.sqlite`.
One RDB limitation is worth recording. Opening a second client_storage registry
fails (14800001 / 14800011) about two runs in three, on DAYU200 and a HarmonyOS phone
alike, when the process is not an application: `new_storage_threads` with no
`config_dir` falls back to `tempfile::tempdir()`, which outside an application
sandbox is `/data/local/tmp`. Neither half alone is enough — a single registry
under `/data/local/tmp` is reliable, and so are two registries inside the
application, which a phone confirmed over ten launches of the default
configuration and five of `--temporary-storage`, the latter being the same
two-registry shape that fails in a bare process. Servo always passes the
application's cache dir, so it never meets the condition;
`test_new_storage_threads_create_independent_groups`, which does, is ignored
when the RDB backend is compiled in.
The RDB copies of the IndexedDB and client-storage schemas are checked
against the SQLite ones by `tests/schema_parity.rs`, a host test that builds
both in an in-memory SQLite database and compares tables, columns, keys,
foreign keys and indexes, so an upstream schema change that is not mirrored
fails on the host instead of diverging on devices. The webstorage `data`
tables differ on purpose and are not compared.
Validation: Parallel twin of the sqlite backend — revalidate on every rebase even when it merges cleanly, since upstream storage changes never conflict with the RDB engine files. (1) `./mach check --ohos -- -p servo-storage --all-targets --features ohos-rdb-backend` must pass warning-free, as must the plain and the `--no-default-features --features ohos-rdb-backend` configurations; a new `AsyncOperation`/engine-trait variant fails here loudly and must be implemented in the RDB twins, not wildcarded. (2) Diff upstream changes since the previous base with `git log -p <old-base>..<new-base> -- components/storage` and mirror any sqlite-engine semantics changes into `engines/ohos_rdb.rs` / `webstorage/engines/ohos_rdb.rs` / `client_storage_ohos_rdb.rs`. (3) Host `./mach test-unit -p servo-storage` pins the sqlite reference behaviour. (4) On a device, run the same suite against both backends with `CARGO_TARGET_AARCH64_UNKNOWN_LINUX_OHOS_RUNNER=ohos-test-runner cargo nextest run -p servo-storage --target aarch64-unknown-linux-ohos [--no-default-features --features ohos-rdb-backend]` (raise nextest's slow-timeout: every test is pushed to the device), then the same-HAP A/B: build servoshell with `--features ohos-rdb-backend` (flavor and signing per the device: `harmonyos`/`hos` for a phone whose UDID is in the profile, default/OpenHarmony for the DAYU200), install it, and run `./mach test-wpt --ohos --release --no-headless --ohos-device <serial> --pref dom_indexeddb_enabled=true --pref storage_ohos_rdb_backend_enabled=<bool> --log-wptreport <leg>.json <subset>` (the `servo_ohos` wptrunner product of the `wpt-ohos` runner branch, cherry-picked onto the stack) once per pref value with `bm clean -n org.servo.servo -d` before each leg. Subset = all of `webstorage/` plus `IndexedDB/{idbobjectstore_put,idbobjectstore_get,idbobjectstore_delete,idbobjectstore_createIndex,idbindex_get,idbcursor_continue_objectstore,keypath,key_valid,transaction-abort-generator-revert,upgrade-transaction-lifecycle-committed,idbfactory_open,idbfactory_deleteDatabase}.any.{html,worker.html}` (78 tests). Compare the two wptreports subtest by subtest: no subtest may differ (crash/timeout-truncated tests are re-run in isolation on both legs), and the app data dir must contain only `*.rdb` stores after the true leg and only `*.sqlite` after the false leg (a lone `reg.rdb` from the runner's pref-less first launch and the HTTP cache's `cache.sqlite3` are expected). (5) Host `cargo nextest run -p servo-storage schema_parity` must pass; it fails when an upstream schema change is not mirrored into `indexeddb/engines/shared.rs` or `client_storage_shared.rs`. `./mach clippy --locked -- -- --deny warnings` must pass.
AI-assisted: Yes (agent session; implementation and on-device testing)
AI-assisted: Yes (agent session; 2026-08-29 rebase conflict resolution -- components/servo/Cargo.toml and components/storage/Cargo.toml resolved to the upstream side with only the fork's `ohos-rdb-backend` feature and optional-dependency markers re-added: upstream's `no-wgl = ["dep:mozangle", ...]` (servo#47198) is kept and `ohos-rdb-backend = ["storage/ohos-rdb-backend"]` re-added after it, and servo#43819 moved rusqlite's `bundled` feature onto the workspace dependency, so components/storage now carries only `rusqlite = { workspace = true, optional = true }`. Validation step (2): of the three upstream commits touching components/storage, only 7bea9ed (`ImmutableOrigin::ascii_serialization` now returns `Cow<'_, str>`) reaches the RDB twins, and it is a type change with no behaviour change; mirrored into `client_storage_shared.rs`, whose `create_a_storage_shelf` now hands the `Cow` to `push_text` by deref instead of the gone `as_str()`; `indexeddb/engines/shared.rs` already coerced, and no other twin site serializes an origin. fb04f8f touches only the Cargo.toml line above and 39f05ac only sqlite-side destructuring, so no semantics were mirrored into `engines/ohos_rdb.rs`, `webstorage/engines/ohos_rdb.rs` or `client_storage_ohos_rdb.rs`. Note: fb04f8f gave components/net an unconditional rusqlite dependency, so the 1.91 MiB saving quoted above for the RDB-only configuration no longer holds and needs remeasuring)
AI-assisted: Yes (agent session; 2026-10-08 sync -- conflict resolution in Cargo.toml, components/servo/Cargo.toml and components/storage/Cargo.toml: upstream's 0.7.0 versions with the fork's `default-features = false` re-added, upstream's new `multiprocess` default kept in servo's `default` and servoshell's `base` group, the fork's `[lints.rust]` table dropped for upstream's `[lints] workspace = true`; mirrored servo#47936 (index names unique per object store) into the RDB schema copy, adapted the tests to servo#48037's `GenericCallback::new`, added tests/schema_parity.rs and Validation step (5), updated step (4) for the current WPT runner, folded the clippy `duplicate_mod` squash commit; Cargo.lock regenerated from upstream's so that `cargo metadata --locked` passes at this commit)
AI-assisted: Yes (agent session; 2026-10-13 sync -- upstream servo#47255 added the default_tooling feature group: kept it in servo's default set and servoshell's base group next to the storage backend features)
AI-assisted: Yes (agent session; 2026-10-22 sync -- upstream servo#48934 and servo#49065 renamed servoshell's `default_without_allocator` group to `default_base` (which mach selects with `--no-default-features` for dummy-media builds) and moved jemalloc into it: `default_base` = `base` + `sqlite-backend`, and `base` takes upstream's list including `jemalloc`, so the RDB-only command above no longer names the allocator; servo's `default` merged next to upstream's blank line)
AI-assisted: Yes (agent session; 2026-11-09 sync -- the storage crate joins upstream's 0.8.0 workspace version block (servo#49467), keeping default-features = false; the sqlite-backend feature next to upstream's subtlecrypto (servo#48860))
Signed-off-by: Jonathan Schwender <[email protected]>
With the js-quickjs feature, Servo runs on servo-quickjs (https://github.com/openharmony-rs/servo-quickjs), which implements the mozjs API on QuickJS. The feature builds only with mozjs patched to the shim, e.g. in .cargo/config.toml: [patch.crates-io] mozjs = { git = "https://github.com/openharmony-rs/servo-quickjs", rev = "..." } QuickJS frees objects by reference counting and collects cycles, so under js-quickjs: - Dom<T> and DomRoot<T> hold a reference count on their target, also when the target's reflector is set later (a DissimilarOriginWindow's WindowProxy), and roots go through no root list; - the reflector of a DOM object holds none on its own object, and is neither traced nor released by the Heap drop barrier; the reflector of a TracedPromise holds a counted, traced one; - finalizers drop the Dom<T> fields of an object while the collector knows which objects it frees, so WindowProxy finalizes through finalize_common; - live Trusted references are counted until swept, and the shim's autorelease pool is drained between tasks, on the script thread and on worker threads; - reflectors are initialized before they are rooted, DOM objects are left alone once the runtime is destroyed, and the Debugger API is left out. Under SpiderMonkey, WindowProxy's finalizer does what it did before, and MutDom and MutNullableDom no longer copy Dom<T> bitwise, which is equivalent. Fork note: experimental, to evaluate QuickJS as the engine of a smaller profile (servo-quickjs docs/design.md). All QuickJS code is behind the feature, and the QuickJS workflow builds it and runs WPT with it. Not meant for upstream in this form. Rebasing: under js-quickjs a Dom<T> holds a count, so a bitwise copy of one, as upstream's ptr::read in MutDom and MutNullableDom was, releases it twice. This must find nothing; clone or borrow instead: git grep ptr::read components/script_bindings components/script Removing such a copy can leave a crown unrooted_must_root expectation unfulfilled, which fails the Linux CI build (-D warnings) but no local build. Check with crown installed from the tree (cargo install --path support/crown): RUSTFLAGS="-D warnings" ./mach check --use-crown Validation: On ohos-main 8fab166, before folding: servo-quickjs `just test`, `just test-verify` and `just test-asan` (79 tests each) and `just fuzz-smoke 60` pass; `./mach fmt` and `./mach test-tidy` are clean, and servoshell builds without warnings with and without js-quickjs. WPT with debug builds of the same commit, QuickJS with QJS_VERIFY_TRACING=1 against SpiderMonkey, `--processes 2`, html/semantics/scripting-1, html/webappapis/microtask-queuing, html/webappapis/scripting, import-maps, workers/modules, webidl and dom/events (1087 tests): no panics or verifier aborts; worse with QuickJS only the three dynamic-import/microtasks/basic variants, which time out in a debug build and pass with `--timeout-multiplier 4`; better on 3 tests. On af58e60: release builds with both engines, the QuickJS one through the QuickJS workflow's patch step (servo-quickjs 0605066), and `./mach smoketest` passes with both. The worker sweep was added after these runs, from the ownership review: with it, 1000 XHRs in a worker no longer leave 1000 XMLHttpRequest objects alive (probe build of the spike). Full WPT on this stack, release builds with servo-quickjs ed76452, 58,101 tests, then 3 reruns per engine of every difference: outside the WebAssembly-dependent tests, QuickJS is consistently worse only in the three autoplay-*-permissions-policy tests, two WebGL conformance tests that time out on SpiderMonkey without JIT too, and single subtests of structured-cloning-error-stack and localeCompare (no Intl on desktop). After a review of these fixes, workers also release the pool after each batch, not only before the next one. With servo-quickjs 3286cd6, release build: `./mach smoketest` passes, and 2138 tests (cross-origin objects, WindowProxy, Location, history, windows, forms, structured cloning, WebIDL, DOM, fetch responses, workers) match the full run's QuickJS results, except one subtest that now passes and three tests that are flaky with SpiderMonkey too. Rebased onto 7f6279e (the TimerListener and closed-pipeline leak fixes, and servo#48739, which this stack had carried as a backport): release builds with both engines and a checked-release QuickJS build pass the smoketest without warnings, and 2464 WPT tests (the 2138 above plus timers, iframes and cross-document navigation) match the full run's QuickJS results, except one test now passing, as on SpiderMonkey, and two customizable-select tests that are flaky on both engines (select-appearance-hover crashed once under load and fails 5 of 5 alone on both). `RUSTFLAGS="-D warnings" ./mach check --use-crown`, as the Linux CI job builds, passes: the crown expectation on `MutNullableDom::get_unrooted` went away with the `ptr::read` it covered. AI-assisted: Yes (agent session; agent sessions wrote and tested the js-quickjs commits, and the agent folded them into this patch and added the worker sweep) AI-assisted: Yes (agent session; 2026-10-13 sync -- mechanical conflict resolution in components/servo/Cargo.toml, next to upstream's new default_tooling feature (servo#47255), no semantic change) AI-assisted: Yes (agent session; 2026-10-22 sync -- mechanical conflict resolution, no semantic change: the `js-quickjs` features next to upstream's new `default` lines of servo and servoshell (servo#48934)) AI-assisted: Yes (agent session; 2026-11-09 sync -- the task-end sweep sits in upstream's renamed handle_messages() loop; the feature next to upstream's subtlecrypto (servo#48860)) Signed-off-by: Jonathan Schwender <[email protected]>
`./mach build --js-engine quickjs`, or `js-engine = "quickjs"` in .servobuild, builds Servo on servo-quickjs, the QuickJS implementation of the mozjs API. mach passes support/quickjs/cargo-config.toml, which patches mozjs to the servo-quickjs commit it pins, to every cargo command of a build configuration, also with `-p`, and enables the js-quickjs feature where it passes features. Before, a QuickJS build needed a hand-written patch in .cargo/config.toml, and the pinned commit lived in quickjs.yml, from where the runner image and the servo-ohos-wpt nightly had to extract it. The patch replaces mozjs in Cargo.lock, so a QuickJS build can't be `--locked`, and a cargo command without the configuration, e.g. from rust-analyzer, switches Cargo.lock back to SpiderMonkey. SpiderMonkey builds are unchanged. quickjs.yml builds with the option, and its servo-quickjs-ref input now replaces the commit in the file. A change under support/quickjs/ runs only the QuickJS build. Fork note: the pinned commit is bumped with mozjs at each sync, as it was in quickjs.yml. Validation: `./mach build --release --js-engine quickjs` built servoshell on servo-quickjs 72fa2b6 (cargo's command had the configuration and js-quickjs; the binary has the QuickJS symbols and no SpiderMonkey ones) and `xvfb-run ./mach smoketest --release` passed. With a nonexistent extra `--config`, mach printed the expected cargo commands for `--js-engine quickjs`, for js-engine = "quickjs" in .servobuild, for no option (unchanged) and for `--js-engine spidermonkey` overriding .servobuild; an unknown value in .servobuild is an error. `./mach check --js-engine quickjs -p servo-url` left the QuickJS Cargo.lock. `./mach test-scripts` and `./mach test-tidy` pass; actionlint reports for quickjs.yml only its two findings on ohos-main. AI-assisted: Yes (agent session; written by the agent, which also ran the builds and checks above) AI-assisted: Yes (agent session; 2026-10-22 sync -- upstream servo#48934 no longer adds `media-gstreamer` in mach (it is a default feature now; dummy-media builds switch to `--no-default-features` + `default_base`): the `js-quickjs` feature is appended after that block) Signed-off-by: Jonathan Schwender <[email protected]>
This change enables GStreamer by default on all platforms other than
Android and OHOS in an effort to try to make
./mach builddo the samething as
cargo build. There is more work to do here, but this is animportant step.
Testing: There really isn't any automated testing for this kind of change.
Closes: #30420.