From 7877780b10e6c554680426a7e0dd8f7d2ae020dc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=87a=C4=9Fan=20=C3=96zcan?= Date: Sun, 20 Sep 2026 19:46:56 +0300 Subject: [PATCH] fix: guard macOS-only MTLDevice selectors for iOS 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. --- plume_metal.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/plume_metal.cpp b/plume_metal.cpp index 373c87e..7fd29b7 100644 --- a/plume_metal.cpp +++ b/plume_metal.cpp @@ -3796,10 +3796,20 @@ namespace plume { const std::string deviceName(mtl->name()->utf8String()); description.name = deviceName; +#if TARGET_OS_IPHONE + // MTLDevice location and recommendedMaxWorkingSetSize are macOS-only selectors; + // iOS devices are always integrated and share system memory. + description.type = RenderDeviceType::INTEGRATED; +#else description.type = mapDeviceType(mtl->location()); +#endif description.driverVersion = 1; // Unavailable description.vendor = mtl->supportsFamily(MTL::GPUFamilyApple1) ? RenderDeviceVendor::APPLE : getRenderDeviceVendor(mtl->registryID()); +#if TARGET_OS_IPHONE + description.dedicatedVideoMemory = NS::ProcessInfo::processInfo()->physicalMemory(); +#else description.dedicatedVideoMemory = mtl->recommendedMaxWorkingSetSize(); +#endif timestampCounterSet = findTimestampCounterSet(); if (timestampCounterSet != nullptr) { @@ -3823,7 +3833,11 @@ namespace plume { capabilities.resolveModes = false; capabilities.scalarBlockLayout = true; capabilities.presentWait = true; +#if TARGET_OS_IPHONE + capabilities.preferHDR = NS::ProcessInfo::processInfo()->physicalMemory() > (512 * 1024 * 1024); +#else capabilities.preferHDR = mtl->recommendedMaxWorkingSetSize() > (512 * 1024 * 1024); +#endif capabilities.dynamicDepthBias = true; capabilities.uma = mtl->hasUnifiedMemory(); capabilities.gpuUploadHeap = capabilities.uma;