Skip to content

Commit 67cfcfb

Browse files
authored
iOS: Remove software renderer/headless fallback (flutter#190590)
iOS is Impeller-only and requires iOS 15, so there is no software renderer. The `IOSRenderingAPI::kSoftware` path doesn't actually render in software: on a simulator whose host exposed no Metal device it selects a no-op context and surface that draw nothing. This removes that fallback and instead fails immediately when Metal is unavailable. This matches the existing runtime behaviour (which already `FML_CHECK`ed) and the macOS embedder, which refuses to start without a Metal device. The no-op path was added in flutter-team-archive/engine#54856 to stop Impeller-enabled simulators from exiting when no Metal context was available. That goes back way before we bumped the minimum supported iOS version to 15. Every device capable of running iOS 15 has a Metal-capable GPU, and a simulator requires a host with Metal support, so the fallback isn't necessary and a source of additional complexity and possibly bugs from misconfigured environments. `GPUSurfaceNoop` is now unused and `IOSRenderingAPI` is down to just one enum value. I'll remove both in followups. This also fixes a lint in `IOSSurface::Create()` that was revealed by removing `IOSSurfaceNoop`. `IOSSurfaceMetalImpeller` constructor takes a `const std::shared_ptr<IOSContext>&`, so in this code, the move was doing nothing. ```cc std::unique_ptr<IOSSurface> IOSSurface::Create(std::shared_ptr<IOSContext> context, return std::make_unique<IOSSurfaceMetalImpeller>( static_cast<CAMetalLayer*>(layer), // Metal layer std::move(context) // context ); ``` The lint wasn't triggering before because in the same method, we were constructing a fallback `IOSSurfaceNoop`, whose ctor takes a `std::shared_ptr<IOSContext>` by value, not by const ref. That move WAS doing real work, but effectively covered prevented the lint from firing. Issue: flutter#190041 <!-- Thanks for filing a pull request! Reviewers are typically assigned within a week of filing a request. To learn more about code review, see our documentation on Tree Hygiene: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md --> ## Pre-launch Checklist - [X] I read the [Contributor Guide] and followed the process outlined there for submitting PRs. - [X] I read the [AI contribution guidelines] and understand my responsibilities, or I am not using AI tools. - [X] I read the [Tree Hygiene] wiki page, which explains my responsibilities. - [X] I read and followed the [Flutter Style Guide], including [Features we expect every widget to implement]. - [X] I signed the [CLA]. - [X] I listed at least one issue that this PR fixes in the description above. - [X] I updated/added relevant documentation (doc comments with `///`). - [X] I added new tests to check the change I am making, or this PR is [test-exempt]. - [X] I followed the [breaking change policy] and added [Data Driven Fixes] where supported. - [X] All existing and new tests are passing. If you need help, consider asking for advice on the #hackers-new channel on [Discord]. If this change needs to override an active code freeze, provide a comment explaining why. The code freeze workflow can be overridden by code reviewers. See pinned issues for any active code freezes with guidance. **Note**: The Flutter team is currently trialing the use of [Gemini Code Assist for GitHub](https://developers.google.com/gemini-code-assist/docs/review-github-code). Comments from the `gemini-code-assist` bot should not be taken as authoritative feedback from the Flutter team. If you find its comments useful you can update your code accordingly, but if you are unsure or disagree with the feedback, please feel free to wait for a Flutter team member's review for guidance on which automated comments should be addressed. <!-- Links --> [Contributor Guide]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#overview [AI contribution guidelines]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#ai-contribution-guidelines [Tree Hygiene]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md [test-exempt]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#tests [Flutter Style Guide]: https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md [Features we expect every widget to implement]: https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md#features-we-expect-every-widget-to-implement [CLA]: https://cla.developers.google.com/ [flutter/tests]: https://github.com/flutter/tests [breaking change policy]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#handling-breaking-changes [Discord]: https://github.com/flutter/flutter/blob/main/docs/contributing/Chat.md [Data Driven Fixes]: https://github.com/flutter/flutter/blob/main/docs/contributing/Data-driven-Fixes.md
1 parent 7820e78 commit 67cfcfb

12 files changed

Lines changed: 19 additions & 233 deletions

‎engine/src/flutter/shell/platform/darwin/ios/BUILD.gn‎

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -169,8 +169,6 @@ source_set("flutter_framework_source") {
169169
"ios_context.mm",
170170
"ios_context_metal_impeller.h",
171171
"ios_context_metal_impeller.mm",
172-
"ios_context_noop.h",
173-
"ios_context_noop.mm",
174172
"ios_external_texture_metal.h",
175173
"ios_external_texture_metal.mm",
176174
"ios_external_view_embedder.h",
@@ -179,8 +177,6 @@ source_set("flutter_framework_source") {
179177
"ios_surface.mm",
180178
"ios_surface_metal_impeller.h",
181179
"ios_surface_metal_impeller.mm",
182-
"ios_surface_noop.h",
183-
"ios_surface_noop.mm",
184180
"platform_message_handler_ios.h",
185181
"platform_message_handler_ios.mm",
186182
"platform_view_ios.h",
@@ -328,8 +324,6 @@ if (enable_ios_unittests) {
328324
"framework/Source/VsyncWaiterIOSTest.mm",
329325
"framework/Source/accessibility_bridge_test.mm",
330326
"framework/Source/availability_version_check_test.mm",
331-
"ios_context_noop_unittests.mm",
332-
"ios_surface_noop_unittests.mm",
333327
"platform_message_handler_ios_test.mm",
334328
"platform_view_ios_test.mm",
335329
]

‎engine/src/flutter/shell/platform/darwin/ios/ios_context.mm‎

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
#include "flutter/fml/logging.h"
1010
#import "flutter/shell/platform/darwin/common/InternalFlutterSwiftCommon/InternalFlutterSwiftCommon.h"
1111
#include "flutter/shell/platform/darwin/ios/ios_context_metal_impeller.h"
12-
#include "flutter/shell/platform/darwin/ios/ios_context_noop.h"
1312
#include "flutter/shell/platform/darwin/ios/rendering_api_selection.h"
1413

1514
FLUTTER_ASSERT_ARC
@@ -25,13 +24,6 @@
2524
const std::shared_ptr<const fml::SyncSwitch>& is_gpu_disabled_sync_switch,
2625
const Settings& settings) {
2726
switch (api) {
28-
case IOSRenderingAPI::kSoftware:
29-
[FlutterLogger logImportant:@"Software rendering is incompatible with Impeller.\n"
30-
"Software rendering may have been automatically selected when "
31-
"running on a simulator in an environment that does not support "
32-
"Metal. Enabling GPU passthrough in your environment may fix "
33-
"this."];
34-
return std::make_unique<IOSContextNoop>();
3527
case IOSRenderingAPI::kMetal:
3628
return std::make_unique<IOSContextMetalImpeller>(settings, is_gpu_disabled_sync_switch);
3729
}

‎engine/src/flutter/shell/platform/darwin/ios/ios_context_noop.h‎

Lines changed: 0 additions & 32 deletions
This file was deleted.

‎engine/src/flutter/shell/platform/darwin/ios/ios_context_noop.mm‎

Lines changed: 0 additions & 31 deletions
This file was deleted.

‎engine/src/flutter/shell/platform/darwin/ios/ios_context_noop_unittests.mm‎

Lines changed: 0 additions & 24 deletions
This file was deleted.

‎engine/src/flutter/shell/platform/darwin/ios/ios_surface.h‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@ namespace flutter {
1919

2020
class IOSSurface {
2121
public:
22-
static std::unique_ptr<IOSSurface> Create(std::shared_ptr<IOSContext> context, CALayer* layer);
22+
static std::unique_ptr<IOSSurface> Create(const std::shared_ptr<IOSContext>& context,
23+
CALayer* layer);
2324

2425
std::shared_ptr<IOSContext> GetContext() const;
2526

‎engine/src/flutter/shell/platform/darwin/ios/ios_surface.mm‎

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,16 @@
66

77
#include <memory>
88

9+
#include "flutter/fml/logging.h"
910
#import "flutter/shell/platform/darwin/common/InternalFlutterSwiftCommon/InternalFlutterSwiftCommon.h"
1011
#import "flutter/shell/platform/darwin/ios/ios_surface_metal_impeller.h"
11-
#import "flutter/shell/platform/darwin/ios/ios_surface_noop.h"
1212
#include "flutter/shell/platform/darwin/ios/rendering_api_selection.h"
1313

1414
FLUTTER_ASSERT_ARC
1515

1616
namespace flutter {
1717

18-
std::unique_ptr<IOSSurface> IOSSurface::Create(std::shared_ptr<IOSContext> context,
18+
std::unique_ptr<IOSSurface> IOSSurface::Create(const std::shared_ptr<IOSContext>& context,
1919
CALayer* layer) {
2020
FML_DCHECK(layer);
2121
FML_DCHECK(context);
@@ -24,11 +24,15 @@
2424
if ([layer isKindOfClass:[CAMetalLayer class]]) {
2525
return std::make_unique<IOSSurfaceMetalImpeller>(
2626
static_cast<CAMetalLayer*>(layer), // Metal layer
27-
std::move(context) // context
27+
context // context
2828
);
2929
}
3030
}
31-
return std::make_unique<IOSSurfaceNoop>(std::move(context));
31+
// The layer MUST be a CAMetalLayer or FlutterMetalLayer, which overrides
32+
// isKindOfClass to return true for the above check. Anything else means the
33+
// rendering surface was misconfigured.
34+
FML_CHECK(false) << "Expected a Metal-backed layer for iOS rendering.";
35+
FML_UNREACHABLE();
3236
}
3337

3438
IOSSurface::IOSSurface(std::shared_ptr<IOSContext> ios_context)

‎engine/src/flutter/shell/platform/darwin/ios/ios_surface_noop.h‎

Lines changed: 0 additions & 43 deletions
This file was deleted.

‎engine/src/flutter/shell/platform/darwin/ios/ios_surface_noop.mm‎

Lines changed: 0 additions & 35 deletions
This file was deleted.

‎engine/src/flutter/shell/platform/darwin/ios/ios_surface_noop_unittests.mm‎

Lines changed: 0 additions & 33 deletions
This file was deleted.

0 commit comments

Comments
 (0)