Skip to content

chore(preprod): Include idiom and colorspace info in asssets.json#2860

Merged
NicoHinderling merged 1 commit intomasterfrom
pass-idiom-and-colorspace-info
Oct 22, 2025
Merged

chore(preprod): Include idiom and colorspace info in asssets.json#2860
NicoHinderling merged 1 commit intomasterfrom
pass-idiom-and-colorspace-info

Conversation

@NicoHinderling
Copy link
Copy Markdown
Contributor

So we can show users why they have duplicate images despite not having intended to (and nudge them to consider app thinning on their side)

@NicoHinderling NicoHinderling requested review from a team as code owners October 21, 2025 22:06
Comment on lines +167 to +168
let idiomValue = key.getUInt(forKey: "themeIdiom")
let colorSpaceID = rendition.getUInt(forKey: "colorSpaceID")
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: The getUInt extension uses perform(Selector(...)) without exception handling, which can cause a crash if the selector does not exist on the target object.
(Severity: Critical 0.85 | Confidence: 0.95)

🔍 Detailed Analysis

The getUInt(forKey:) extension method is called on lines 167 and 168 to retrieve themeIdiom and colorSpaceID. This method uses perform(Selector(key)) without a try-catch block. If the key or rendition objects, which are from Apple's private frameworks, do not implement methods corresponding to these selectors, the application will crash with an "Unrecognized Selector" exception. This can happen with different asset types or macOS versions. The codebase already contains a safeValueForKey function that handles this exact scenario, but it is not used for these new calls.

💡 Suggested Fix

Modify the getUInt extension to handle cases where the selector does not exist. Either wrap the perform(Selector(key)) call in a try-catch block or check responds(to:) before making the call to prevent a crash.

🤖 Prompt for AI Agent
Fix this bug. In
apple-catalog-parsing/native/swift/AssetCatalogParser/Sources/AssetCatalogParser/AssetCatalogReader.swift
at lines 167-168: The `getUInt(forKey:)` extension method is called on lines 167 and 168
to retrieve `themeIdiom` and `colorSpaceID`. This method uses `perform(Selector(key))`
without a `try-catch` block. If the `key` or `rendition` objects, which are from Apple's
private frameworks, do not implement methods corresponding to these selectors, the
application will crash with an "Unrecognized Selector" exception. This can happen with
different asset types or macOS versions. The codebase already contains a
`safeValueForKey` function that handles this exact scenario, but it is not used for
these new calls.

Did we get this right? 👍 / 👎 to inform future reviews.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The crash risk would only be if the selector itself didn't exist, but these are standard CoreUI selectors that do exist on these objects

@NicoHinderling NicoHinderling merged commit 64ca848 into master Oct 22, 2025
27 checks passed
@NicoHinderling NicoHinderling deleted the pass-idiom-and-colorspace-info branch October 22, 2025 16:30
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.

2 participants