Repository navigation
fix(cli): check measures its screenshots outside the composition's page - #9079
Conversation
jrusso1020
left a comment
There was a problem hiding this comment.
Reviewed at 0427c79. Requesting changes for one thing only: the PR's own red check.
Blocking: Fallow audit is red because of this diff. It reports two fallow/duplicate-export findings: Rgba is exported from both packages/cli/src/utils/framePixels.ts:11 (new) and packages/cli/src/commands/contrast-bg.ts:4 (existing). Keep one: framePixels.ts can import the type from contrast-bg.ts (or the other way round), and contrast-measure.ts then takes it from the single owner. No behaviour change. I will approve once that check is green on the new head.
The code itself reads clean; no other finding.
- Compared
measureContrastagainst the removed in-page__contrastAuditFinishline by line: same sample rect and grid (now the sharedcontrast-sample.tsfunctions), same known-backdrop rule (ownBgalpha >= 0.99, elsesolidBg), same skip on a transparent median, same weakest-fill pick and stronger-of-fill-and-stroke rule, same 2-decimal rounding and AA thresholds. The clip offset maths matches the old(y - oy) * width + (x - ox). framePixels.tskeeps the thresholds (24 per channel, 16 pixels) and the kept reference decode;isOneColorreplaces the old "paint a full frame in the page and compare" with the same comparison against one colour. The engine'sdecodePngaccepts the 8-bit RGB and RGBA PNGs a screenshot produces, and./alpha-blitis an existing engine export, now aliased intsup.config.ts.check: paint is restored right after the measurement shot and again infinally;matchComponentsnow hands the page onlyselectorandcontainerSelector; the annotated overview and the filmstrip are drawn on a new blank page of the same viewport, closed infinally.validate: same shot options as before, candidates shape-checked in Node, restore still infinally.- No reader of the three removed page functions is left in
packages/outside the new test. - Body has the
fails without the fix:line namingscreenshotsOutsidePage.chromium.test.ts.
Non-blocking:
- The PR body ends with a stray
CORPUS_LINEline. - The body says 10 rows fail on main and lists 8 names; worth making the two agree.
Read whole at head: framePixels.ts, blankPageShot.ts, contrast-measure.ts, contrast-audit.browser.js, blank-span.browser.js. Read as hunks: checkBrowser.ts, validate.ts, motionShot.ts, motion-signature.browser.js, contrast-bg.ts, contrast-sample.ts, tsup.config.ts. Tests: only the first 60 lines of the new Chromium test were read; the other test files were not read. Nothing was run (string searches only).
Need: yes · Size: fits (844/740, mostly a move) · Reuse: good, removes the in-page copies · Simpler: no · Structure: fine
Risk: low once the audit is green; measurement maths is unchanged.
— Rames
Edit accuracy: accurate 275 (base branch 273), smooth 82 of thoseThe gate passes. Newly passing (2)
Not banked yet, reported and not gated (bank a full-grid run's baseline.json) (2)
Quarantined, measured but not gated (0) |
|
Answering the review at 0427c79; new head 4a557c6.
Before and after:
The branch build used for this was made before |
jrusso1020
left a comment
There was a problem hiding this comment.
Reviewed at 4a557c6. Re-review of my one open item.
Resolved: Rgba now has one owner (commands/contrast-bg.ts); utils/framePixels.ts, its test and contrast-measure.ts import it. The audit check that was red on the previous head passes here.
What I compared: the diff between the head I reviewed before (0427c79) and this one is a single commit, 3 files, +5 −5, type imports only, on the same merge base. No runtime line changed, so the earlier read of the rest of the change stands. The body still carries its fails without the fix: line.
Nothing was run; this is a git byte comparison plus a string search for the type's definitions.
Note, not blocking: a utils/ file now imports a type from commands/. It is type-only, so no runtime cycle; if more of the frame code ends up needing colour types, a small shared types file would read better.
Need: yes · Size: unchanged · Reuse: one type, one owner · Simpler: n/a · Structure: fine, see note
Risk: low; type-only delta on top of the already reviewed change.
— Rames
What
hyperframes check,validateandkeyframes --shotmeasure their own screenshots in Node, or draw them on a blank page. The composition's page no longer receives a screenshot, or a colour or verdict read from one.Why
Several checks took a screenshot and handed it back to functions living in the composition's own page, next to the composition's scripts. A composition that redefines a global,
Imageor a canvas method changed what the check measured. A check's reading should not depend on the code it is checking.Related work
Follows #9059, which added the blank-stretch check on top of the same in-page comparison.
How
utils/framePixels.tsdecodes PNGs with the engine's existingdecodePngand owns the frame comparison and the one-colour test. Same thresholds as before (24 per channel, 16 pixels).commands/contrast-measure.tsis the contrast measurement, moved out ofcontrast-audit.browser.js. It reusescontrast-sample.tsandcontrast-bg.ts, which that script used to copy.utils/blankPageShot.tstakes the filmstrip and the annotated overview on a blank page of the same size.Every place in
packages/clithat takes a screenshotLine numbers are
packages/cli/srcon main at ef1d5db.Went back into the composition's page, now does not:
utils/checkBrowser.ts:1165stageIsEmptyutils/checkBrowser.ts:1143framesDiffer(the never-moves check, andkeepsMoving, whole page or inside a selector)utils/checkBrowser.ts:2086finishContrastcommands/validate.ts:341runContrastAuditcommands/motionShot.ts:734filmstriputils/checkBrowser.ts:1938captureOverviewShot(--snapshots)utils/checkBrowser.ts:1109matchComponents(--components)Never went back, unchanged:
utils/checkBrowser.ts:697,:750finding crops and framescommands/snapshot.ts:393commands/snapshot.ts:1538,:1548commands/motionShot.ts:779marker drawingcommands/compare.ts:302,commands/grade-compare.ts:590server/studioServer.ts:951capture/screenshotCapture.ts:128,:328,capture/mediaCapture.ts:192,:534Two are not screenshots and stay:
commands/snapshot.ts:1474puts a video's own decoded frames in its place, andcommands/motionShot.ts:597(--ghost) reads the page's own canvases inside the page.What still reaches the page: the selectors a finding names, when
--componentsor the--snapshotsframes look the elements up again, and the seeks a comparison makes. Neither carries pixels or colours.Test plan
fails without the fix:
packages/cli/src/utils/screenshotsOutsidePage.chromium.test.ts. It loads a film that hooks the receivers,Image, canvas and DOM insertion, before the scripts arrive and again at every seek, and reports what it is handed. On main its 10 rows fail ("asks whether the stage is empty", "compares the frames of a film that never moves", "compares the frames keepsMoving asks about", "measures contrast under check's default flags", "marks contrast failures on the overview frame", "asks which findings belong to a component", "measures contrast in validate", "lays out the keyframes filmstrip"). Each row also asserts that its check still ran and reported. An eleventh row proves the film's hooks see a PNG.keyframes --shotfilmstrip andcheck --snapshotsoverview compared with main's: same picture, only the label text's antialiasing differs. The second page renders the same in one-process headless shell. Not run: the macOS agent sandbox.CORPUS_LINE