Skip to content

Skip icon regeneration when inputs are unchanged#8

Open
DanielCech wants to merge 1 commit into
masterfrom
feat/dc/avoid-icon-duplication
Open

Skip icon regeneration when inputs are unchanged#8
DanielCech wants to merge 1 commit into
masterfrom
feat/dc/avoid-icon-duplication

Conversation

@DanielCech
Copy link
Copy Markdown
Member

@DanielCech DanielCech commented Jun 2, 2026

Problem

VersionIcon regenerated the app icon on every build, even when nothing changed. Because the rendering pipeline (Core Image compositing, text drawing) is not byte-deterministic, the output PNG differed slightly on each run — so git constantly showed the icons as modified, which was annoying and polluted diffs.

Solution

Each generated icon now carries a small, human-readable JSON record embedded as a standard PNG tEXt chunk. It describes all inputs that produced the icon: version text, font, colors, position ratios, pixel size, and SHA-256 hashes of the binary inputs (original icon, ribbon, title overlay).

On the next run the stored record is compared with the current inputs before rendering:

  • Match → the file is left untouched (Keeping original file - no change), so git sees no modification. Rendering is skipped entirely, which also makes repeat builds faster.
  • Mismatch (new version, changed style, different source icon…) → the icon is regenerated and stamped with the updated record.

The chunk is an ancillary PNG chunk, so Xcode, actool, and any image viewer simply ignore it. You can inspect it with strings Icon.png.

Changes

  • PNGMetadata.swift — minimal, dependency-free PNG tEXt chunk reader/writer
  • IconState.swift — the IconStateRecord input fingerprint (uses CryptoKit, no new dependencies)
  • IconGeneration.swift — skip-before-render check + stamping the record into the output
  • Removed the old unused TIFF-based image comparison
  • Two new end-to-end tests: identical inputs keep all icons byte-identical; a changed input regenerates

Note

The first run after this change regenerates all icons once (existing files have no metadata yet). After that they stay stable.

@DanielCech DanielCech requested a review from ipek June 2, 2026 18:22
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.

1 participant