Guard macOS-only MTLDevice selectors for iOS - #115
Closed
yorgunkral31 wants to merge 1 commit into
Closed
yorgunkral31 wants to merge 1 commit into
yorgunkral31 wants to merge 1 commit into
Conversation
MTLDevice location and recommendedMaxWorkingSetSize are unavailable on iOS and crash with unrecognized selector (verified on iPhone 16 Pro / A18 Pro). iOS devices are always integrated and share system memory, so report INTEGRATED and use ProcessInfo physicalMemory instead.
squidbus
reviewed
Sep 20, 2026
Comment on lines
+3836
to
+3840
| #if TARGET_OS_IPHONE | ||
| capabilities.preferHDR = NS::ProcessInfo::processInfo()->physicalMemory() > (512 * 1024 * 1024); | ||
| #else | ||
| capabilities.preferHDR = mtl->recommendedMaxWorkingSetSize() > (512 * 1024 * 1024); | ||
| #endif |
Contributor
There was a problem hiding this comment.
You might as well update this to just check description.dedicatedVideoMemory since it's the same values.
squidbus
reviewed
Sep 20, 2026
| #if TARGET_OS_IPHONE | ||
| description.dedicatedVideoMemory = NS::ProcessInfo::processInfo()->physicalMemory(); | ||
| #else | ||
| description.dedicatedVideoMemory = mtl->recommendedMaxWorkingSetSize(); |
Contributor
There was a problem hiding this comment.
This does exist on iOS 16+ by the way, if we could use this on those versions instead.
Contributor
|
I did this in a bit more proper way in #116 along with some macOS 27 fixes. |
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.
MTLDevice.locationandMTLDevice.recommendedMaxWorkingSetSizeare macOS-only selectors. The Metal backend calls both unconditionally during device initialization, which crashes on iOS hardware with-[AGXG17PDevice location]: unrecognized selector sent to instance(verified on an iPhone 16 Pro / A18 Pro while testing hedge-dev/UnleashedRecomp#1767 with the native Metal backend on device).This guards the call sites for
TARGET_OS_IPHONE:INTEGRATED(iOS devices are always integrated), andNSProcessInfo.physicalMemoryinstead (unified memory shares system RAM).No behavior change on macOS. Related to the pending iOS support work in #102 — these guards are needed by any iOS target that builds the Metal backend, independent of that PR.