Skip to content

test(Lightbox): the spring zoom's check reads the zoom on its own clock - #10301

Merged
cixzhang merged 2 commits into
meta:mainfrom
vjeux:uikit/c13-lightbox-spring-zoom-clock
Nov 6, 2026
Merged

cixzhang merged 2 commits into
meta:mainfrom
vjeux:uikit/c13-lightbox-spring-zoom-clock

Conversation

@vjeux

@vjeux vjeux commented Nov 6, 2026 •

Copy link
Copy Markdown
Contributor

Maintainer impact

LightboxFinePointer.a11y.browser.spec.ts "the keyboard's zoom settles on springs.settle" fails on a busy runner, and that can block a release cut. In the release-check of main 28dda93 (https://github.com/meta/astryx/actions/runs/42234763190, attempt 1, "Accessibility spec-test contracts (1/6)"), it failed at its 100 ms sample: |progress − settleProgress| was 0.093 against a 0.08 bound. Attempt 2 passed.

Intended invariant

The check stays the same: the photo's zoom settles on springs.settle from rest (about 0.36 at 100 ms, 0.72 at 200 ms, within 0.08), and it comes within half a percent of its target near 0.59 s. The bounds don't change.

Change

The test sampled the photo's width in main-thread frame callbacks and dated the curve from the last frame before the photo moved. On a busy runner frames come tens of ms apart, so that origin could be off by a whole gap. Near 100 ms the spring moves 0.0045 per ms, so a 20 ms error is the 0.093 reading.

Now the curve is read on the zoom's own clock, through the shared interaction harness. The zoom plays as two animations on the photo (its translate and its scale, with one start time). Before the input, armHold(page, img, {newOnly: true}) arms the page to hold those animations itself as they start; a hold sent from the test could reach a busy page late, and runs an earlier zoom left in their end hold are not taken. The test then moves them with seekAnimations to 100, 200 and 300 ms and reads the photo's width there, against the same bound. "Near 0.59 s" is read the same way: not yet within half a percent at 450 ms, and within it by 800 ms. releaseAnimations(page, {finish: true}) ends them.

Pausing means the curve check no longer watches the zoom run live. So the keyboard test first watches an unpaused Enter zoom reach 2× and return to the fitted size, with no timing bound. Other live zoom checks are unchanged: "a mouse double-click zooms 2× about the clicked point, and the next zooms back" (LightboxFinePointer.a11y.browser.spec.ts:182), and the keyboard + zoom that the zoomed-drag tests wait on until it rests (LightboxZoomModes.interaction.browser.spec.ts:245, :317).

Evidence

  • Failure before the change: under the CI profile, on a Storybook build of main 010db3f, the test as it is on main fails 1 of 30 runs in Chromium pinned to 2 cores with 2 workers, and 4 of 20 in WebKit in a 4-CPU container (at its 200 ms and 300 ms samples, 0.095 to 0.097). With 2 busy loops on the same 2 cores, Chromium fails 4 of 20.
  • Success after the change: the same profiles pass every run: Chromium on 2 cores 30 of 30, and 20 of 20 with the 2 busy loops; WebKit in the 4-CPU container 20 of 20. The harness-based head passes the same: 30 of 30, 20 of 20 and 20 of 20.
  • Product/runtime behavior verified unchanged: no product file changes. A spring 25 % slower (the theme's tempo 1.25) still fails the check at its 100 ms sample (0.092), in Chromium and WebKit.

Scope

  • No intended public API, product behavior, visual direction, or policy change.
  • Product changes discovered during the work were removed or split.
  • Public text and artifacts contain no internal Meta context.

Testing

  • core tsc 0; strict ESLint 0 on the changed file; comment sentence lengths 0 over.
  • On the same build: LightboxFinePointer, LightboxViewport and LightboxKeyboard a11y specs 20/20 in Chromium; 18 passed in WebKit (2 Chromium-only pen cases skip). At the harness-based head, the whole LightboxFinePointer file passes 15/15 in Chromium.

The check that the keyboard's and a double-click's zoom settle on
springs.settle sampled the photo in frame callbacks and dated the
curve from the last frame before it moved. On a busy runner frames
come tens of ms apart, so that origin could be off by a whole gap, and
the 100 ms reading missed by 0.09. The page now pauses the zoom's two
animations on the photo as they start, and the test reads the photo's
width at 100, 200, 300, 450 and 800 ms on their own clock. The bounds
are unchanged.
@vercel

vercel Bot commented Nov 6, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
astryx Ready Ready Preview Nov 6, 2026 4:29pm UTC

Request Review

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Meta Open Source bot. label Nov 6, 2026
@astracat-bot

astracat-bot Bot commented Nov 6, 2026 •

Copy link
Copy Markdown
Contributor

AI review status for this pull request.

Review status Updated
🟢 Reviewed (for maintainers only) Nov 6, 2026, 4:34 PM UTC

@github-actions

github-actions Bot commented Nov 6, 2026 •

Copy link
Copy Markdown
Contributor

PR Analysis Report

🔎 Preview · a2bd44e

Storybook · Sandbox · built from this PR's head

Modified components

Component Size LoC Visual · A11y · RTL
Lightbox · Storybook 103.0 kB (0) · 9.8 kB CSS (0) 2,469 (−12) ✓ · ✓ · ✓

Package size: no published package changed; no new dependencies.

API changes: none in this pull request

Committed API report behind this build: cli 19 rows, core 24 rows; run pnpm api:report.

Touched components checked; add ci:run-visual or ci:run-rtl to run the full suites.


Generated by PR Enrichment workflow | View full report

@cixzhang

cixzhang commented Nov 6, 2026

Copy link
Copy Markdown
Contributor

/approve-spec 8b6aef9

@cixzhang cixzhang added ci:run A maintainer lets this outside contributor's pull request run CI (AST-030 FR17) ci:run-a11y Run the accessibility suite on this PR; write access, next push (AST-030 FR12) labels Nov 6, 2026

@astracat-bot astracat-bot Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changes requested: the new spring-zoom reading is sound and keeps the same bounds, but it re-implements the shared interaction harness instead of calling it.

  • expectSpringZoom (LightboxFinePointer.a11y.browser.spec.ts:236-338) copies armHold, seekAnimations and releaseAnimations from @astryxdesign/interaction-harness (the same every-frame-and-4-ms page hold, new-animations-only filter, offset seek and finish), so please call armHold(page, img, {newOnly: true}) before the input, seekAnimations(page, ms) before each width read and releaseAnimations(page, {finish: true}) at the end, and drop the __zoom page code and the startEvent parameter.

A harness-based version of both checks passes in Chromium and WebKit with the same bounds, so the swap does not change what the test proves; held.every(a => a.offsetMs === 0) replaces the same-start check, and the live Enter zoom check can stay as it is.

[Automated review]

Comment on lines +236 to +287
// The page pauses the zoom itself, before the input comes: a pause sent
// from the test would reach a busy page late.
await page.evaluate(type => {
(window as unknown as {__samples: Promise<[number, number][]>}).__samples =
new Promise<[number, number][]>(resolve => {
const img = document.querySelector('dialog img');
const samples: [number, number][] = [];
let start: number | null = null;
window.addEventListener(
type,
() => {
start = performance.now();
},
{capture: true, once: true},
const img = document.querySelector('dialog img');
const w = window as unknown as {
__zoom: Promise<{animation: Animation; start: number}[]>;
};
// A run that the last zoom left in its end hold is not this zoom.
const before = new Set(img?.getAnimations() ?? []);
w.__zoom = new Promise(resolve => {
let begin = 0;
let timer = 0;
let done = false;
const look = () => {
if (done) {
return;
}
const running = (img?.getAnimations() ?? []).filter(
animation =>
!before.has(animation) &&
animation.playState === 'running' &&
!animation.pending,
);
const tick = (now: number) => {
if (start != null && img != null) {
samples.push([now - start, img.getBoundingClientRect().width]);
}
if (start == null || now - start < 1000) {
requestAnimationFrame(tick);
} else {
resolve(samples);
}
};
requestAnimationFrame(tick);
});
if (running.length > 0 || performance.now() - begin > 5000) {
done = true;
clearInterval(timer);
// Each keeps where it started, so all of them read one instant.
const held = running.map(animation => ({
animation,
start: Number(animation.startTime ?? 0),
}));
held.forEach(({animation}) => animation.pause());
resolve(held);
}
};
// It looks on every frame and every 4 ms between them.
const frame = () => {
look();
if (!done) {
requestAnimationFrame(frame);
}
};
window.addEventListener(
type,
() => {
begin = performance.now();
timer = window.setInterval(look, 4);
requestAnimationFrame(frame);
},
{capture: true, once: true},
);
});

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This page hold, the seek in widthAt and the closing finish() re-implement armHold, seekAnimations and releaseAnimations from @astryxdesign/interaction-harness, which core's accessibility specs already use. Please call them instead: armHold(page, img, {newOnly: true}) before act(), seekAnimations(page, ms) before each width read, and releaseAnimations(page, {finish: true}) at the end; held.every(a => a.offsetMs === 0) replaces the same-start check.

The check holds the zoom's animations with armHold, reads each time
with seekAnimations and finishes them with releaseAnimations: the
shared interaction harness's own tools, in place of a copy of them.
The readings, the bounds and the live zoom check are unchanged.
@cixzhang

cixzhang commented Nov 6, 2026

Copy link
Copy Markdown
Contributor

/approve-spec a2bd44e

@astracat-bot astracat-bot Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved pending CI: CI is still running on this head.

The spring-zoom checks now call the shared interaction harness (armHold, seekAnimations and releaseAnimations), which resolves the earlier change request. Both rewritten checks pass in Chromium with the same bounds, unloaded and under CPU load, and the rest of the file passes too.

[Automated review]

@cixzhang
cixzhang merged commit 4cfcf7c into meta:main Nov 6, 2026
119 checks passed
@vjeux
vjeux deleted the uikit/c13-lightbox-spring-zoom-clock branch November 6, 2026 17:03
cixzhang added a commit that referenced this pull request Nov 8, 2026
* feat(core): UIScrollView zoom constants and the zoom stage geometry

The UIKit constants table gains zoomMedia, measured on iOS 26.2 in a
UIKit lab app and in Photos: the give past the zoom limits, the eased
settle and its length law, and Photos' double tap and maximum zoom. The
settle's three lengths are internal motion roles. component:Lightbox
names them in a new Motion roles table, and the generated motion role
table carries them.

Lightbox/zoomStage.ts is the pure geometry of a zooming scroll view in a
photo viewer, checked against those numbers. A double tap zooms to the
larger of filling the stage and 2x, about the tapped point, as
component:Lightbox FR6 asks. Nothing renders the stage yet: Lightbox's
touch zoom plays it in the next change.

* feat(Lightbox): touch zoom like the iOS Photos viewer

Lightbox's zoom moves to the gesture recognizers and the compositor
animator. A pinch zooms about the fingers with the pan riding along, and
it gives past the zoom limits and eases back about the last centroid. A
finger's double tap zooms to the larger of filling the viewer and 2x,
about the tapped point, over the theme's move easing and medium
duration. A mouse's or a pen's double-click zooms 2x about the clicked
point. In the touch presentation a zoomed pan has UIScrollView's rubber
band, coast and edge bounce. A mouse's or a pen's drag pans 1:1 and
stops at the edges and at the release, as before.

The zoom takes every pointer: a ctrl-wheel or a trackpad pinch zooms,
and a trackpad's scroll pans a zoomed photo; a mouse wheel's notches
never pan. The photo's stage fills the viewer and takes the pinch; the
controls and caption keep the page's pinch-zoom.
Since a zoomed photo can now lie under Close, Previous, Next and the
counter, a zoomable Lightbox sets them on its own translucent backing
and keeps their icons and text on the on-dark colour, so they keep
3:1, and 4.5:1 for the counter's text, over any photo in every theme.
The keyboard keeps its 2x zoom about the centre over the released 200 ms
ease-out, and keyboard panning stops at the photo's edges.

The double tap reads its tokens through the shared theme-timing
reader in motion/themeTiming.ts. A theme that leaves --duration-medium
unset gets Core's default duration there, not a zoom that lands at once.

* feat(Lightbox): swipe between gallery photos like Photos

A Lightbox gallery moved only through its two arrow buttons. A finger's
drag or flick now pages between items with UIKit's paging release: one
page at most, with Photos' measured 40 pt gap, settled on the
compositor. The drag paging is part of the touch presentation, which a
coarse primary pointer brings (spec:AST-094 FR13); under a fine pointer
the buttons and the arrow keys page, as before. A zoomed photo keeps
the drag until its edge, as nested scroll views do, and a pinch never
pages.

A video pages from its frame. Its native controls are taken as a 48 px
band at its bottom edge, since browsers expose no control geometry, so
a drag that starts there stays the video's (component:Lightbox FR7).

Only the current page takes focus and is in the accessibility tree.
Next, Previous and any other change of `index` slide the row under the
touch presentation; under a fine pointer the row moves at once, so a
button the owner refuses shows nothing. A drag the owner refuses
springs back. Under Reduce Motion they fade. On a
zoomable gallery the photo rows take the stage's touches while the
track allows the page's pinch-zoom, so a pinch on a caption still
zooms the page.

The pan and the pinch read where their touches began from the shared
recognizers, and without zoom a tap beside a gallery's photo closes
the viewer through a shared tap recognizer.

* feat(core): UIScrollView zoom constants and the zoom stage geometry

The UIKit constants table gains zoomMedia, measured on iOS 26.2 in a
UIKit lab app and in Photos: the give past the zoom limits, and Photos'
double tap and maximum zoom. UIKit's eased zoom settle stays a
measurement only. Lightbox's main interaction is a gesture, so its zoom
settles on springs.settle (spec:AST-094 FR45).

Lightbox/zoomStage.ts is the pure geometry of a zooming scroll view in a
photo viewer, checked against those numbers. A double tap zooms to the
larger of filling the stage and 2x, about the tapped point, as
component:Lightbox FR6 asks. Nothing renders the stage yet: Lightbox's
touch zoom plays it in the next change.

* feat(Lightbox): touch zoom like the iOS Photos viewer

Lightbox's zoom moves to the gesture recognizers and the compositor
animator. A pinch zooms about the fingers with the pan riding along, and
it gives past the zoom limits and springs back about the last centroid,
from the photo's scale velocity at the lift. A finger's double tap zooms
to the larger of filling the viewer and 2x, about the tapped point. A
mouse's or a pen's double-click zooms 2x about the clicked point. Every
zoom settles on springs.settle, since Lightbox's main interaction is a
gesture (spec:AST-094 FR45). In the touch presentation a zoomed pan has
UIScrollView's rubber band, coast and edge bounce. A mouse's or a pen's
drag pans 1:1 and stops at the edges and at the release, as before.

The zoom takes every pointer: a ctrl-wheel or a trackpad pinch zooms,
and a trackpad's scroll pans a zoomed photo; a mouse wheel's notches
never pan. The photo's stage fills the viewer and takes the pinch; the
controls and caption keep the page's pinch-zoom.
Since a zoomed photo can now lie under Close, Previous, Next and the
counter, a zoomable Lightbox sets them on its own translucent backing
and keeps their icons and text on the on-dark colour, so they keep
3:1, and 4.5:1 for the counter's text, over any photo in every theme.
The keyboard keeps its 2x zoom about the centre, and keyboard panning
stops at the photo's edges.

* Merge the updated #8148 into the Lightbox pager (replays the lane's reference resolution)

* fix(Lightbox): the zoom pan reads its begin threshold per press

The zoom pan's begin threshold was set by Lightbox's own capture
pointerdown listener on the stage. The shared PanGestureRecognizer
takes a per-press hysteresis function, so the threshold moves there
and the listener goes. A mouse's or a pen's drag on a zoomed photo
still pans from its first move, and a finger keeps UIKit's threshold.

The zoom stage's header now says that the return past a limit springs
from the pinch's velocity.

A fine-pointer test's comment splits one 26-word sentence in two, under
the 25-word limit.

* Merge main into the Lightbox pager

This merge takes main at bef866e, with the Popover group, and
this pull request's own diff is unchanged.

* fix(Lightbox): a single zoomed photo gives past its edge again

The zoom stage's pan refused a finger's drag that headed past a zoomed
photo's edge in every Lightbox, so a single photo resting at its edge
no longer rubber-banded there. Only a gallery's touch pager takes that
drag now: the stage yields at the edge only when Lightbox says an
outer pager is there. A single photo gives past its edge as on main.

The record's press-tracker line no longer names the stage's own
pointerdown listener, which the pan's per-press threshold replaced.

* fix(core): a released page settles at the theme's tempo

The spec owners ruled this a consistency fix: AST-108 plays motion at
the theme's tempo, and AST-094 requires the touch presentations to
follow it, but the pager's settle after a release ignored it.
solvePaging now takes the tempo. Each step lasts tempo times as long
and carries tempo times the release's distance, so a settle from rest
keeps its shape and takes tempo times as long, and a release still
starts at 96 % of the finger's speed. At tempo 1 the settle is
unchanged. No motion role names the paging table, so usePager reads
the tempo of the theme the track is in. Every pager follows it: a
Lightbox gallery and a Carousel with hasSnap.

The busy-main-thread proof of the gallery's settle now plays at tempo
3, as the zoom's does. A swipe at tempo 1 checks that the slowed settle
is three times as long, and a frozen settle and one that the main
thread drives both fail the proof. A refused drag's spring-back is now
read from its keyframes rather than counted in main-thread frames,
which a loaded runner thins out.

* docs(core): the tempo note names the snap paging Carousel

The release note named a Carousel with hasSnap, but a plain hasSnap is
native CSS scroll snap. Only hasSnap={useSnapPaging()} runs the pager
whose settle now follows tempo, so the note names that value. The
AST-094 FR45 verification row no longer lists tempo as a gap of the
pager's settle.

* Merge main into the Lightbox pager

This merge takes main at 1c142dc. #10301 rewrote the spring-zoom
check in LightboxFinePointer.a11y.browser.spec.ts onto the shared
interaction harness, and this pull request had split a sentence of
that check's old comment. The merge keeps #10301's check and its
comment as they are on main.

* test(Lightbox): the instant-page check waits for 12 frames

The check that Next and the arrow key show the next photo at once
samples the track every frame for 600 ms after the press, and it needs
more than 10 frames. WebKit in a 4-CPU container painted 3 to 7 frames
in that time under load, so the check failed there. The sampler now
runs for 600 ms and at least 12 frames. At half the test's timeout it
gives up, and too few frames fail by name. The one-place check is the
same.

* Merge main into the Lightbox pager

This merge takes main at 755206d. Main's busy-proof harness now
judges each run of a pooled proof on its own and leaves out, by name, a
run whose control presented nothing. The page-settle proof that follows
relies on it.

* test(Lightbox): the busy page-settle proof pools six settles

One settle moves visibly for about 550 ms at tempo 3. While the main
thread is blocked, WebKit's software compositor presents a frame every
110 to 200 ms, so a settle held three to five frames. A loaded runner
presented three, under the proof's four, and the proof failed as too
little to judge, though the photo had moved on every one of them. A
starved compositor could also draw one or two frames before it applied
a settle handed over just before the block.

The proof now judges six settles, to page 4 and back, as one pool, at
tempo 5. A run whose control presented nothing is left out by name, and
the pool needs three judged runs. Each block starts one rendering update
after the handoff, once the compositor has drawn the settle, and each
run skips at most one frame the compositor began before the block. A
settle that stays still for two frames or more into the block still
fails, as two new controls prove.

* Merge main into the Lightbox pager (v0.7.10 shipped the zoom note)

Main's v0.7.10 release consumed .changeset/lightbox-every-pointer.md,
the note for #8148's ctrl-wheel and trackpad zoom, which this pull
request had edited to read "with `hasZoom`". The merge keeps main's
deletion and drops the edit: on main the zoom stage already runs only
for a photo with `hasZoom`, so the qualifier names no change of this
pull request. Its own notes, lightbox-gallery-paging.md and
pager-settle-tempo.md, are unchanged.

* Merge main into the Lightbox pager (keeps #10406's lift record)

Main's #10406 added recordLiftOffset to LightboxZoom's interaction
spec, beside this pull request's slowViewer import. The merge keeps
both imports; every other path is the automatic merge.

* Merge main into the Lightbox pager (ports #10415's busy zoom tempo)

Main's #10415 plays LightboxZoom's busy double-tap proof at tempo 5
through `slowZoom`, which this pull request replaced with the shared
`slowViewer`. The merge keeps #10415's three constants and calls
`slowViewer(page, ZOOM_TEMPO)` in the proof and its controls; every
other path is the automatic merge.

* Merge main into the Lightbox pager

The restack of #8197 on main 993e1fa, which brings #10436's
PowerSearch play fix for the story play guard. No conflict; this pull
request's own diff is unchanged.

* fix(Lightbox): the photo left behind resets by the page the pager names

The pager's onSettle reset every photo outside the page marked current.
On a slow runner the settle ends before the render that moves that
mark, so the photo left behind was still marked current and kept its
zoom. Each page now carries its index, and the reset skips only the
page the pager names.

* Merge main into the Lightbox pager

The restack of #8197 on main 5c1b7d4, which brings #10464: a busy
pool now leaves out a run that began too late, as null. No conflict.

* test(Lightbox): the busy settle proofs read a left-out run as none

Main's busy pool now leaves out a run that began too late, as null in
its runs. The page settle proof reads each judged run's monotonic flag,
and its delayed control reads the first run's frame interval. A judged
run must exist, so a missing one fails that check. A first run the pool
left out fails by name, with the pool's summary, before the control
uses its interval.

Co-authored-by: Cindy Zhang <[email protected]>

This branch was successfully deployed

1 active deployment
Preview — a2bd44ef Deployed Nov 6, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci:run A maintainer lets this outside contributor's pull request run CI (AST-030 FR17) ci:run-a11y Run the accessibility suite on this PR; write access, next push (AST-030 FR12) CLA Signed This label is managed by the Meta Open Source bot.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants