From 80c1c4564040aae4cd4cdd153a87634cb2a8e4a2 Mon Sep 17 00:00:00 2001 From: Nathan Broadbent Date: Fri, 4 Dec 2026 15:20:14 +1300 Subject: [PATCH 1/2] journeys: the same steady Chromium raster flags as the page screenshots (software raster, one thread, sRGB, greyscale text) --- scripts/screenshots/capture.mjs | 13 ++----------- scripts/screenshots/checks.mjs | 3 ++- scripts/screenshots/journeys.mjs | 3 ++- scripts/screenshots/lightbox.mjs | 3 ++- scripts/screenshots/raster.mjs | 12 ++++++++++++ 5 files changed, 20 insertions(+), 14 deletions(-) create mode 100644 scripts/screenshots/raster.mjs diff --git a/scripts/screenshots/capture.mjs b/scripts/screenshots/capture.mjs index 1a76c2ce..2392d8f8 100644 --- a/scripts/screenshots/capture.mjs +++ b/scripts/screenshots/capture.mjs @@ -11,6 +11,7 @@ import { dirname, join } from 'node:path' import { chromium } from 'playwright' import { EMAIL, NOW, pages } from './pages.mjs' +import { STEADY_RASTER } from './raster.mjs' /** VisualCI's production gallery, as frontend/src/components/GalleryImage.tsx names it. */ const GALLERY = 'https://app.visualci.com/g/docspring/visualci' @@ -100,19 +101,9 @@ async function unstick(page) { async function main() { const opts = args() - // Software rasterising on one thread, one colour profile and greyscale text: with the GPU and partial raster, small SVG - // icons came out a few pixels different from run to run. const browser = await chromium.launch({ ...(process.env.CHROME_PATH ? { executablePath: process.env.CHROME_PATH } : {}), - args: [ - '--disable-gpu', - '--force-color-profile=srgb', - '--disable-partial-raster', - '--disable-skia-runtime-opts', - '--disable-lcd-text', - '--font-render-hinting=none', - '--num-raster-threads=1', - ], + args: STEADY_RASTER, }) const contexts = new Map() const missing = new Set() diff --git a/scripts/screenshots/checks.mjs b/scripts/screenshots/checks.mjs index fea7a4ec..6a60b5b4 100644 --- a/scripts/screenshots/checks.mjs +++ b/scripts/screenshots/checks.mjs @@ -13,6 +13,7 @@ import { chromium } from 'playwright' import { EMAIL, pages } from './pages.mjs' import { checkLightbox } from './lightbox.mjs' +import { STEADY_RASTER } from './raster.mjs' const arg = (name, fallback) => { const i = process.argv.indexOf(name) @@ -20,7 +21,7 @@ const arg = (name, fallback) => { } const BASE = arg('--base-url', 'http://127.0.0.1:5151') -const browser = await chromium.launch() +const browser = await chromium.launch({ args: STEADY_RASTER }) try { await checkLightbox(browser, BASE) diff --git a/scripts/screenshots/journeys.mjs b/scripts/screenshots/journeys.mjs index dc50ea32..2f93b0fe 100644 --- a/scripts/screenshots/journeys.mjs +++ b/scripts/screenshots/journeys.mjs @@ -6,6 +6,7 @@ import { createHash, randomBytes } from 'node:crypto' import { mkdir } from 'node:fs/promises' import { createServer } from 'node:http' import { chromium, request } from 'playwright' +import { STEADY_RASTER } from './raster.mjs' const arg = (name, fallback) => { const i = process.argv.indexOf(`--${name}`) @@ -21,7 +22,7 @@ const MCP = 'https://mcp.visualci.test' const NO_MOTION = '*, *::before, *::after { animation: none !important; transition: none !important; caret-color: transparent !important; }' await mkdir(out, { recursive: true }) -const browser = await chromium.launch() +const browser = await chromium.launch({ args: STEADY_RASTER }) const failures = [] /** One journey in a fresh browser (no cookies), its steps' screenshots named `/-`. */ diff --git a/scripts/screenshots/lightbox.mjs b/scripts/screenshots/lightbox.mjs index a0fcfeeb..43991518 100644 --- a/scripts/screenshots/lightbox.mjs +++ b/scripts/screenshots/lightbox.mjs @@ -9,6 +9,7 @@ // image hasn't loaded yet, the way a slow connection does. import { chromium } from 'playwright' import { pathToFileURL } from 'node:url' +import { STEADY_RASTER } from './raster.mjs' // A 1×1 PNG: the check reads which URL each image shows, not its pixels. const PNG = Buffer.from( @@ -95,7 +96,7 @@ export async function checkLightbox(browser, base) { if (import.meta.url === pathToFileURL(process.argv[1]).href) { const i = process.argv.indexOf('--base-url') const base = i > 0 ? process.argv[i + 1] : 'http://127.0.0.1:5151' - const browser = await chromium.launch() + const browser = await chromium.launch({ args: STEADY_RASTER }) try { await checkLightbox(browser, base) } catch (e) { diff --git a/scripts/screenshots/raster.mjs b/scripts/screenshots/raster.mjs new file mode 100644 index 00000000..1675ecac --- /dev/null +++ b/scripts/screenshots/raster.mjs @@ -0,0 +1,12 @@ +// Chromium flags for screenshots that come out the same every run: software rasterising on one thread, one colour +// profile and greyscale text. With the GPU and partial raster, small SVG icons and rounded corners' anti-aliased edges +// came out a shade different from run to run (4 Dec 2026: 28 pixels on the site header's button in a journey). +export const STEADY_RASTER = [ + '--disable-gpu', + '--force-color-profile=srgb', + '--disable-partial-raster', + '--disable-skia-runtime-opts', + '--disable-lcd-text', + '--font-render-hinting=none', + '--num-raster-threads=1', +] From 0f07b1006b58d6ecad33fb85e9e9cf6306f0e7c9 Mon Sep 17 00:00:00 2001 From: Nathan Broadbent Date: Fri, 4 Dec 2026 15:21:01 +1300 Subject: [PATCH 2/2] Docs: steady rasterising flags for Chromium screenshots (deterministic guide, Playwright guide); plugin 0.1.54 --- .claude-plugin/marketplace.json | 2 +- .claude-plugin/plugin.json | 2 +- .cursor-plugin/plugin.json | 2 +- .../content/docs/screenshots/deterministic.md | 30 ++++++++++++++++++- .../content/docs/screenshots/playwright.md | 2 +- gemini-extension.json | 2 +- skills/visualci-deterministic/SKILL.md | 30 ++++++++++++++++++- skills/visualci-playwright/SKILL.md | 2 +- 8 files changed, 64 insertions(+), 8 deletions(-) diff --git a/.claude-plugin/marketplace.json b/.claude-plugin/marketplace.json index a7b24e02..19b94c5c 100644 --- a/.claude-plugin/marketplace.json +++ b/.claude-plugin/marketplace.json @@ -5,7 +5,7 @@ "plugins": [ { "name": "visualci", - "version": "0.1.53", + "version": "0.1.54", "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.", "author": { "name": "DocSpring", "url": "https://visualci.com" }, "homepage": "https://visualci.com/docs/skills/", diff --git a/.claude-plugin/plugin.json b/.claude-plugin/plugin.json index 427d0cca..f010870c 100644 --- a/.claude-plugin/plugin.json +++ b/.claude-plugin/plugin.json @@ -1,6 +1,6 @@ { "name": "visualci", - "version": "0.1.53", + "version": "0.1.54", "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.", "author": { "name": "DocSpring", "url": "https://visualci.com" }, "homepage": "https://visualci.com/docs/skills/", diff --git a/.cursor-plugin/plugin.json b/.cursor-plugin/plugin.json index 86818dbe..c7adfe7d 100644 --- a/.cursor-plugin/plugin.json +++ b/.cursor-plugin/plugin.json @@ -1,7 +1,7 @@ { "name": "visualci", "displayName": "VisualCI", - "version": "0.1.53", + "version": "0.1.54", "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.", "author": { "name": "DocSpring" diff --git a/frontend/content/docs/screenshots/deterministic.md b/frontend/content/docs/screenshots/deterministic.md index 59626ac8..dd4ad49f 100644 --- a/frontend/content/docs/screenshots/deterministic.md +++ b/frontend/content/docs/screenshots/deterministic.md @@ -24,9 +24,10 @@ as a change somebody has to look at. Fix these in the tests, once, rather than a | Lazy-loaded images | Wait for every image to finish loading | | Viewport, scrollbars, pixel ratio | Fix the viewport size, hide scrollbars, use a device pixel ratio of 1 | | Text cursor, hover, focus | Hide the caret, and move the mouse away | +| Anti-aliased edges and icons a shade off | Launch Chromium with software raster on one thread ([flags](#steady-rasterising)) | | Scroll position | Scroll once the page has stopped changing, never while it still lays out | -What's left after this (anti-aliasing that differs slightly between runs) is what a +What's left after this (anti-aliasing that still differs slightly between runs, as between two machines) is what a [threshold](/docs/screenshots/#thresholds) is for. A threshold can't fix a clock or an animation: those change far more pixels than anti-aliasing does. @@ -123,6 +124,33 @@ purpose: a screenshot from a Retina laptop is twice the size of one from CI). Hi operating systems and appear only when content overflows. Hide the text cursor, and move the mouse away from anything with a hover state. +### Steady rasterising + +Chromium rasterises on the GPU, in tiles and on several threads, so the anti-aliased edges of rounded corners, borders +and small SVG icons can come out a shade different from one run to the next on the same machine: a handful of pixels, +one colour step off, with nothing else changed. Launch it with software rasterising on one thread, one colour profile +and greyscale text, and those edges come out the same every run: + +```ts +// playwright.config.ts +use: { + launchOptions: { + args: [ + '--disable-gpu', + '--force-color-profile=srgb', + '--disable-partial-raster', + '--disable-skia-runtime-opts', + '--disable-lcd-text', + '--font-render-hinting=none', + '--num-raster-threads=1', + ], + }, +}, +``` + +The same flags work with `chromium.launch({ args })` and Puppeteer's `launch({ args })`. Switching them on changes +every screenshot slightly once (greyscale text instead of subpixel text), so approve that build as the new baseline. + ### Scroll position A test that scrolls an element into view before the screenshot gets a different scroll position on each run when the diff --git a/frontend/content/docs/screenshots/playwright.md b/frontend/content/docs/screenshots/playwright.md index 3d422daf..ec5f2590 100644 --- a/frontend/content/docs/screenshots/playwright.md +++ b/frontend/content/docs/screenshots/playwright.md @@ -26,6 +26,6 @@ visualci upload --platform webkit-linux --threshold 0.1 screenshots/webkit visualci build finalize ``` -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. +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. Run the tests in CI's browsers, not on a laptop: see [Platforms](/docs/screenshots/#platforms) and [Local runs](/docs/local-runs/). diff --git a/gemini-extension.json b/gemini-extension.json index 934fae1f..e7a39871 100644 --- a/gemini-extension.json +++ b/gemini-extension.json @@ -1,6 +1,6 @@ { "name": "visualci", - "version": "0.1.53", + "version": "0.1.54", "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.", "mcpServers": { "visualci": { diff --git a/skills/visualci-deterministic/SKILL.md b/skills/visualci-deterministic/SKILL.md index be2064ae..277fd538 100644 --- a/skills/visualci-deterministic/SKILL.md +++ b/skills/visualci-deterministic/SKILL.md @@ -29,9 +29,10 @@ as a change somebody has to look at. Fix these in the tests, once, rather than a | Lazy-loaded images | Wait for every image to finish loading | | Viewport, scrollbars, pixel ratio | Fix the viewport size, hide scrollbars, use a device pixel ratio of 1 | | Text cursor, hover, focus | Hide the caret, and move the mouse away | +| Anti-aliased edges and icons a shade off | Launch Chromium with software raster on one thread ([flags](#steady-rasterising)) | | Scroll position | Scroll once the page has stopped changing, never while it still lays out | -What's left after this (anti-aliasing that differs slightly between runs) is what a +What's left after this (anti-aliasing that still differs slightly between runs, as between two machines) is what a [threshold](https://visualci.com/docs/screenshots.md#thresholds) is for. A threshold can't fix a clock or an animation: those change far more pixels than anti-aliasing does. @@ -128,6 +129,33 @@ purpose: a screenshot from a Retina laptop is twice the size of one from CI). Hi operating systems and appear only when content overflows. Hide the text cursor, and move the mouse away from anything with a hover state. +### Steady rasterising + +Chromium rasterises on the GPU, in tiles and on several threads, so the anti-aliased edges of rounded corners, borders +and small SVG icons can come out a shade different from one run to the next on the same machine: a handful of pixels, +one colour step off, with nothing else changed. Launch it with software rasterising on one thread, one colour profile +and greyscale text, and those edges come out the same every run: + +```ts +// playwright.config.ts +use: { + launchOptions: { + args: [ + '--disable-gpu', + '--force-color-profile=srgb', + '--disable-partial-raster', + '--disable-skia-runtime-opts', + '--disable-lcd-text', + '--font-render-hinting=none', + '--num-raster-threads=1', + ], + }, +}, +``` + +The same flags work with `chromium.launch({ args })` and Puppeteer's `launch({ args })`. Switching them on changes +every screenshot slightly once (greyscale text instead of subpixel text), so approve that build as the new baseline. + ### Scroll position A test that scrolls an element into view before the screenshot gets a different scroll position on each run when the diff --git a/skills/visualci-playwright/SKILL.md b/skills/visualci-playwright/SKILL.md index 074bc634..a74e5e45 100644 --- a/skills/visualci-playwright/SKILL.md +++ b/skills/visualci-playwright/SKILL.md @@ -31,7 +31,7 @@ visualci upload --platform webkit-linux --threshold 0.1 screenshots/webkit visualci build finalize ``` -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](https://visualci.com/docs/screenshots/deterministic.md#playwright) has a fixture that pins the clock, randomness and network. +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](https://visualci.com/docs/screenshots/deterministic.md#playwright) has a fixture that pins the clock, randomness and network. Launch Chromium with the [steady rasterising flags](https://visualci.com/docs/screenshots/deterministic.md#steady-rasterising) too, or rounded corners and icons can differ by a shade between runs. Run the tests in CI's browsers, not on a laptop: see [Platforms](https://visualci.com/docs/screenshots.md#platforms) and [Local runs](https://visualci.com/docs/local-runs.md).