From a9a80ef38615e1a69ec56dc8b00894fb525ecc7a Mon Sep 17 00:00:00 2001 From: Corentin Wallez Date: Mon, 7 Feb 2022 16:12:00 +0000 Subject: [PATCH] Guard for [MTLDevice counterSets] being null. Bug: dawn:1102 Change-Id: I1c8fffba65cba0b04ef72018013f027f0a814f90 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/79361 Reviewed-by: Austin Eng Commit-Queue: Corentin Wallez Auto-Submit: Corentin Wallez --- src/dawn/native/metal/BackendMTL.mm | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/dawn/native/metal/BackendMTL.mm b/src/dawn/native/metal/BackendMTL.mm index 52bcda76a0..21515a7b74 100644 --- a/src/dawn/native/metal/BackendMTL.mm +++ b/src/dawn/native/metal/BackendMTL.mm @@ -193,6 +193,12 @@ namespace dawn::native::metal { API_AVAILABLE(macos(10.15), ios(14.0)) { // MTLDevice’s counterSets property declares which counter sets it supports. Check // whether it's available on the device before requesting a counter set. + + // On some systems, [device counterSets] is null and not an empty array. + if ([device counterSets] == nil) { + return false; + } + id counterSet = nil; for (id set in [device counterSets]) { if ([set.name caseInsensitiveCompare:counterSetName] == NSOrderedSame) {