Skip to content

Commit ec77d6b

Browse files
committed
journeys: the same steady Chromium raster flags as the page screenshots (software raster, one thread, sRGB, greyscale text)
1 parent b4b3bf5 commit ec77d6b

5 files changed

Lines changed: 20 additions & 14 deletions

File tree

‎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) {

‎scripts/screenshots/raster.mjs‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// Chromium flags for screenshots that come out the same every run: software rasterising on one thread, one colour
2+
// profile and greyscale text. With the GPU and partial raster, small SVG icons and rounded corners' anti-aliased edges
3+
// came out a shade different from run to run (4 Dec 2026: 28 pixels on the site header's button in a journey).
4+
export const STEADY_RASTER = [
5+
'--disable-gpu',
6+
'--force-color-profile=srgb',
7+
'--disable-partial-raster',
8+
'--disable-skia-runtime-opts',
9+
'--disable-lcd-text',
10+
'--font-render-hinting=none',
11+
'--num-raster-threads=1',
12+
]

0 commit comments

Comments
 (0)