Repository navigation
feat(util): move screenshot pixel work into a Rust addon, off the JavaScript thread (ENG-1543) #2341
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
kdy1
wants to merge
65
commits into
main
Choose a base branch
from
kdy1/rust-e2e-util-package
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+25,849
−642
Open
feat(util): move screenshot pixel work into a Rust addon, off the JavaScript thread (ENG-1543) #2341
Changes from all commits
Commits
Show all changes
65 commits
Select commit
Hold shift + click to select a range
3f44ec7
feat(util): add the e2e-util crate and the @e2e-dev/util package (ENG…
kdy1 c36a190
test(util): hold the addon to the reference on browser screenshots, a…
kdy1 08eddb4
perf(util): benchmark the addon against the JavaScript it replaces (E…
kdy1 56463e3
feat(core): move screenshot pixel work to @e2e-dev/util (ENG-1543)
kdy1 7cc4667
docs: describe crates/ and @e2e-dev/util (ENG-1543)
kdy1 742ef45
ci: build and check the Rust workspace, and pack @e2e-dev/util in the…
kdy1 48e51d9
fix(util): refuse oversized images before allocating, and copy input …
kdy1 731eeda
fix(core): report a screenshot that does not decode as UNSUPPORTED_CA…
kdy1 54a7615
fix(util): keep images alive through their native calls, and credit p…
kdy1 1be7541
ci: build @e2e-dev/util where core is built alone, and run the addon …
kdy1 fd70466
ci: build @e2e-dev/util and its addon before core in the Electron job…
kdy1 8f28554
feat(util): ship the addon in eight platform packages (ENG-1543)
kdy1 30546f6
ci: build, check, and load @e2e-dev/util's addon on each platform, an…
kdy1 a8f34ae
fix(ci): keep the example install script's comment free of apostrophe…
kdy1 a6b1d20
fix(e2e): fail a cut-off screenshot as unreadable before reporting a …
kdy1 89fda23
chore(util): carry the notice of the FreeBSD cube root the addon port…
kdy1 ba5b9af
test(util): list tracked PNGs NUL-separated in the equivalence suite …
kdy1 6447c3f
fix(util): leave sockets out of the report that tells glibc from musl…
kdy1 34b3cce
ci: run the benchmarks when .cargo/config.toml changes (ENG-1543)
kdy1 11f9863
ci: keep the pack job's comment above the pack job in examples.yml (E…
kdy1 6cd96d9
chore(mobile): restore the escaped contributor name in package.json (…
kdy1 204e1fa
docs: say the build needs rustup, and build util before core in the f…
kdy1 f826185
perf(util): compare pixels through a view of each image, not a copy (…
kdy1 880d438
perf(util): check the size of NativeImage.fromRgba's input before cop…
kdy1 d81d2a2
fix(core): keep no locator screenshot when the attempt is cancelled d…
kdy1 c120e1a
docs: say mobile loads the util addon with the engine, and which util…
kdy1 5a0d9c7
build: opt the desktop crate out of the workspace lints explicitly (E…
kdy1 e1b0428
fix(e2e): write no screenshot when the attempt is cancelled during it…
kdy1 f9f106e
docs: say what a mobile project without the util addon fails with (EN…
kdy1 255be46
fix(mobile): keep no screenshot when the operation is cancelled while…
kdy1 5c7b8da
test(e2e): cancel the screenshot tests inside the native call they co…
kdy1 9f74741
fix(scripts): leave an addon in place when place-native is given the …
kdy1 847f55d
fix(scripts): pack the install smoke's util platform package from a c…
kdy1 8156758
fix(scripts): import the installed util package by file URL in the in…
kdy1 59e4166
docs(changeset): say how a mobile project fails on a platform with no…
kdy1 fa2b3ec
fix(mobile): race screenshot masking with cancellation only, not the …
kdy1 ae9d0a9
ci: register the util-native runner labels with actionlint (ENG-1543)
kdy1 cad1ca6
fix(util): type the addon's returned bytes as Uint8Array, not Buffer …
kdy1 72a731d
fix(util): report a checkout build that fails to load, not the absent…
kdy1 88b84b7
perf(util): start NAPI-RS's runtime with one scheduler thread, not on…
kdy1 3456fed
fix(util): time the old mobile mask as the engine ran it in the bench…
kdy1 dc63510
fix(util): report the size of the addon the benchmark loaded (ENG-1543)
kdy1 c1c97ef
docs: name UTIL_NATIVE_DIR in AGENTS.md's canary steps (ENG-1543)
kdy1 d36e098
fix(util): report a platform package without its addon as failing to …
kdy1 d307e62
fix(util): keep a checkout build's load failure as the cause beside a…
kdy1 929a10f
fix(util): give install advice only when the platform package is not …
kdy1 a11940e
fix(util): compare two buffers on both sides of the identical-image b…
kdy1 b351a56
fix(util): keep util's benchmark from importing @e2e-dev/mobile (ENG-…
kdy1 0b3d7f0
docs: name the screenshot calls that need the util addon (ENG-1543)
kdy1 7fefac7
docs: say when core loads the util addon: on pixel work, not every sc…
kdy1 dc28639
ci(util): build the glibc addons on glibc 2.28, not Ubuntu 22.04 (ENG…
kdy1 2d4251b
Merge origin/main into kdy1/rust-e2e-util-package (ENG-1543)
kdy1 493396a
fix(util): point util's vitest at the vite main now pins (ENG-1543)
kdy1 bc26254
fix(core): stop waiting for native image work once the attempt is can…
kdy1 2314f31
refactor(util): keep Rgba's fields private behind checked constructor…
kdy1 366b566
test(util): hold processPng's PNG output and fromRgba's size check to…
kdy1 b131721
test(util): expect the platform package's failure only where one exis…
kdy1 fac602f
fix(util): refuse a --runs the benchmark cannot use, and drop the p95…
kdy1 625eb1f
ci: run the benchmarks for util's crates only, not every crate (ENG-1…
kdy1 3e2e79f
docs(util): state that the macOS builds need macOS 13 or later (ENG-1…
kdy1 4269fcc
docs(util): say the comparison is bit-exact with pixelmatch on Node 2…
kdy1 34b1445
Merge origin/main into kdy1/rust-e2e-util-package (ENG-1543)
kdy1 321fd01
fix(core): end a judgment's wait for model-sized pixels at its deadli…
kdy1 16c74c9
refactor(core): make every image call take the signal that ends its w…
kdy1 b670afd
Merge origin/main into kdy1/rust-e2e-util-package (ENG-1543)
kdy1 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| # How the Node addons in crates/ link their C runtime on the targets where the default does not fit an addon. | ||
|
|
||
| # musl defaults to a static C runtime, with which rustc drops a cdylib; the addon links the musl that the Node | ||
| # process loading it already has. | ||
| [target.x86_64-unknown-linux-musl] | ||
| rustflags = ["-C", "target-feature=-crt-static"] | ||
|
|
||
| [target.aarch64-unknown-linux-musl] | ||
| rustflags = ["-C", "target-feature=-crt-static"] | ||
|
|
||
| # MSVC defaults to the C runtime DLLs of the Visual C++ Redistributable, which a Windows machine with Node may not | ||
| # have; the addon carries its own. | ||
| [target.x86_64-pc-windows-msvc] | ||
| rustflags = ["-C", "target-feature=+crt-static"] | ||
|
|
||
| [target.aarch64-pc-windows-msvc] | ||
| rustflags = ["-C", "target-feature=+crt-static"] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| --- | ||
| '@e2e-dev/util': patch | ||
| '@e2e-dev/util-darwin-arm64': patch | ||
| '@e2e-dev/util-darwin-x64': patch | ||
| '@e2e-dev/util-linux-arm64-gnu': patch | ||
| '@e2e-dev/util-linux-arm64-musl': patch | ||
| '@e2e-dev/util-linux-x64-gnu': patch | ||
| '@e2e-dev/util-linux-x64-musl': patch | ||
| '@e2e-dev/util-win32-arm64-msvc': patch | ||
| '@e2e-dev/util-win32-x64-msvc': patch | ||
| '@e2e-dev/core': patch | ||
| 'e2e': patch | ||
| '@e2e-dev/mobile': patch | ||
| --- | ||
|
|
||
| Screenshot pixel work (PNG decoding and encoding, resizing for the model, `toHaveScreenshot` captures and comparisons, `locator.screenshot()` crops, and mobile masking) now runs in the new `@e2e-dev/util` native addon, off the JavaScript thread. npm installs its build for your platform with it, from `@e2e-dev/util-<platform>`: macOS on arm64 and x64, Linux on x64 and arm64 with glibc 2.28 or later or with musl, and Windows on x64 and arm64. On any other platform, `toHaveScreenshot`, `locator.screenshot()`, and an agent screenshot the runner has to resize fail with `IMAGE_CODEC_UNAVAILABLE`, naming the platforms there are (a plain `app.screenshot()` saves the engine's PNG and still works), and a config that uses `@e2e-dev/mobile` fails to load, since the engine loads the addon when it loads. The output is byte for byte what `@napi-rs/image` and `pixelmatch` produced, so stored screenshots do not change. `@napi-rs/image` and `pixelmatch` are no longer dependencies. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,5 @@ | ||
| self-hosted-runner: | ||
| labels: | ||
| - blacksmith-4vcpu-ubuntu-2404 | ||
| - blacksmith-4vcpu-ubuntu-2404-arm | ||
| - blacksmith-6vcpu-macos-26 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,54 @@ | ||
| #!/bin/sh | ||
| # Builds a native addon for a glibc target inside a manylinux_2_28 container | ||
| # (AlmaLinux 8, glibc 2.28), so the addon asks for no glibc newer than 2.28, | ||
| # the oldest that Node 22's and 24's own Linux builds run on (Debian 11, | ||
| # Ubuntu 20.04, RHEL 8). It checks the build, leaves it in its package, and, | ||
| # given a probe script and its arguments, runs that in the same container, | ||
| # so the addon is loaded on glibc 2.28 itself. The workflow runs it as | ||
| # docker run --rm -v "$PWD:/work" -w /work quay.io/pypa/manylinux_2_28_<arch>@<digest> sh .github/scripts/build-glibc.sh <addon> <target> [<probe> <args>...] | ||
| # on a runner of the target's architecture. | ||
| # | ||
| # rustup-init is a fixed release checked against the SHA-256 recorded here, | ||
| # the same version `.github/actions/rust-toolchain` pins for the other runners. | ||
| # The image has no Node, so the scripts run in Node's official build, a fixed | ||
| # release checked against the SHA-256 in https://nodejs.org/dist/v<version>/SHASUMS256.txt. | ||
| set -eu | ||
|
|
||
| addon="$1" | ||
| target="$2" | ||
| shift 2 | ||
| RUSTUP_VERSION=1.29.3 | ||
| NODE_VERSION=26.13.1 | ||
| case "$(uname -m)" in | ||
| x86_64) | ||
| host=x86_64-unknown-linux-gnu rustup_sha256=b1c8cb14e30889e7e2999e6b69e62d9e9b9ffc0f4df8180564d306d9680e6c55 | ||
| node_arch=x64 node_sha256=518674de2b621728a5e4486f5fb3b7d2900bb3cc4aa97969edaa463db99f9778 ;; | ||
| aarch64) | ||
| host=aarch64-unknown-linux-gnu rustup_sha256=9f608c142e0e38a78957d0661ba1dfaf0b6fb37184cfaa4b9a0aa57af6184282 | ||
| node_arch=arm64 node_sha256=80a330b35415382878df18d41afbd106ea89bfb3be0087d6608e289a14c5cc7d ;; | ||
| *) echo "no pinned rustup-init or Node for $(uname -m)" >&2; exit 1 ;; | ||
| esac | ||
| if [ "$host" != "$target" ]; then | ||
| echo "$target builds on a runner of its own architecture, not $host" >&2 | ||
| exit 1 | ||
| fi | ||
|
|
||
| curl --proto '=https' --tlsv1.2 -sSf --retry 3 -o /tmp/rustup-init \ | ||
| "https://static.rust-lang.org/rustup/archive/$RUSTUP_VERSION/$host/rustup-init" | ||
| echo "$rustup_sha256 /tmp/rustup-init" | sha256sum -c - | ||
| chmod +x /tmp/rustup-init | ||
| /tmp/rustup-init -y --no-modify-path --default-toolchain none | ||
| export PATH="$HOME/.cargo/bin:$PATH" | ||
|
|
||
| node_dir="node-v$NODE_VERSION-linux-$node_arch" | ||
| curl --proto '=https' --tlsv1.2 -sSf --retry 3 -o "/tmp/$node_dir.tar.gz" \ | ||
| "https://nodejs.org/dist/v$NODE_VERSION/$node_dir.tar.gz" | ||
| echo "$node_sha256 /tmp/$node_dir.tar.gz" | sha256sum -c - | ||
| tar -xzf "/tmp/$node_dir.tar.gz" -C /tmp | ||
| export PATH="/tmp/$node_dir/bin:$PATH" | ||
|
|
||
| node scripts/native/build-native.ts "$addon" --target "$target" | ||
| node scripts/native/check-build.ts "$addon" "$target" | ||
| if [ "$#" -gt 0 ]; then | ||
| node "$@" | ||
| fi |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| #!/bin/sh | ||
| # Builds a native addon for a musl target inside an Alpine container, where | ||
| # the addon links the musl a user's Node there runs on, and checks the build | ||
| # and leaves it in its package for the next step to load. The workflow runs it as | ||
| # docker run --rm -v "$PWD:/work" -w /work node:<version>-alpine@<digest> sh .github/scripts/build-musl.sh <addon> <target> | ||
| # on a runner of the target's architecture. | ||
| # | ||
| # rustup-init is a fixed release checked against the SHA-256 recorded here, | ||
| # the same version `.github/actions/rust-toolchain` pins for the other runners. | ||
| set -eu | ||
|
|
||
| addon="$1" | ||
| target="$2" | ||
| RUSTUP_VERSION=1.29.3 | ||
| case "$(uname -m)" in | ||
| x86_64) host=x86_64-unknown-linux-musl sha256=1552169aba2836777136ccff7a381e95c17233b5d8250cd5e10ae3cb971bfcfc ;; | ||
| aarch64) host=aarch64-unknown-linux-musl sha256=956deacdc27ab82ae7ac821d5d3e9e95e4795d476d17efe99743bb8531ca1031 ;; | ||
| *) echo "no pinned rustup-init for $(uname -m)" >&2; exit 1 ;; | ||
| esac | ||
| if [ "$host" != "$target" ]; then | ||
| echo "$target builds on a runner of its own architecture, not $host" >&2 | ||
| exit 1 | ||
| fi | ||
|
|
||
| # The linker and C runtime objects a cdylib needs. | ||
| apk add --no-cache build-base curl | ||
| curl --proto '=https' --tlsv1.2 -sSf --retry 3 -o /tmp/rustup-init \ | ||
| "https://static.rust-lang.org/rustup/archive/$RUSTUP_VERSION/$host/rustup-init" | ||
| echo "$sha256 /tmp/rustup-init" | sha256sum -c - | ||
| chmod +x /tmp/rustup-init | ||
| /tmp/rustup-init -y --no-modify-path --default-toolchain none | ||
| export PATH="$HOME/.cargo/bin:$PATH" | ||
|
|
||
| node scripts/native/build-native.ts "$addon" --target "$target" | ||
| node scripts/native/check-build.ts "$addon" "$target" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.