Skip to content

Canvas ゴールデンの perceptualPrecision を戻す(#49) - #55

Merged
temoki merged 1 commit into
mainfrom
restore-perceptual-precision
Sep 21, 2026
Merged

temoki merged 1 commit into
mainfrom
restore-perceptual-precision

Conversation

@temoki

@temoki temoki commented Sep 21, 2026

Copy link
Copy Markdown
Owner

Summary

#48 で外していた perceptualPrecision を Canvas ゴールデン比較に戻す。

原因だった swift-snapshot-testing の不具合(知覚差分比較が CIAreaAverage の inputExtent に素の CGRect を渡し、macOS 27 の Core Image が -[NSConcreteValue CGRectValue] 例外でテストプロセスごと落とす)が上流で修正され、pointfreeco/swift-snapshot-testing#1120 として 1.19.6 でリリースされた。

  • Package.swift の swift-snapshot-testing を from: "1.18.0" → from: "1.19.6"
  • .canvasGolden を .image(precision: 0.995, perceptualPrecision: 0.98) に復帰
  • CLAUDE.md の「perceptualPrecision を足すな」という記述を、「1.19.6 以上が必要、だから下限を切ってある」に更新

依存の下限を上げている理由

from: "1.18.0" のままでも手元では 1.19.6 に解決されるが、下限は 1.19.6 に切る必要がある。知覚差分の経路はバイト列が一致しない時にしか到達しないので、古いバージョンに解決された環境でもゴールデンが完全一致していればテストは緑のまま通ってしまい、アンチエイリアスがずれた環境で初めてプロセスごと落ちる。

検証方法

フルスイートが緑になっただけでは検証にならない。 上と同じ理由で、ゴールデンを録ったマシンでは知覚差分の経路が実行されないため。

そこで使い捨てのプローブを書き、意図的に異なる 2 枚のレンダリング結果を Snapshotting.canvasGolden.diffing.diff(a, b) に直接通して、クラッシュせず差分が報告されることを確認した(プローブはコミットしていない)。

実行環境は macOS 27.0 (26A428) / Xcode 27.0 (27A266a) — #49 で落ちることを確認していた組み合わせそのもの。

ゴールデン画像は録り直していない。知覚比較はバイト比較より厳密に緩いため、録ったときの前提を壊さない。

Related issue

Fixes #49

Checklist

  • swift test passes locally
  • xcrun swift-format lint --recursive --strict Sources Tests passes
  • Added/updated tests for new behavior (or not applicable) — 比較方法の変更のみ。検証は上記のプローブで実施し、コミットはしていない
  • Updated CHANGELOG.md (for user-visible changes) — テスト専用依存の変更で、ライブラリ利用者には影響しないため対象外
  • Golden snapshots — 録り直し不要(知覚比較はバイト比較より緩いため、既存ゴールデンがそのまま通る)

swift-snapshot-testing 1.19.6 fixes the crash that forced byte-wise comparison
in #48: the perceptual path passed a bare CGRect as CIAreaAverage's inputExtent,
which Core Image on macOS 27 rejected with an uncaught -[NSConcreteValue
CGRectValue] exception, killing the whole test process
(pointfreeco/swift-snapshot-testing#1120).

Floor the dependency at 1.19.6 rather than leaving it at 1.18.0. The perceptual
path is only reached when bytes differ, so an older resolution would keep
passing locally and crash wherever antialiasing drifts.

Verified on macOS 27.0 (26A428) / Xcode 27.0 (27A266a) — the combination that
crashed — by passing two deliberately different renders through
Snapshotting.canvasGolden.diffing.diff, which now reports a difference instead
of taking down the process. A green suite alone would not have shown this: the
goldens match byte for byte on the machine that recorded them, so the perceptual
path never runs.

The goldens themselves are unchanged; perceptual comparison is strictly more
permissive than the byte-wise one they were recorded against.
@codecov

codecov Bot commented Sep 21, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 93.76%. Comparing base (a5c4f79) to head (bdbc7cd).

Additional details and impacted files
@@           Coverage Diff           @@
##             main      #55   +/-   ##
=======================================
  Coverage   93.76%   93.76%           
=======================================
  Files          16       16           
  Lines         946      946           
=======================================
  Hits          887      887           
  Misses         59       59           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@temoki
temoki merged commit 56ce2b4 into main Sep 21, 2026
6 checks passed
@temoki
temoki deleted the restore-perceptual-precision branch September 21, 2026 23:32
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.

macOS 27 で swift-snapshot-testing の知覚差分比較が CGRectValue 例外でテストプロセスごとクラッシュする

1 participant