Skip to content

Capture: hold animated images and SVG animations on their first frame - #64

Merged
tmashara merged 2 commits into
mainfrom
claude/issue-42-freeze-images
Oct 29, 2026
Merged

tmashara merged 2 commits into
mainfrom
claude/issue-42-freeze-images

Conversation

@tmashara

@tmashara tmashara commented Oct 29, 2026 •

Copy link
Copy Markdown
Owner

What

Animated images (GIF, APNG, animated WebP) and SVG animations (SMIL, inline or as <img>) now show their first frame on both sides. launch() in src/run.ts passes --blink-settings=imageAnimationPolicy=2 on the bundled Chromium and the system Chrome fallback. The report's "What was neutralized" block, README, docs/how-it-works.md and the skill reference say so.

Why

reducedMotion and the fake clock stop none of these, so a page with a GIF either scored unstable pixels or diffed on whichever frame each side landed on. Checked on Chromium 151 headless shell and system Chrome 156: with policy 2, GIF/APNG/WebP, a play-once GIF, a CSS background-image GIF, SVG-in-<img>, inline SMIL and a GIF inserted after load all hold frame 0. The policy is renderer-wide from launch, so an image never starts animating. Policy 1 (animate once) is wrong: play-once images end on the last frame.

Not the issue's canvas/data-URL approach: drawImage of a cross-origin image taints the canvas so toDataURL throws (most sites serve images from CDNs), it misses CSS backgrounds and SMIL, and it changes the DOM that --computed reads. A page.route rewrite would bypass routeFromHAR (--cache-right).

Scrollbars: no change

The issue assumes scrollbars show up, for example on the installed-Chrome fallback. They don't: Playwright adds --hide-scrollbars whenever it launches headless, and renderdiff always launches headless, the Chrome fallback included. An overflow: scroll box measures offsetWidth - clientWidth == 0 on both paths with no args of ours. Passing the flag ourselves would only repeat it.

The repeated blink-settings (fragile on purpose)

Our --blink-settings replaces the one Playwright passes in headless mode (primaryHoverType=2,availableHoverTypes=2,primaryPointerType=4,availablePointerTypes=4), because Chromium uses the last value of a repeated switch. Those values are what make Linux CI (no pointer device) report (hover: hover) / (pointer: fine), so ours repeats them. I found no better way: Playwright has no public defaultArgs (that's Puppeteer), ignoreDefaultArgs needs the same exact string, and CDP Browser.getBrowserCommandLine is refused without --enable-automation. If Playwright changes its values, ours win silently, but both sides share the browser, so the comparison stays symmetric. A one-line comment says why the values are there. Linux CI is the real check for them, since a Mac reports hover/fine even without them.

Behaviour change

Pages with animated images now capture frame 0. Accepted diffs or --rerun-failed state recorded on another frame may not match.

Tests

  • The animated fixture (identical on both sides) gains a 4-frame GIF (tests/fixtures/shared/img/blink.gif, 417 bytes, base.css colours) and an inline SVG whose SMIL fill interpolates continuously. The SVG makes the check deterministic: with only the GIF, the two stability shots sometimes land on the same frame. The fixture server serves .gif.
  • "a static page reports nothing unstable" in tests/visual/guardrails.test.ts is the test that catches a regression. Without the flag it failed 3 runs out of 3 (unstablePixels 8192, both 64x64 boxes). With the flag it passed 3 out of 3. The "identical" diff test can't see this, because unstable pixels are left out of the diff.
  • typecheck, lint, format:check, npm test (294 pass) and npm run test:visual (330 pass, rebased on Capture: name a route that is not an HTML page #63) all pass on macOS.

Fixes #42

🤖 Generated with Claude Code

tmashara and others added 2 commits October 29, 2026 17:11
A Blink launch setting (imageAnimationPolicy=2) on both launch paths. It
replaces Playwright's own headless --blink-settings, so the hover/pointer
values are repeated. The animated fixture gains a GIF and a SMIL fill.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@tmashara
tmashara force-pushed the claude/issue-42-freeze-images branch from f752304 to 0e69233 Compare October 29, 2026 16:15
@tmashara
tmashara merged commit 5f7e155 into main Oct 29, 2026
3 checks passed
@tmashara
tmashara deleted the claude/issue-42-freeze-images branch October 29, 2026 16:24
@tmashara tmashara mentioned this pull request Oct 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Freeze animated images and hide scrollbars

1 participant