Skip to content

ci(viewer): build the WASM once per run, and test the file Deploy viewer publishes (#1457) - #1458

Merged
DrunkOnJava merged 4 commits into
mainfrom
ci/viewer-wasm-built-once
Nov 5, 2026
Merged

DrunkOnJava merged 4 commits into
mainfrom
ci/viewer-wasm-built-once

Conversation

@DrunkOnJava

@DrunkOnJava DrunkOnJava commented Nov 5, 2026 •

Copy link
Copy Markdown
Owner

Summary

The viewer's WASM and gen-fixture are built once per run, and Deploy viewer's browser tests and measurement run on the very WASM it publishes.

Motivation

#1457, item "The viewer builds its WASM once per run, and Deploy viewer tests what it publishes". Measured in that issue's audit of recent runs: each of CI's three viewer legs built the WASM and gen-fixture itself (about 2 minutes of its 5.5 to 6.6), and Deploy viewer built the WASM three times (build 4.1, tests 4.3, measure 3.6 of 27 job-minutes a run). More important than the time: it published the build job's copy while tests and measure each tested a build of their own, so the file published was not a file that was tested.

Changes

  • viewer-test.yml: a build job builds the WASM (release_wasm honoured) and gen-fixture once and uploads pkg/, bin/gen-fixture and wasm.sha256 as a run artifact. Each leg needs it, downloads it, sets the executable bit, puts gen-fixture on PATH, runs gen-fixture --help (the stager would otherwise build gen-fixture itself, since cargo is on the runner image, and pass), prints the WASM's sha256 and fails if it differs from the recorded one. Rust toolchain, rust-cache, wasm-bindgen and wasm-pack steps are gone from the legs. The network-import audit stays in each leg, on the copy it tests; demo staging, Playwright and the tests stay in the legs.
  • The tests serve viewer/dist, not viewer/pkg, so after "Build viewer" each leg also runs tools/ci/check-wasm-in-site.sh: some .wasm in the site must have the recorded sha256. Deploy viewer's build runs the same script on the site it publishes. A bundler that re-encoded or renamed the asset would otherwise pass every leg and fail on main.
  • New workflow_call input wasm_artifact: a caller that built the WASM already passes the artifact's name, and build is skipped. It is not a dispatch input (a dispatched run has no artifact to name, so it builds its own).
  • A skipped leg cannot read as a pass. The legs run unless the run is cancelled (if: !cancelled()), and their first step fails unless build succeeded or was skipped with wasm_artifact given. A result job (legs passed) then fails unless the test job's result is success, so a test job that was skipped, or a legs list that yields no leg, fails the call; ci-ok therefore never sees an all-skipped viewer. The only way a leg does not run is a cancelled run, which ci-ok reads as cancelled.
  • Artifact names: the build's is viewer-build-<12 hex of a sha256 of legs and release_wasm>, so two calls in one run differ. The failure report was playwright-report-<job index>, which is 0 in both of Deploy viewer's calls; it now follows the leg's name (/ and spaces replaced). Every upload, the build's, the report's and the saved-mesh measurement's, has overwrite: true, so a rerun of every job does not fail on a 409.
  • deploy-viewer.yml: build builds gen-fixture beside the WASM as viewer-test.yml does, uploads viewer-build-release before anything is staged, and tests and measure have needs: build and wasm_artifact: viewer-build-release.
  • Deploy viewer's trigger paths now name .github/workflows/viewer-test.yml and .github/actions/**, with the reason in a comment.
  • Comments and docs: viewer-test.yml's header, deploy-viewer.yml's header, docs/maintaining.md and docs/viewer-build-pipeline.md.
  • ci.yml is unchanged: release_wasm: false still selects the fast build and wasm_artifact defaults to empty.
  • Rust-cache keys: the legs restore none now, so no cache step restores nothing. build keeps viewer-wasm and viewer-wasm-fast; Deploy viewer's build keeps viewer-wasm and adds target-native (see "Not measured" below).

Testing

Unit tests are banned in this repository: do not add them. Show the change working end to end on real files instead.

  • tools/check-local.sh passes: N/A, workflow, shell and docs only (no Rust changed). Locally: actionlint reports only the known $/ complaints, zizmor --offline on viewer-test.yml, deploy-viewer.yml and ci.yml finds nothing, shellcheck on the new script finds nothing, and the script was run against a matching, a changed and a missing .wasm.
  • Verified end to end on real Revit files: N/A, CI plumbing. The proof is the runs below.
  • If this touches the IFC exporter: N/A
  • If this is a performance change: before and after are measured below, from job timings of the runs named.

Proofs

Heads: 7ae87737 (first push) and 82fb52a7 (adds the dist check, the two overwrites and a merge of main). The structure of both is the same.

  • Deploy viewer on the branch, run 42092946961, head 82fb52a: success. build ran; the build the WASM job inside tests and measure was skipped, and the legs and legs passed of both calls succeeded; deploy skipped (not main). The WASM's sha256 is e4360cda5fd0050bd5aad645d281b9f2a00de9e8846ddc33ce96f0513315d22f in build, in tests' leg and in measure's leg, and each of the three found that same sha256 in the .wasm of the site it had built, so vite copies the file unchanged.
  • PR's own full run, run 42092901241, head 82fb52a: success. CI passed printed job results: with 21 results, all success, viewer-paths and viewer among them; viewer ran its build the WASM job (2.2 min), the three legs and legs passed. The earlier full run, 42071653521 on head 7ae8773, also passed.
  • viewer-test.yml with legs='[]' (and release_wasm=false), run 42092950916, head 82fb52a: red, not green. No test job was created for the empty matrix and needs.test.result read failure; legs passed failed. build still ran to the end (2.2 min).
  • A wrong artifact name fails the legs. Scratch commit 22ce7074 (a branch, since deleted, that adds a wasm_artifact dispatch input), run 42092956350: build skipped, all three legs failed at the download ("Artifact not found for name: viewer-build-does-not-exist"), legs passed failed, run red.
  • A failed build fails the legs. The same scratch commit with a step in build that exits 1, run 42092960158: build failed, all three legs failed in their first step ("the build job ended failure; there is no WASM to test"), legs passed failed, run red.

Job-minutes and wall time

"Before" is the 12 most recent full CI (pull request) runs of other branches that had the old shape (2026-11-05: 42091450363, 42089961945, 42089583832, 42069752738, 42069162991, 42068363131, 42067703359, 42067234997, 42066197964, 42065433127, 42064122054, 42062387965), and, for Deploy viewer, the 9 successful pushes to main that day (42063967923, 42043964976, 42037978731, 42034472263, 42029351913, 42025959298, 42013240274, 42008824775, 42000482201). "After" is this branch's runs. Times are each job's started-to-completed time from the Actions API; "from the first job" counts from the run's first job start.

CI, a ready pull request:

Before, median (range) After, 42071653521 (7ae8773) After, 42092901241 (82fb52a)
Viewer job-minutes 16.9 (13.4 to 19.2) 12.0 12.7
Whole run job-minutes 68.8 (63.0 to 74.3) 59.7 63.6
Longest leg 7.0 min (5.5 to 8.2) 3.7 min 3.8 min
build the WASM n/a 2.5 min 2.2 min
Longest viewer path: before, the longest leg; after, build start to legs passed end 7.0 min (5.5 to 8.2) 6.4 min 6.3 min
CI passed done, from the first job 514 s (366 to 695) 402 s 507 s
Viewer was the last job before CI passed 8 of 12 runs yes, by 40 s yes, by 77 s

The viewer saves about 4 to 5 job-minutes a run. CI passed did not get slower on these two runs, and the chain through the viewer is no longer than the longest leg was: a leg now takes 2.7 to 3.8 minutes because it no longer builds, and the build job takes 2.2 to 2.5 minutes before it. The second read's estimate of 1 to 1.5 minutes more on that chain did not show. Two runs cannot separate a minute from runner queueing, though: the 82fb52a run shared the runners with the four dispatched runs above and other lanes' runs (its jobs started up to 121 s after the first), which is part of its 507 s; every job of the 7ae8773 run started within 11 s. The viewer is the last job before CI passed in both runs after and in 8 of 12 before, so a later change that shortens the other jobs makes it the critical path.

Deploy viewer (jobs before deploy):

Before, median (range) After, 42092946961 (82fb52a)
Job-minutes 24.9 (20.5 to 29.1) 17.8
build 5.8 min (3.6 to 6.7) 6.3 min
Browser tests leg (before, with its own WASM build) 10.2 to 16.7 min 8.7 min
Saved-mesh measurement leg (before, with its own WASM build) 4.8 to 7.8 min 2.7 min
Wall time until deploy could start 15.3 min (10.4 to 17.3) 15.6 min

Deploy viewer saves about 7 job-minutes a run and takes as long: tests and measure now wait for build, which is a serial step of about 6 minutes that used to run beside them, and the legs no longer carry the 4 minutes of building. One run after, against nine before whose own spread is 7 minutes.

Not measured

  • The Deploy viewer build here compiled gen-fixture cold in 2 min 23 s beside the WASM, whose release build took 5 min 10 s, because the restored viewer-wasm cache (150 MB) holds no target-native. I did not test whether that slows the WASM; a branch run does not save a cache. It should correct itself on main when a push with a changed Cargo.lock saves one with target-native. If it does not, giving Deploy viewer's build a new shared-key would.
  • Only one Deploy viewer run after the change, from a branch; the deploy job and the real Pages publish have not run on this shape.
  • A rerun of every job, which the overwrite: true uploads are for, was not exercised.
  • Whether a rerun of failed jobs after 3 days (the artifact retention) behaves is untested: the artifact is gone by then.

Audit-honesty checklist

  • README / docs reflect the current state after this PR — no claims of features that are not actually shipped in this PR
  • A user-visible change has its entry as a fragment under changelog.d/<section>/: N/A, CI only, no user-visible change
  • If a limitation was resolved, the "Known limitations" / "What works today" section in the relevant docs is updated: N/A
  • If a new limitation was introduced, it is documented in the PR body and in-code: the artifacts expire after 3 days, and Deploy viewer's tests and measurement start after its build (above)
  • Commit messages describe WHAT changed and WHY, not "fix things" or "updates"
  • No emojis in code, docs, or commit messages
  • No private paths, personal email addresses, or internal jargon in committed files
  • If this is a reverse-engineering finding: N/A

Legal and contribution hygiene

  • I agree this work is licensable under Apache-2.0 (see CONTRIBUTING.md)
  • This PR contains no Autodesk proprietary source, decompiled internals, or NDA'd SDK content (see CLEANROOM.md)
  • Any new test fixtures use synthetic values: N/A, none added

Breaking changes

None.

Screenshots or output samples

N/A.

Related issues

Refs #1457

…wer publishes (#1457)

viewer-test.yml gets a `build` job that builds the WASM (honouring
release_wasm) and gen-fixture once and uploads them with the WASM's sha256.
The legs download them, set the executable bit, put gen-fixture on PATH, run
it, print the WASM's sha256 and fail when it differs from the recorded one.
They used to build both themselves, about 2 minutes of each leg.

A caller that built the WASM already passes the artifact's name as
`wasm_artifact`, and `build` is skipped. Deploy viewer's `build` job uploads
the release WASM and gen-fixture before staging, and its `tests` and
`measure` jobs need `build` and pass the name, so they test the bytes that
are published; `build` checks the site holds that WASM. Before, the three
jobs each built it and tested builds of their own.

The legs run unless the run is cancelled and fail first when `build` did not
succeed; a `result` job fails unless every leg succeeded, so a skipped leg
cannot read as a pass in `CI passed`. Artifact names no longer collide when
Deploy viewer calls the workflow twice. Deploy viewer's trigger paths now
name viewer-test.yml and .github/actions.

Refs #1457
@DrunkOnJava DrunkOnJava added the ready-when-green Draft whose code is complete: marked ready for review once its fast CI passes label Nov 5, 2026
@DrunkOnJava
DrunkOnJava marked this pull request as ready for review November 5, 2026 17:08
@DrunkOnJava DrunkOnJava removed the ready-when-green Draft whose code is complete: marked ready for review once its fast CI passes label Nov 5, 2026
…WASM, and every upload can be rerun (#1457)

The legs checked the sha256 of viewer/pkg/rvt_bg.wasm before "Build viewer",
but the tests serve the viewer/dist that step produces, and only Deploy
viewer's build checked that copy. A bundler bump that re-encoded or renamed
the asset would have passed every leg and CI passed, then failed on main.
tools/ci/check-wasm-in-site.sh now does the check, and both the legs and
Deploy viewer's build run it after the vite build.

The Playwright report and the saved-mesh measurement uploads get
`overwrite: true`, as the build uploads have, so a rerun of every job whose
first attempt uploaded them does not fail on a 409.

Refs #1457
@DrunkOnJava
DrunkOnJava merged commit fb48606 into main Nov 5, 2026
37 checks passed
@DrunkOnJava
DrunkOnJava deleted the ci/viewer-wasm-built-once branch November 5, 2026 20:15
DrunkOnJava added a commit that referenced this pull request Nov 5, 2026
…ions (#1457) (#1491)

## Summary

The last piece of #1457: the Rust install, which was thirty-two copies
of one script, is a composite action, `.github/actions/setup-rust`, and
the three copies of the wasm-bindgen steps are another,
`.github/actions/wasm-tools`. Nothing else changes: the same toolchain
in every job, the same rust-cache keys, the same release path.

## Motivation

#1457's last box: "the Rust install is repeated 27 times and the
`wasm-bindgen` steps 3 times". By `git grep` today the install is 32
steps in 10 workflows (`ci.yml` 17, `publish.yml` 5, `measure.yml` 2,
`scheduled-checks.yml` 2, and one each in `corpus-nightly.yml`,
`deploy-viewer.yml`, `fuzz.yml`, `perf-budget.yml`,
`release-binaries.yml` and `viewer-test.yml`), each a copy of `rustup
toolchain install`, `rustup default`, two `echo ... >> $GITHUB_ENV`
lines and `rustc --version`, differing in the toolchain, one component,
one target and whether the toolchain becomes the default.

## Changes

- `.github/actions/setup-rust` (new): inputs `toolchain` (default
`stable`), `component`, `target` and `make-default` (default `"true"`).
One `shell: bash` step, inputs through `env:` (no expression in the
script), the same `--profile minimal --no-self-update`, then `rustup
default` unless `make-default` is `"false"`, then `CARGO_INCREMENTAL=0`
and `CARGO_TERM_COLOR=always` into `$GITHUB_ENV`, then `rustc
+<toolchain> --version`. No third-party action inside it.
- `.github/actions/wasm-tools` (new): the "Locked wasm-bindgen version"
step, byte for byte, and `taiki-e/install-action` at the same SHA and
the same `[email protected]` and locked `wasm-bindgen`, with the comment
about the DNS outage (CI run 41954251714) moved into the action. Used by
`viewer-test.yml`, `deploy-viewer.yml` and `publish.yml`.
- All 32 sites use `setup-rust` (33 uses: the semver job takes a second
for its nightly), as `uses: $/.github/actions/setup-rust` with only the
inputs that differ from the default: `component: rustfmt` and `clippy`
(fmt, clippy), `toolchain: ${{ matrix.rust }}` (the test matrix),
`toolchain: nightly-2026-10-01` (the docs.rs previews, the fuzz-check
job), `toolchain: ${{ env.NIGHTLY }}` (Fuzz), `toolchain: nightly` (the
floating docs.rs build), `target: i686-unknown-linux-gnu`, `target:
wasm32-unknown-unknown` (three), `target: ${{ matrix.target }}`
(release-binaries), `target: ${{ runner.os == 'macOS' && matrix.target
|| '' }}` (publish's wheels, still `if: runner.os != 'Linux'`).
- Three sites install a toolchain they do not make the default, with
`make-default: "false"`: the fuzz-check job (`cargo
+nightly-2026-10-01`, its rust-cache keyed by the default stable's
`rustc -vV`), the MCP server's 1.88 check (its own step now, `cargo
+1.88 check ...` after the install), and the public API listing's
nightly in the semver job (a second use of the action after the stable
one).
- Deploy viewer's trigger already names `.github/actions/**` and
`viewer-test.yml` (#1458), which covers both new actions, so it is
unchanged.
- `docs/maintaining.md`: a section on the two actions and on why the
environment they set is not tidying.

## What is the same, and what is not

Same: every job's toolchain, component and target; the default
toolchain; `CARGO_INCREMENTAL=0` and `CARGO_TERM_COLOR=always` before
the cache steps; the dated nightly stays at its sites; `shell: bash` on
the composite steps; `rustup` flags.

Swatinem/rust-cache hashes the default toolchain's `rustc -vV` and every
`CARGO*`, `CC*`, `CFLAGS`, `CXX*`, `CMAKE*` and `RUST*` variable into
its key (`src/config.ts` at the pinned SHA), so a change of default
toolchain or of one of those variables in a job that restores a cache
would start it from nothing. None changes:

- every site that restores a cache set both variables and made its
toolchain the default, as the action does;
- the sites that differ are `i686-overflow` (no `CARGO_TERM_COLOR`
before, which `ci.yml`'s workflow-level `env` sets for every step
anyway), `docs-rs-nightly` of `scheduled-checks.yml` (the same, from
that file's workflow-level `env`; no cache there) and the `Audit` jobs
of `scheduled-checks.yml` (no `CARGO_INCREMENTAL` before; they compile
nothing, their tools are prebuilt, and restore no cache): these two
files' sites gain a variable that is already set or that nothing reads;
- the log gains `rustc +<toolchain> --version` where a step printed none
(fuzz-check), and shows the install as one step with its inner steps.

## Left alone

Nothing in the issue's list was left. `publish.yml`'s `publish-crate`
job runs only at a tag, so no dispatch runs its install step; it is the
same invocation (`setup-rust` with no inputs) that
`release-source-smoke` runs in a dispatch.

## Testing

Unit tests are banned in this repository: do not add them. Show the
change working end to end on real files instead.

- [ ] `tools/check-local.sh` passes. N/A: CI-only change; no local
compute on this lane.
- [ ] Verified end to end on real Revit files. N/A: no Rust or reader
change.
- [ ] If this touches the IFC exporter. N/A.
- [ ] If this is a performance change. N/A.

What was run on this head (`13aa7f41`):

- `python3 tools/ci/check-workflows.py`: 0 errors, 0 warnings; 65 jobs
run steps in 17 workflows, `PENDING` empty, and 67 uses of this
repository's own actions and workflows, whose files exist and whose
`with:` names only inputs they declare (the `target`, `toolchain`,
`component` and `make-default` of `setup-rust`). `actionlint` exits 0.
- `zizmor` 1.32.0 offline over `.github` on this head and on
`origin/main`: 45 findings each (2 ignored, 37 suppressed, 6 medium, all
the Dependabot 3-day cooldown), none in the new actions or the changed
steps, and no inline suppression removed. The repository's own
`zizmor.yml` runs 1.30.1 on this pull request.
- No inline Rust install is left: `git grep "rustup toolchain
install\|rustup default" -- .github` finds only the action's own.
- rust-cache keys, before: the `Cache Key` lines of the latest CI run on
`main` (42120229711, at `16682a7a`, this branch's base): clippy
`v0-rust-clippy-Linux-x64-cdee7d24-2ff012fc`, doc
`v0-rust-doc-Linux-x64-0c88e82e-2ff012fc`, the shared
`v0-rust-ci-release-Linux-x64-cdee7d24-2ff012fc` (Corpus health, MCP on
Einhoven, Writer patch corpus, IfcOpenShell, bench and the Ubuntu stable
build), `-1bcc85bf-` (MSRV), the macOS and Windows builds,
`v0-rust-ci-i686-Linux-x64-3f01e9d1-2ff012fc`,
`v0-rust-ci-docs-rs-Linux-x64-ab072a77-2ff012fc`,
`v0-rust-ci-fuzz-check-Linux-x64-cd142760-c3664f70` and the viewer's
`v0-rust-viewer-wasm-fast-Linux-x64-a74c6f26-2ff012fc`; Deploy viewer's
build on `main` (42112535877)
`v0-rust-viewer-wasm-Linux-x64-a74c6f26-2ff012fc`; Measure's build on
`main` (42121438036) `v0-rust-measure-Linux-x64-a74c6f26-2ff012fc`. The
runs on this head are compared against them (below).

Runs on this head (`13aa7f41`), none read yet: not yet measured on this
head until they are.

- The draft's fast CI, run 42122477187: clippy and doc (component and
default), the Ubuntu stable and MSRV builds (`toolchain: ${{ matrix.rust
}}`), Corpus health and the MCP server on Einhoven (their rust-cache
keys), the env config lint and the PII guard. At the first look `fast /
cargo fmt`, `env config lint`, `PII guard` and both zizmor runs had
passed.
- Measure, which this pull request starts itself because it changes
`measure.yml` (run 42122476881, Build head and Build base): the build
job's install and cache. I dispatched no Measure of my own on top of it,
since the filtered run asked for would build the same job again.
- Release binaries, which a change to `release-binaries.yml` starts on a
pull request (run 42122476923): the five targets, Windows, both macOS
(one cross-compiled and smoked under Rosetta) and both Linux musl legs,
with `target: ${{ matrix.target }}`.
- Publish, dispatched on the branch (run 42123198927; a dispatch
publishes nowhere, `test-pypi` stays false): the preflight, the wheel
builds on all three systems (the non-Linux `if:` and the macOS target),
the source install, the docs.rs preview on the dated nightly and the
viewer smoke (`target: wasm32-unknown-unknown` and `wasm-tools`). Not
run by it: `publish-crate`, which runs at a tag only; its install is the
invocation `release-source-smoke` runs.
- Deploy viewer, dispatched on the branch (run 42123203945; it deploys
nothing from a branch): its build job (`viewer-wasm`'s cache key,
`wasm-tools`) and the two calls of `viewer-test.yml`.
- The full CI on ready: every other site, and the keys compared with the
list above: `python3 cachekeys.py <main run> <this run>` over each job's
`Cache Key:` lines (`.claude/scripts/cache-keys.py RUN_A RUN_B`, kept
out of the tree; the baselines are CI run 42120229711, Deploy viewer run
42112535877 and Measure run 42121438036, all on `main`) reports the jobs
whose key differs; the expected result is none.

## Audit-honesty checklist

- [x] README / docs reflect the current state after this PR
(`docs/maintaining.md`)
- [ ] A user-visible change has its entry as a fragment under
`changelog.d/<section>/`. N/A: CI only, as agreed for #1457.
- [ ] If a limitation was resolved, the "Known limitations" section is
updated. N/A.
- [x] If a new limitation was introduced, it is documented in the PR
body (none)
- [x] Commit messages describe WHAT changed and WHY
- [x] No emojis in code, docs, or commit messages
- [x] No private paths, personal email addresses, or internal jargon in
committed files
- [ ] Reverse-engineering finding. N/A.

## Legal and contribution hygiene

- [x] I agree this work is licensable under Apache-2.0
- [x] This PR contains no Autodesk proprietary source, decompiled
internals, or NDA'd SDK content
- [x] Any new test fixtures use synthetic values

## Breaking changes

None.

## Screenshots or output samples

See Testing.

## Related issues

Closes #1457
DrunkOnJava added a commit that referenced this pull request Nov 6, 2026
…ead on selection (#35) (RE-207) (#1468)

## Summary

The viewer's info panel lists a selected element's saved parameters
(RE-207): instance, then type, named ones first, nameless ones behind a
fold grouped by why they have no name (#255), each row saying where its
parameter is defined. They are read for that element only, on selection,
by a new `savedParameters` binding in a worker of its own; the open and
every export are unchanged. File Status's Parameters row no longer says
the rest are "still to be decoded".

**Nothing is requested once the first file is open** (Griffin,
2026-11-05, "Keep the claim, no request"): selecting an element,
exporting IFC, plan or glTF, and opening the file again fetch nothing,
and a page taken offline after it loaded does all of them.

## Motivation

The last open acceptance item of #35 that is not blocked: "Viewer info
panel displays them in readable form". The CLI, Python and IFC
(`--revit-property-sets`) expose the saved parameters; the viewer showed
a count and a sentence that RE-207 had already made wrong.

## Changes

- `rvt-wasm/src/lib.rs`, `rvt-wasm/Cargo.toml`, `Cargo.lock`:
`savedParameters(bytes, ids, limits)` returns JSON text: each entry is
`serde_json::to_value` of the parameter
`native_element_parameters::read` gives, the call `rvt-elements` makes,
with the release and how far it is read. `rvt` gets `unstable-research`
here, which "adds paths and changes nothing else" (`src/research.rs`);
no file under `src/` changes, so no export can move, and `arm.sh`'s
`src/` gate path does not match `rvt-wasm/src/`. **The result's keys are
a 1.0-stable surface** (`RELEASE.md`): `release`, `release_read`,
`release_experimental`, `releases_read`, `releases_measured`,
`elements`, `unresolved_family_slots`,
`instance_parameters_without_value`. I chose them to say what they mean
(not the research module's "native"): the read range, the measured range
(Revit 2015 to 2022 are read experimentally, RE-281), and what could not
be listed. `ids` is a `Float64Array`.
- `viewer/src/parameters-worker.ts`, `viewer/src/saved-parameters.ts`,
`viewer/src/wasm-failure.ts` (new; the out-of-memory test both workers
use), `viewer/src/worker.ts`, `viewer/src/main.ts`,
`viewer/src/styles.css`, `viewer/index.html`, `viewer/src/env.d.ts`: the
panel group and its states (loading, ready, empty, release not read,
experimental release, no ElementId, error with Try again,
read-when-asked), the page's map of answers, focus and a live region,
the status row text, and the no-request mechanics below. The "Not
recovered" note for an element with no IFC property set now says "IFC
property sets".
- `viewer/tests/parameters-row.spec.ts`,
`viewer/tests/no-network.spec.ts`,
`viewer/tests/worker-failures.spec.ts` (now patches the inline worker's
blob where it routed a worker URL), `viewer/tests/folded-pieces.spec.ts`
(prints what a read does and what the page keeps on the BIM4LCA office,
and fails if the read errors).
- `.github/workflows/viewer-test.yml`,
`.github/workflows/deploy-viewer.yml`: after #1458, `--bin rvt-elements`
is built beside `gen-fixture` in the `build` job, copied into the
artifact and checked to run in each leg; Deploy viewer builds and
uploads its own artifact for `tests` and `measure`, so it carries the
binary the same way. A local `pnpm test:browser` needs `rvt-elements` on
PATH (`viewer/README.md`); the `parameters-row` specs skip without it
locally and fail in CI.
- Docs: `docs/viewer-api.md`, `docs/viewer-privacy-posture.md` (the CSP
change, below), `README.md` (13 bindings), `docs/status.md`,
`docs/support-matrix.json` (it also drops the "wall's or floor's type
parameters are not joined" caveat RE-256 made stale),
`docs/evidence.md`, `docs/export-diagnostics.md`, `docs/user-guide.md`,
`docs/viewer-build-pipeline.md`, `docs/maintaining.md`,
`viewer/README.md`, and
`changelog.d/added/35-viewer-saved-parameters.md`.

## Design

**A worker of its own, nothing resident.** `extract` is a pass over the
file, so the read is lazy, per selected element. The open's worker keeps
no `RevitFile` and no bytes: a held handle would keep the file's bytes
and every partition it inflates for the session, and its reads would
hold up the panel (Core Interior's take seconds). Instead the page opens
a worker for one element, which reads the `File` the page already holds,
calls the binding, answers and is terminated, or is terminated at once
when another element, a storey or a scaffold panel replaces the group.
wasm linear memory only grows, so ending the worker gives a read's
memory back. A worker the browser ends with no word (no event) is found
by a Web Lock it holds, so "Reading" cannot show for ever.

**No request once the file is open; the CSP change.** The page's
`worker-src` was `'self'`; it is now `'self' blob:`, and nothing else in
the policy moves (`docs/viewer-privacy-posture.md` says so and why).
Both workers (the open's and the reader) are bundled into the page
(`?worker&inline`) and start from blob URLs; the decoder's glue is a
static import (the main thread's exports used to `import()` it, and
fetch the wasm, at the first export click). The first open's worker
fetches the wasm once, compiles it and hands the module to the page,
which keeps it: the next open (another phase, the saved-mesh toggle, the
large-model retry), the readers (`initSync({ module })`) and the main
thread's exports (`default({ module_or_path })`; the main thread does
not allow `initSync` of a large module) start from it. The lazy loads in
`viewer/src` that could run after the open were:
`import('../pkg/rvt.js')` (static now), `new Worker(new
URL('./worker.ts', ...))` (inline now), the worker's `fetch(new
URL('../pkg/rvt_bg.wasm', ...))` (the page resolves the URL once, and
fetches only at the first open). Opening a gallery demo still fetches
the demo, which is an open.

**First page load.** The page's one script is 999.56 kB (271.47 kB
gzipped) against 959.29 kB (262.82 kB) in the build of `d1de8adf`: 40.27
kB, 8.65 kB gzipped, more, mostly the glue and the two workers it used
to fetch later; the built site holds one script, one stylesheet and the
wasm.

**When a selection is read on its own.** A read has taken 0.74 to 1.04
times the open's wasm memory, and the ratio rises with the file
(Einhoven 23 MiB, Core Interior 326, the office 910). Nothing above the
office has been measured, so a selection is read on its own only while
the wasm memory the page holds (the open's, plus the main thread's
instance if an export made one) is at most 1 GiB (a quarter of
`?memoryCeilingBytes=` where that lowers the 4 GiB ceiling), and above
that the panel asks first with a button whose copy says clicking may
close the tab: a renderer out of memory takes the tab and the model with
it, with no error. After a read that ran out of memory, or a worker that
went without a word, that file is read only when asked. This replaces
the rule that two instances stay inside the ceiling, which extrapolated
past what is measured.

**What the page keeps.** Each element's answer, in a map on the page: at
most 64 (`?parametersRemembered=` lowers it for the test), the least
recently selected going first, emptied when a file is opened. Selecting
an element again starts no worker. On the office after the test's
selections it held 2 answers, 4,654 characters of JSON (the entries are
small; the answers there have 8 entries).

## Testing

Unit tests are banned in this repository: none added. Measured in
**Viewer tests run 42125048710**, dispatched on head
`3146f14e6fcf221adc4f632ac1a5cfa31a3b885d` (the merge of main with
#1457's changes included), `release_wasm=false`, on a CI runner: success
in all three legs, `check-wasm-in-site.sh` finding the one wasm sha256
in the site in each. **Deploy viewer run 42125109395**, dispatched on
the same head, on the release (LTO) wasm: success. Its `tests` job
passed all 61 tests of the suite (the whole of it, on the wasm the site
publishes), its `measure` job 6, and `check-wasm-in-site.sh` found the
artifact's one sha256 (`d2b60a7e…`) in the built site in each of the
three jobs that build it; the page's one script is the same size as in
the viewer tests' build (999.56 kB, 271.47 kB gzipped). On the office
with that wasm a read took 3.3 s in 942 MiB beside the open's 910 MiB,
on selection, and the page kept 3 answers, 4,929 characters; the real
capped read ran out of memory as in the other run. (`deploy` is skipped
on a branch, by design.) This PR's head is `3146f14e` plus documentation
(the figures, in the changelog, `docs/status.md` and
`docs/viewer-api.md`) plus a merge of main as it stood at #1470, whose
export changes (#1456, #1470, `src/ifc`) were not part of either run;
the full CI of the ready PR runs the viewer tests on this head. Earlier
runs on earlier code are not counted; Deploy viewer 42122627698 and
viewer tests 42122623374, on `7663a4f3`, each failed once, in the test
of a worker ended with no word, which ended a worker that had already
answered (a read of Einhoven takes a fraction of a second); the test now
holds the file back first.

`viewer/tests/parameters-row.spec.ts`, in the viewer's leg 1/3 (no new
spec file). The oracle is the command line: the test runs `rvt-elements`
on the same file.

| | Einhoven (2023) | Core Interior (2024) | BIM4LCA office as built |
|---|---|---|---|
| Compared with `rvt-elements`, whole entries | 37 of 37 tree elements:
28 with parameters (369 entries: 332 instance, 37 type, 8 named) equal,
7 with none show the empty state, 2 have no ElementId in the export
(shown as such) | 4 elements, IFCSLAB 22756 (4 entries), IFCWALL 22771
(11), IFCCOLUMN 22798 (17), IFCDOOR 80750 (21), equal | **not compared**
|
| A read, time (a CI runner's) | median 153 ms, most 210 ms | 1.5 to 1.9
s | 3.9 s (8 entries, IFCCOVERING 2097832) |
| That read's wasm memory | 17 MiB | 275 MiB | 943 MiB |
| The open's worker | 23 MiB, 0.7 s in the open call | 326 MiB, 17.3 s |
910 MiB, 66.6 s |
| Read over open (memory) | 0.74 | 0.84 | 1.04 |
| How it was read | on selection | on selection | on selection (no
button) |
| Kept by the page | | | 2 answers, 4,654 characters of JSON |

Also in the spec (each passed in 42125048710):
- **A real out-of-memory read.** A Chromium whose V8 caps wasm memory at
927 MiB (`--wasm-max-mem-pages`, the pattern of
`memory-ceiling-capped.spec.ts`) opens the office (910 MiB) and the read
(943 MiB) really runs out: the page says "The tab ran out of memory
reading the file a second time (unreachable)... read only when asked
from now on", and the next element asks. A read of Einhoven cannot fail
after its open succeeds (17 MiB against 23), so the office is the only
file in CI where a cap separates the two.
- **No request, offline.** After the load the page is taken offline and
every request is recorded (workers included): three elements are read
and equal `rvt-elements`', an IFC, a plan and a glTF export are made,
the file is opened again (the saved-mesh toggle), an element is read
again, and no http(s) request was made. `no-network.spec.ts` runs the
same exports and re-open, and a selection, in phases that allow nothing,
and fails if the sample has no element to select, if the wasm is fetched
to boot the page or more than once.
- The gate at its edge (a limit 8 MiB over and 8 MiB under Einhoven's
measured open memory: read on selection, then asked); the
bare-`unreachable` branch and its copy, and the file read only when
asked afterwards; a worker ended with no word, with the file held back
four seconds so it is still reading; a read for an element no longer
shown ended (another element, a storey), and the shown element's read
not started over by selecting it again; an element selected again
starting no worker; a copy of the file opened under another name
emptying the map; the bound; a read that fails with a panic, with Try
again, and focus on the result; the empty state; the Parameters row
text; Revit 2013 (the worker's answer replaced) and Revit 2019
experimental (replaced).

Not verified:

- **The release-not-read and experimental-release states.** No file of a
release outside Revit 2015 to 2027, or of 2015 to 2022, is in the
viewer's job, so those two tests replace the worker's answer to the page
with the binding's shape for one (`release_read` false;
`release_experimental` true). They test the page's rendering only. The
Rust branches (`NATIVE_RELEASES.contains`, the measured range) are not
exercised by any file.
- `tools/check-local.sh`, clippy and `tools/ci/check-workflows.py` (no
local compute; PyYAML is not installed here); CI's fast jobs on this PR
are the check. The wasm network-import audit passed in the viewer legs.
- An ElementId above `u32::MAX`: the binding reads it, the command line
lists such elements as `id: null`, so nothing compares them.
- The office is not compared with `rvt-elements`; only that its read
does not error. The gate is held at its edge on Einhoven's open memory;
no file between 910 MiB and the 4 GiB ceiling is in the viewer's job,
which is why the limit is the measured 1 GiB.
- The CDP session of `no-network.spec.ts` may not see worker requests;
the offline test, which records every request and fails any, is what
covers them.
- Screen-reader announcements were not heard: the live region's text and
the focus move are asserted, not a screen reader's output.

## Breaking changes

None. A binding is added (`tools/ci/wasm-api.py compat` has nothing to
flag); no existing binding or output changes. The `worker-src` of the
page's Content-Security-Policy gains `blob:`.

## Related issues

Refs #35 (#255 and the family built-in slots stay open).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant