Skip to content

Commit c1fc14f

Browse files
authored
journeys: steady Chromium raster, as the page screenshots have (the corner flakes) (#167)
* journeys: the same steady Chromium raster flags as the page screenshots (software raster, one thread, sRGB, greyscale text) * Docs: steady rasterising flags for Chromium screenshots (deterministic guide, Playwright guide); plugin 0.1.54
1 parent 925b7f6 commit c1fc14f

13 files changed

Lines changed: 84 additions & 22 deletions

File tree

‎.claude-plugin/marketplace.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"plugins": [
66
{
77
"name": "visualci",
8-
"version": "0.1.53",
8+
"version": "0.1.54",
99
"description": "Visual regression and snapshot review for PDFs, screenshots, JSON, HTML and text: VisualCI's MCP server and its skills for each CI provider and test tool.",
1010
"author": { "name": "DocSpring", "url": "https://visualci.com" },
1111
"homepage": "https://visualci.com/docs/skills/",

‎.claude-plugin/plugin.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "visualci",
3-
"version": "0.1.53",
3+
"version": "0.1.54",
44
"description": "Visual regression and snapshot review for PDFs, screenshots, JSON, HTML and text: VisualCI's MCP server and its skills for each CI provider and test tool.",
55
"author": { "name": "DocSpring", "url": "https://visualci.com" },
66
"homepage": "https://visualci.com/docs/skills/",

‎.cursor-plugin/plugin.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "visualci",
33
"displayName": "VisualCI",
4-
"version": "0.1.53",
4+
"version": "0.1.54",
55
"description": "Visual regression and snapshot review for PDFs, screenshots, JSON, HTML and text: VisualCI's MCP server and its skills for each CI provider and test tool.",
66
"author": {
77
"name": "DocSpring"

‎frontend/content/docs/screenshots/deterministic.md‎

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,10 @@ as a change somebody has to look at. Fix these in the tests, once, rather than a
2424
| Lazy-loaded images | Wait for every image to finish loading |
2525
| Viewport, scrollbars, pixel ratio | Fix the viewport size, hide scrollbars, use a device pixel ratio of 1 |
2626
| Text cursor, hover, focus | Hide the caret, and move the mouse away |
27+
| Anti-aliased edges and icons a shade off | Launch Chromium with software raster on one thread ([flags](#steady-rasterising)) |
2728
| Scroll position | Scroll once the page has stopped changing, never while it still lays out |
2829

29-
What's left after this (anti-aliasing that differs slightly between runs) is what a
30+
What's left after this (anti-aliasing that still differs slightly between runs, as between two machines) is what a
3031
[threshold](/docs/screenshots/#thresholds) is for. A threshold can't fix a clock or an animation: those change far
3132
more pixels than anti-aliasing does.
3233

@@ -123,6 +124,33 @@ purpose: a screenshot from a Retina laptop is twice the size of one from CI). Hi
123124
operating systems and appear only when content overflows. Hide the text cursor, and move the mouse away from
124125
anything with a hover state.
125126

127+
### Steady rasterising
128+
129+
Chromium rasterises on the GPU, in tiles and on several threads, so the anti-aliased edges of rounded corners, borders
130+
and small SVG icons can come out a shade different from one run to the next on the same machine: a handful of pixels,
131+
one colour step off, with nothing else changed. Launch it with software rasterising on one thread, one colour profile
132+
and greyscale text, and those edges come out the same every run:
133+
134+
```ts
135+
// playwright.config.ts
136+
use: {
137+
launchOptions: {
138+
args: [
139+
'--disable-gpu',
140+
'--force-color-profile=srgb',
141+
'--disable-partial-raster',
142+
'--disable-skia-runtime-opts',
143+
'--disable-lcd-text',
144+
'--font-render-hinting=none',
145+
'--num-raster-threads=1',
146+
],
147+
},
148+
},
149+
```
150+
151+
The same flags work with `chromium.launch({ args })` and Puppeteer's `launch({ args })`. Switching them on changes
152+
every screenshot slightly once (greyscale text instead of subpixel text), so approve that build as the new baseline.
153+
126154
### Scroll position
127155

128156
A test that scrolls an element into view before the screenshot gets a different scroll position on each run when the

‎frontend/content/docs/screenshots/playwright.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,6 @@ visualci upload --platform webkit-linux --threshold 0.1 screenshots/webkit
2626
visualci build finalize
2727
```
2828

29-
Use this instead of `toHaveScreenshot`: the baselines live on VisualCI, a change waits for review instead of failing the test, and no PNGs are committed. Hide content that changes on every run (times, avatars) with Playwright's `mask` option, or wait for animations to finish, before the screenshot. [Deterministic screenshots](/docs/screenshots/deterministic/#playwright) has a fixture that pins the clock, randomness and network.
29+
Use this instead of `toHaveScreenshot`: the baselines live on VisualCI, a change waits for review instead of failing the test, and no PNGs are committed. Hide content that changes on every run (times, avatars) with Playwright's `mask` option, or wait for animations to finish, before the screenshot. [Deterministic screenshots](/docs/screenshots/deterministic/#playwright) has a fixture that pins the clock, randomness and network. Launch Chromium with the [steady rasterising flags](/docs/screenshots/deterministic/#steady-rasterising) too, or rounded corners and icons can differ by a shade between runs.
3030

3131
Run the tests in CI's browsers, not on a laptop: see [Platforms](/docs/screenshots/#platforms) and [Local runs](/docs/local-runs/).

‎gemini-extension.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "visualci",
3-
"version": "0.1.53",
3+
"version": "0.1.54",
44
"description": "Visual regression and snapshot review for PDFs, screenshots, JSON, HTML and text: VisualCI's MCP server and its skills for each CI provider and test tool.",
55
"mcpServers": {
66
"visualci": {

‎scripts/screenshots/capture.mjs‎

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import { dirname, join } from 'node:path'
1111
import { chromium } from 'playwright'
1212

1313
import { EMAIL, NOW, pages } from './pages.mjs'
14+
import { STEADY_RASTER } from './raster.mjs'
1415

1516
/** VisualCI's production gallery, as frontend/src/components/GalleryImage.tsx names it. */
1617
const GALLERY = 'https://app.visualci.com/g/docspring/visualci'
@@ -100,19 +101,9 @@ async function unstick(page) {
100101

101102
async function main() {
102103
const opts = args()
103-
// Software rasterising on one thread, one colour profile and greyscale text: with the GPU and partial raster, small SVG
104-
// icons came out a few pixels different from run to run.
105104
const browser = await chromium.launch({
106105
...(process.env.CHROME_PATH ? { executablePath: process.env.CHROME_PATH } : {}),
107-
args: [
108-
'--disable-gpu',
109-
'--force-color-profile=srgb',
110-
'--disable-partial-raster',
111-
'--disable-skia-runtime-opts',
112-
'--disable-lcd-text',
113-
'--font-render-hinting=none',
114-
'--num-raster-threads=1',
115-
],
106+
args: STEADY_RASTER,
116107
})
117108
const contexts = new Map()
118109
const missing = new Set()

‎scripts/screenshots/checks.mjs‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,15 @@
1313
import { chromium } from 'playwright'
1414
import { EMAIL, pages } from './pages.mjs'
1515
import { checkLightbox } from './lightbox.mjs'
16+
import { STEADY_RASTER } from './raster.mjs'
1617

1718
const arg = (name, fallback) => {
1819
const i = process.argv.indexOf(name)
1920
return i > 0 ? process.argv[i + 1] : fallback
2021
}
2122
const BASE = arg('--base-url', 'http://127.0.0.1:5151')
2223

23-
const browser = await chromium.launch()
24+
const browser = await chromium.launch({ args: STEADY_RASTER })
2425
try {
2526
await checkLightbox(browser, BASE)
2627

‎scripts/screenshots/journeys.mjs‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import { createHash, randomBytes } from 'node:crypto'
66
import { mkdir } from 'node:fs/promises'
77
import { createServer } from 'node:http'
88
import { chromium, request } from 'playwright'
9+
import { STEADY_RASTER } from './raster.mjs'
910

1011
const arg = (name, fallback) => {
1112
const i = process.argv.indexOf(`--${name}`)
@@ -21,7 +22,7 @@ const MCP = 'https://mcp.visualci.test'
2122
const NO_MOTION = '*, *::before, *::after { animation: none !important; transition: none !important; caret-color: transparent !important; }'
2223

2324
await mkdir(out, { recursive: true })
24-
const browser = await chromium.launch()
25+
const browser = await chromium.launch({ args: STEADY_RASTER })
2526
const failures = []
2627

2728
/** One journey in a fresh browser (no cookies), its steps' screenshots named `<journey>/<nn>-<step>`. */

‎scripts/screenshots/lightbox.mjs‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
// image hasn't loaded yet, the way a slow connection does.
1010
import { chromium } from 'playwright'
1111
import { pathToFileURL } from 'node:url'
12+
import { STEADY_RASTER } from './raster.mjs'
1213

1314
// A 1×1 PNG: the check reads which URL each image shows, not its pixels.
1415
const PNG = Buffer.from(
@@ -95,7 +96,7 @@ export async function checkLightbox(browser, base) {
9596
if (import.meta.url === pathToFileURL(process.argv[1]).href) {
9697
const i = process.argv.indexOf('--base-url')
9798
const base = i > 0 ? process.argv[i + 1] : 'http://127.0.0.1:5151'
98-
const browser = await chromium.launch()
99+
const browser = await chromium.launch({ args: STEADY_RASTER })
99100
try {
100101
await checkLightbox(browser, base)
101102
} catch (e) {

0 commit comments

Comments
 (0)