Repository navigation
test(interaction): deterministic storyboards - #8348
Conversation
Adds internal/interaction-harness (@astryxdesign/interaction-harness) and playwright.interaction.config.ts: phone-sized touch projects in Chromium and WebKit for *.interaction.browser.spec.ts specs. Touch scripts are data (tap, drag with hold and rest, flick with an exact release velocity and velocity profiles, hold-then-drag, pinch, rotate, any path, a second finger mid-gesture), played as real engine input: CDP Input.dispatchTouchEvent with scripted timestamps in Chromium, WebKit's own input command in WebKit. The harness's self-test proves the timestamps, a native fling and multi-touch delivery; a pr-interaction CI job runs the proofs against each PR's Storybook build, and a container script runs the WebKit project where host libraries are missing.
… Chromium The Chromium driver sent a lift of one finger of several as a touchMove listing the fingers still down, assuming CDP releases a point a move omits. It does not: the lifted finger stayed down. A touchEnd that lists the lifting fingers releases exactly those while the others keep moving, so the driver sends that, and a self-test lifts one of two fingers and checks the release, the other finger's moves and the touchend's remaining touches. Playwright's WebKit sends that touchend with no remaining touches, which iOS never does. The harness does not work around it: drivers expose partialLifts, and PARTIAL_LIFT_SKIP is the reason a proof cites when it skips; the README lists it with the other engine limits.
… lift profiled flicks at their velocity - pr-interaction now always reports and the `test` join requires its success (AST-030 FR7, FR11), shaped like test-native-swift: a Linux interaction-scope job decides, with the base's scope helper and failing closed, whether the harness, a component, Storybook, internal/a11y-spec, the workflow, package.json or pnpm-lock.yaml changed. Only then do the proofs take a 4-core runner; otherwise, and in merge groups (as with pr-a11y), the job passes without work. - A profiled flick's last move runs at velocity times profile(1), so the finger lifts at the documented velocity, and releaseVelocity reads the last move instead of a 100 ms window mean. - Docs: drop the /math subpath this package does not export yet; scripted timestamps arrive to 0.1 ms; the job comment describes the self-test it runs.
…ed its previous position A sample that repeats a position is not a move: frames that merge() inserts for another finger, where this finger did not move, made the last move look shorter, so a 10 Hz drag merged with a tap read 375 px/s instead of 300 and a 60 Hz drag whose other finger lifted 5 ms before its last move read about 3.6x too fast. The previous sample is now the first one at the previous position, as the page sees it, with a merged case in scripts.test.ts.
Pause every Web Animation, seek it to a time and read the presented transform and opacity, then compare the curve with oracles that share no code with the motion under test: cubic-bezier, the SwiftUI spring (response, dampingFraction, initial velocity), UIScrollView deceleration and UIKit's rubber band. Storyboards photograph seeked animations at t = 0, 16.7, 33.3 ... ms or each step of a scripted touch, and write a PNG contact sheet plus the JSON trace a spec asserts, under the gitignored test-results/interaction-evidence. A timer gate holds a component's own timers while a filmstrip is taken. pnpm storyboards runs the tagged tests.
…sented values An animation that keeps its end value in a run of identical final keyframes (held so a later interruption can read it) reported its whole duration as the curve: storyboards filmed the hold, waitForAnimation's interval reached past the landing, and waitForRest, which also required every animation to leave the running state and read only transform, timed out. The curve now ends where that run starts (HeldAnimation.curveEndMs, waitForAnimation's to, the default storyboard times), and rest is no animation pending or before its curve's end plus the presented transform, translate, rotate, scale and opacity (and ::backdrop opacity) still for 3 frames, whatever the playState. sampleCurve composes translate, rotate and scale with transform, so curves of the individual properties are sampled.
…film no endless curve, let the page cancel gated callbacks - holdAnimations holds only running document-timeline animations: a finished fill animation keeps its end value, an animation the page paused stays paused (release resumes only what was held), and a scroll-driven one is not seeked. Each held animation keeps its offset from the earliest start, so staggered starts stay staggered. - A sample or storyboard frame at or past an end reports the time it was read at (presentedAt, half a millisecond inside the end), and curveOf reads oracles there. - An animation that repeats forever no longer sets a storyboard's default length (it ran the worker out of memory); with nothing else to film, animationStoryboard asks for times. - The timer gate queues held callbacks by id, so the page's clearTimeout and cancelAnimationFrame still cancel them; a held frame callback gets the time it runs; frames(), waitForRest and touchStoryboard use the real requestAnimationFrame, so they resolve while frozen. - The storyboard self-tests carry the @Storyboard tag that `pnpm storyboards` selects.
…s from the element's own animations, resume endless ones
- animationStoryboard's default times run from the earliest start to the
latest curve end among the animations that end, each seek at
origin + t: beside a spinner that started earlier the animation under
test no longer shows its start in every frame, and a second animation
that starts later is filmed to its end.
- A sample's presentedAt (per channel: transform, opacity) comes from the
sampled element's own animations, by keyframe property, not from any
animation on the page.
- releaseAnimations({finish: true}) resumes an animation that repeats
forever instead of finishing it (which throws), and always clears the
held set.
- The interaction proofs' scope includes packages/themes/*/src/.
…before it looked waitForAnimation polled getAnimations() after the action, so an entrance shorter than the first look (a cold page answers its first evaluate late) had already finished: "no animation started". The page now records every animation from the first call into curves.ts on it, and on every later document: a frame loop on its own requestAnimationFrame, the CSS animation and transition events, and Element.animate as it is called, pending animations included (WebKit can start and finish a short script animation between two frames of a fresh page). waitForAnimation also reports an animation that started after the last waitForRest or waitForAnimation and has finished, with finishedAt. watchAnimations(locator) arms the record before an action that may be the page's first contact with the harness.
…uest This pull request keeps the curve-sampling instruments: holding and seeking animations, sampling presented values, the oracles, waiting for an animation and for rest. The storyboards (storyboard.ts, the evidence output, the timer gate and the `pnpm storyboards` script) and their tests move to a pull request stacked on this one.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
AI review status for this pull request.
|
`holdAnimations` replaced the held set on each call, so a second hold left the first set paused after `releaseAnimations` (it resumed only the newest set), and `waitForRest` then reported the frozen frame as rest. A later hold now adds to the set: everything held stays held until the release, and offsets count from the earliest start of all of it. The self-test holds two elements in turn, releases, and checks the first runs to its end; on the old code it stays frozen 50 px into a 300 px move. The self-test's header and the `curves.ts` SYNC line no longer describe the storyboard and timer-gate layer, which moved to its own pull request.
animationStoryboard films held animations by seeking them (t = 0, 16.7, 33.3 … ms, from the earliest start to the latest curve end among the animations that end, each at its own offset); touchStoryboard takes a frame per scripted touch event. Each writes a PNG contact sheet and a JSON trace of its measurements to the evidence directory and attaches them to the report; the spec asserts on the trace. The timer gate (installTimerGate, freezeTimers, thawTimers) holds the page's timers and frame callbacks while a storyboard photographs, so a component that finishes an animation from a timer cannot do it behind the held animation's back; the page can still cancel a held callback, and the harness's own frame waits (and the animation recorder) keep the page's real requestAnimationFrame. `pnpm storyboards` runs only the tests tagged @Storyboard.
There was a problem hiding this comment.
Changes requested: the storyboard layer passes its own Chromium self-tests, but this pull request still carries #8043 and #8044 whole, and one documented guarantee of touchStoryboard does not hold.
- Land #8043 and #8044 first and rebase, so the diff is this pull request's own 822-line commit rather than 4,298 authored lines.
touchStoryboardsays velocity-dependent behavior is unchanged in Chromium, but a component that times a release withperformance.now()orDate.now()(Item's and Toast's swipes) sees the storyboard's slower pacing, so a flick that dismisses aSwipeCommitrow when played settles back when filmed; please document that limit or drive the page clock to the scripted times, and cover it with a self-test.
[Automated review]
| * after every event. In Chromium the page still sees the scripted timestamps, | ||
| * so velocity-dependent behavior is unchanged; in WebKit the page sees the |
There was a problem hiding this comment.
This holds only for velocity read from event.timeStamp (BottomSheet). Item's swipe (useSwipeAction.ts, performance.now()) and Toast's (useToastGesture.ts, Date.now()) read the handler clock, and here each event arrives only after two frames, measure and a screenshot: on core-item--swipe-commit, a 150 px flick at 1,500 px/s that dismisses the row under driver.play settles back under touchStoryboard (handler clock 100 ms between the last two moves instead of 33 ms). Please state that limit here and in the README, or drive the page clock to the scripted times while filming.
`touchStoryboard` said velocity-dependent behavior is unchanged in Chromium. That holds for velocity read from event timestamps, which keep their scripted times, but a handler that reads `performance.now()` or `Date.now()` (Item's and Toast's swipes) sees one event per photograph, about 100 ms apart, so a flick that dismisses when played can settle back when filmed. The doc and the README now state that limit and point such gestures at a screencast, and a self-test shows both clocks: scripted 16.7 ms gaps in `timeStamp`, more than two frames in the handler's clock.
21c9295 to
eec2404
Compare
|
Thanks. The guarantee is restated and proven in eec2404:
On scope: this depends on #8043 and #8044, which can't be its base from a fork, so it carries their commits until they merge; then I'll rebase onto main. Its own commits are 4a6dfbe and eec2404. |
Retargeting a CSS transition cancels it. If that happened while it was held, `seekAnimations` and `sampleCurve` set its time again, which revived it over the page's own new transition, and `releaseAnimations` replayed it from the start. Seeking, sampling and releasing now drop an `idle` animation from the held set first, and times count from a fixed origin (the earliest start held until the release), so dropping one never moves the others. The self-test retargets a held transition, seeks, releases and waits for rest: the cancelled transition stays idle and the box ends where the page sent it. On the old code the cancelled transition is still held after the seek.
meta#8117 brings meta#8082 c2fd1bb (with meta#8076 b4e0adb, main with meta#8348's harness), which clears meta#8118's conflict with main, and its FR11 profiles. Both behaviors stay: a cell waits the content-touch delay only inside a scroll view, as a control does (spec:AST-094 FR11), and a control releases on UIButton's clock under a coarse primary pointer. The tests keep both: the fixed-bar and cell FR11 cases beside the coarse and fine release clocks. The story describes both.
…09-search-table
…ang's harness line) into meta#8068
…tion record and the long-task log (#8548) Stacked on #8045 (frame evidence), which is stacked on #8348. Until those land, this diff includes them; this pull request's own change is its single commit. ## What it adds Chromium-only instruments for interaction proofs, split out of #8045 for scope (the code is unchanged): - `traceRendering(page, body)` counts the main thread's rendering work (Layout, Paint, UpdateLayoutTree, PrePaint, …) between two marks, and `countBetween` reads an animation's steady middle: the "no Layout / Paint during a transform animation" proof. - `startCompositorTrace(page)` records when the compositor presented each frame, which `busyWindowProof` takes as `presented` so a frame the screencast skipped is not mistaken for a stall. - `installLongTaskLog` / `readLongTasks` record the page's own long tasks. Harness reads mark themselves (`console.timeStamp('harness-read')`), so a trace reports them in `devtoolsTasks`, apart from the page's `longTasks`. ## Who it helps Authors of interaction proofs: a proof can show that an animation costs the main thread nothing per frame, and the busy-main-thread verdict stays correct on a loaded machine. ## Testing - Harness self-tests in Chromium (`harness.interaction.browser.spec.ts`): the trace counts no Layout for a transform animation and one per frame for `top`; the long-task log records the page's own long task but not a DevTools evaluate; a harness read inside a trace is not a page long task; screencast-skipped frames the compositor presented are not a stall, and a frozen animation still fails. 49 tests × 2 repeats pass. - `busy.test.ts` (29 pass), including the recorded skip fixture. - Test-harness only (`internal/`), nothing published: no changeset. Co-authored with vjeux.
# Conflicts: # internal/interaction-harness/src/curves.ts # internal/interaction-harness/src/harness.interaction.browser.spec.ts
# Conflicts: # internal/interaction-harness/README.md # internal/interaction-harness/package.json # internal/interaction-harness/src/harness.interaction.browser.spec.ts # internal/interaction-harness/src/story.ts
Depends on #8505.
Maintainer impact
A reviewer can't see an animation frame by frame. A screen recording depends on machine load and frame timing, so two runs of the same motion differ, and nothing in it can be asserted.
Intended invariant
No product change. A storyboard is reproducible: its frames come from seeking held animations or stepping scripted input, never from wall-clock capture, and the spec asserts on its trace.
Change
storyboard.ts:animationStoryboardfilms held animations by seeking them. By default it runs from the earliest start to the latest curve end among the animations that end, on a 16.7 ms grid plus the exact end, each animation at its own offset. So a spinner that started earlier doesn't pin the animation under test to its start, and a later animation is filmed to its end.touchStoryboardtakes a frame per scripted touch event. Event timestamps keep the script's times; a handler reading the clock sees one event per photograph.times.output.ts: evidence goes to the gitignoredtest-results/interaction-evidenceand the test report.story.ts: a timer gate (installTimerGate,freezeTimers,thawTimers) holds the component's own timers and frame callbacks while frames are taken. The page can still cancel a held callback, a held frame callback gets the time it actually runs, and the harness's own frame waits (and the animation recorder) keep the page's realrequestAnimationFrame.pnpm storyboardsruns the tests tagged@storyboard.scripts/webkit-container.mjs(from test(interaction): real touch input for browser interaction proofs #8043): WebKit in the official Playwright image for hosts with older libraries.Stacked on #8505 (the animation-state waits, on main with #8044's curve sampling); #8045 and #8423 follow. Review this pull request's own commits.
Evidence
Scope
Testing
pnpm test:interaction --project chromium internal/interaction-harness: 34 passed; the.github/scriptsduration and interaction guards: 32 passed; harness unit tests: 25 passed.pnpm test:interaction --project chromium(harness): 30 passed;pnpm storyboards --list: 9 tests per engine.Storyboard.capturefailed it 3 of 3 times in Chromium and in WebKit; now 10/10 in each.node internal/interaction-harness/scripts/webkit-container.mjs: 27 passed, 3 skipped (native fling; partial lift; the handler-clock test is Chromium-only).pnpm exec vitest run .github/scripts internal/interaction-harness: 1,298 passed.