Skip to content

Commit 85d1efd

Browse files
Pinned the fixture encode to one thread and reported what else moves the pixels (#52)
x264 splits a frame across its worker threads and splits it differently for a different thread count, so the fixture video re-encoded to different bytes on a differently-sized runner. Those bytes are on screen in the snapshots, as box offsets, sizes and the bitrate plot's shape, which is a visual change with nothing in the diff behind it. Verified on ffmpeg 6.1.1-3ubuntu5: -threads 1 reproduces byte for byte, while 1, 2, 4 and auto each give a different file. The two things left that move pixels on their own are now printed rather than left to be guessed at: the runner image behind the ubuntu-24.04 label, which is rebuilt weekly with new fonts, and the fixture's sha256. A branch behind main also reads as changes of its own, since Chromatic diffs against the branch's own last build, so the run says how far behind it is and asks for a merge first. Claude-Session: https://claude.ai/code/session_01CaXNNi6tdDMUPQMpsNz97S Co-authored-by: Claude <noreply@anthropic.com>
1 parent b8f032a commit 85d1efd

3 files changed

Lines changed: 59 additions & 0 deletions

File tree

‎.github/workflows/chromatic-playwright.yml‎

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,28 @@ jobs:
2020
with:
2121
fetch-depth: 0
2222

23+
- name: Report the runner image
24+
# The ubuntu-24.04 label is not a fixed machine: the image behind it is rebuilt roughly
25+
# weekly, and a new one brings new fonts and rasterizer libraries, which move text pixels
26+
# on their own. Printed so a snapshot diff with no code change behind it can be checked
27+
# against the image its baseline was drawn on.
28+
run: |
29+
echo "Runner image: ${ImageOS:-unknown} ${ImageVersion:-unknown}"
30+
31+
- name: Report how far the branch is behind main
32+
# Chromatic takes the branch's own last build as the baseline, so a branch that has not
33+
# seen main in a week diffs against a week-old UI and reports main's changes as this
34+
# branch's. Merge main in before reading the result.
35+
if: github.ref != 'refs/heads/main'
36+
run: |
37+
git fetch --no-tags --quiet origin main
38+
behind=$(git rev-list --count HEAD..origin/main)
39+
if [ "$behind" -eq 0 ]; then
40+
echo "Branch is up to date with main."
41+
else
42+
echo "::notice::This branch is $behind commit(s) behind main. Chromatic diffs it against the branch's own last build, so the changes it reports may be main's rather than this branch's; merge main in before reading them."
43+
fi
44+
2345
- name: Set up Node
2446
uses: actions/setup-node@v7
2547
with:
@@ -47,6 +69,14 @@ jobs:
4769
env:
4870
CHROMATIC_STATIC_VERSION: "true"
4971

72+
- name: Report the fixture video's hash
73+
# The fixture is re-encoded on every run (tests/fixtures/demoVideo.ts) and its bytes reach
74+
# the snapshots, so an encode that came out different is a visual change with nothing in
75+
# the diff to explain it. Printed rather than asserted against a stored hash: the expected
76+
# value would have to be re-pinned for every ffmpeg version.
77+
if: always()
78+
run: sha256sum tests/fixtures/.generated/* || echo "No generated fixture to hash."
79+
5080
- name: Run Chromatic
5181
uses: chromaui/action@v18.8.0
5282
with:

‎.github/workflows/chromatic-storybook.yml‎

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,28 @@ jobs:
2020
with:
2121
fetch-depth: 0
2222

23+
- name: Report the runner image
24+
# The ubuntu-24.04 label is not a fixed machine: the image behind it is rebuilt roughly
25+
# weekly, and a new one brings new fonts and rasterizer libraries, which move text pixels
26+
# on their own. Printed so a snapshot diff with no code change behind it can be checked
27+
# against the image its baseline was drawn on.
28+
run: |
29+
echo "Runner image: ${ImageOS:-unknown} ${ImageVersion:-unknown}"
30+
31+
- name: Report how far the branch is behind main
32+
# Chromatic takes the branch's own last build as the baseline, so a branch that has not
33+
# seen main in a week diffs against a week-old UI and reports main's changes as this
34+
# branch's. Merge main in before reading the result.
35+
if: github.ref != 'refs/heads/main'
36+
run: |
37+
git fetch --no-tags --quiet origin main
38+
behind=$(git rev-list --count HEAD..origin/main)
39+
if [ "$behind" -eq 0 ]; then
40+
echo "Branch is up to date with main."
41+
else
42+
echo "::notice::This branch is $behind commit(s) behind main. Chromatic diffs it against the branch's own last build, so the changes it reports may be main's rather than this branch's; merge main in before reading them."
43+
fi
44+
2345
- name: Set up Node
2446
uses: actions/setup-node@v7
2547
with:

‎tests/fixtures/demoVideo.ts‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,13 @@ export function buildFixtureVideo(): string {
5252
`sine=frequency=440:duration=${FIXTURE_SECONDS}`,
5353
"-c:v",
5454
"libx264",
55+
// x264 splits a frame across its worker threads, and how it splits depends on how many
56+
// there are, which is the runner's core count. Left to itself the same command re-encodes
57+
// to different bytes on a differently-sized machine, and those bytes are on screen in the
58+
// snapshots (box offsets, sizes, the bitrate plot's shape), so the run reads as a visual
59+
// change with no code change behind it. One thread is slower and deterministic.
60+
"-threads",
61+
"1",
5562
"-preset",
5663
"veryfast",
5764
"-crf",

0 commit comments

Comments
 (0)