@@ -23,21 +23,30 @@ bool ShouldUseMetalRenderer() {
2323 bool ios_version_supports_metal = false ;
2424 if (@available (iOS 10.0 , *)) {
2525 auto device = MTLCreateSystemDefaultDevice ();
26- ios_version_supports_metal = [device supportsFeatureSet: MTLFeatureSet_iOS_GPUFamily1_v3];
26+ // We need to check if the device is here since an ios 13 simulator running on an older version
27+ // of macos (below 10.15) will not actually allow metal to be used
28+ if (device != nil ) {
29+ ios_version_supports_metal = [device supportsFeatureSet: MTLFeatureSet_iOS_GPUFamily1_v3];
30+ }
2731 }
2832 return ios_version_supports_metal;
2933}
3034#endif // FLUTTER_SHELL_ENABLE_METAL
3135
3236IOSRenderingAPI GetRenderingAPIForProcess () {
33- #if TARGET_IPHONE_SIMULATOR
34- return IOSRenderingAPI::kSoftware ;
35- #endif // TARGET_IPHONE_SIMULATOR
3637
3738#if FLUTTER_SHELL_ENABLE_METAL
3839 static bool should_use_metal = ShouldUseMetalRenderer ();
3940 if (should_use_metal) {
40- return IOSRenderingAPI::kMetal ;
41+ #if TARGET_IPHONE_SIMULATOR
42+ if (@available (iOS 13.0 , *)) {
43+ return IOSRenderingAPI::kMetal ;
44+ } else {
45+ return IOSRenderingAPI::kSoftware ;
46+ }
47+ #else
48+ return IOSRenderingAPI::kMetal ;
49+ #endif // TARGET_IPHONE_SIMULATOR
4150 }
4251#endif // FLUTTER_SHELL_ENABLE_METAL
4352 return IOSRenderingAPI::kOpenGLES ;
@@ -49,9 +58,16 @@ Class GetCoreAnimationLayerClassForRenderingAPI(IOSRenderingAPI rendering_api) {
4958 return [CALayer class ];
5059 case IOSRenderingAPI::kOpenGLES :
5160 return [CAEAGLLayer class ];
52- #if !TARGET_IPHONE_SIMULATOR
5361 case IOSRenderingAPI::kMetal :
62+ #if !TARGET_IPHONE_SIMULATOR
5463 return [CAMetalLayer class ];
64+ #else
65+ // This will always be true since we filter out this case when checking if the device
66+ // supports metal
67+ if (@available (iOS 13.0 , *)) {
68+ return [CAMetalLayer class ];
69+ }
70+ break ;
5571#endif // !TARGET_IPHONE_SIMULATOR
5672 default :
5773 break ;
0 commit comments