Canvas ゴールデンの perceptualPrecision を戻す(#49) - #55
Merged
Merged
Conversation
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 Report✅ All modified and coverable lines are covered by tests. 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. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 testpasses locallyxcrun swift-format lint --recursive --strict Sources TestspassesCHANGELOG.md(for user-visible changes) — テスト専用依存の変更で、ライブラリ利用者には影響しないため対象外