Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit 2cf3986

Browse files
authored
[Impeller] Enable on-by-default on Android. (#54156)
Developers can control the backend in the following ways: * **Do nothing**: Impeller with Vulkan is used where Vulkan is available with a fallback to Skia with OpenGL. * **In `AndroidManifest.xml`, specify `io.flutter.embedding.android.EnableImpeller` as `false`**: Skia with OpenGL is used. * **On the command line, specify `--no-enable-impeller`**: Skia with OpenGL is used. Manifest options will take priority command line options when there is a conflict. This matches iOS behavior per flutter/flutter#124049 (closed as WAI). Fixes flutter/flutter#149360
1 parent 7f7ad74 commit 2cf3986

File tree

7 files changed

+22
-13
lines changed

7 files changed

+22
-13
lines changed

common/settings.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ struct Settings {
223223

224224
// Enable the Impeller renderer on supported platforms. Ignored if Impeller is
225225
// not supported on the platform.
226-
#if FML_OS_IOS || FML_OS_IOS_SIMULATOR
226+
#if FML_OS_ANDROID || FML_OS_IOS || FML_OS_IOS_SIMULATOR
227227
bool enable_impeller = true;
228228
#else
229229
bool enable_impeller = false;

shell/platform/android/io/flutter/embedding/engine/FlutterShellArgs.java

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,9 @@ public class FlutterShellArgs {
4444
public static final String ARG_TRACE_SYSTRACE = "--trace-systrace";
4545
public static final String ARG_KEY_TRACE_TO_FILE = "trace-to-file";
4646
public static final String ARG_TRACE_TO_FILE = "--trace-to-file";
47-
public static final String ARG_KEY_ENABLE_IMPELLER = "enable-impeller";
48-
public static final String ARG_ENABLE_IMPELLER = "--enable-impeller";
47+
public static final String ARG_KEY_TOGGLE_IMPELLER = "enable-impeller";
48+
public static final String ARG_ENABLE_IMPELLER = "--enable-impeller=true";
49+
public static final String ARG_DISABLE_IMPELLER = "--enable-impeller=false";
4950
public static final String ARG_KEY_ENABLE_VULKAN_VALIDATION = "enable-vulkan-validation";
5051
public static final String ARG_ENABLE_VULKAN_VALIDATION = "--enable-vulkan-validation";
5152
public static final String ARG_KEY_DUMP_SHADER_SKP_ON_SHADER_COMPILATION =
@@ -121,8 +122,12 @@ public static FlutterShellArgs fromIntent(@NonNull Intent intent) {
121122
if (intent.hasExtra(ARG_KEY_TRACE_TO_FILE)) {
122123
args.add(ARG_TRACE_TO_FILE + "=" + intent.getStringExtra(ARG_KEY_TRACE_TO_FILE));
123124
}
124-
if (intent.getBooleanExtra(ARG_KEY_ENABLE_IMPELLER, false)) {
125-
args.add(ARG_ENABLE_IMPELLER);
125+
if (intent.hasExtra(ARG_KEY_TOGGLE_IMPELLER)) {
126+
if (intent.getBooleanExtra(ARG_KEY_TOGGLE_IMPELLER, false)) {
127+
args.add(ARG_ENABLE_IMPELLER);
128+
} else {
129+
args.add(ARG_DISABLE_IMPELLER);
130+
}
126131
}
127132
if (intent.getBooleanExtra(ARG_KEY_ENABLE_VULKAN_VALIDATION, false)) {
128133
args.add(ARG_ENABLE_VULKAN_VALIDATION);

shell/platform/android/io/flutter/embedding/engine/loader/FlutterLoader.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -345,8 +345,12 @@ public void ensureInitializationComplete(
345345
shellArgs.add("--prefetched-default-font-manager");
346346

347347
if (metaData != null) {
348-
if (metaData.getBoolean(ENABLE_IMPELLER_META_DATA_KEY, false)) {
349-
shellArgs.add("--enable-impeller");
348+
if (metaData.containsKey(ENABLE_IMPELLER_META_DATA_KEY)) {
349+
if (metaData.getBoolean(ENABLE_IMPELLER_META_DATA_KEY)) {
350+
shellArgs.add("--enable-impeller=true");
351+
} else {
352+
shellArgs.add("--enable-impeller=false");
353+
}
350354
}
351355
if (metaData.getBoolean(ENABLE_VULKAN_VALIDATION_META_DATA_KEY, false)) {
352356
shellArgs.add("--enable-vulkan-validation");

shell/platform/android/test/io/flutter/embedding/engine/loader/FlutterLoaderTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@ public void itSetsEnableImpellerFromMetaData() {
228228
flutterLoader.ensureInitializationComplete(ctx, null);
229229
shadowOf(getMainLooper()).idle();
230230

231-
final String enableImpellerArg = "--enable-impeller";
231+
final String enableImpellerArg = "--enable-impeller=true";
232232
ArgumentCaptor<String[]> shellArgsCaptor = ArgumentCaptor.forClass(String[].class);
233233
verify(mockFlutterJNI, times(1))
234234
.init(eq(ctx), shellArgsCaptor.capture(), anyString(), anyString(), anyString(), anyLong());

shell/platform/darwin/ios/framework/Source/FlutterDartProject.mm

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -176,10 +176,6 @@ static BOOL DoesHardwareSupportWideGamut() {
176176
settings.enable_wide_gamut = enableWideGamut;
177177
#endif
178178

179-
// TODO(dnfield): We should reverse the order for all these settings so that command line options
180-
// are preferred to plist settings. https://github.com/flutter/flutter/issues/124049
181-
// Whether to enable Impeller. If the command line explicitly
182-
// specified an option for this, ignore what's in the plist.
183179
if (!command_line.HasOption("enable-impeller")) {
184180
// Next, look in the app bundle.
185181
NSNumber* enableImpeller = [bundle objectForInfoDictionaryKey:@"FLTEnableImpeller"];

testing/scenario_app/android/app/src/androidTest/java/dev/flutter/TestRunner.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ public void onCreate(@Nullable Bundle arguments) {
2323
"--enable-impeller=true",
2424
"--impeller-backend=" + arguments.getString("impeller-backend", "vulkan")
2525
};
26+
} else {
27+
engineArguments = new String[] {"--enable-impeller=false"};
2628
}
2729
FlutterRenderer.debugDisableSurfaceClear = true;
2830
if ("true".equals(arguments.getString("force-surface-producer-surface-texture"))) {

testing/scenario_app/bin/run_android_tests.dart

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -417,7 +417,9 @@ Future<void> _run({
417417
if (smokeTestFullPath != null)
418418
'-e class $smokeTestFullPath',
419419
if (enableImpeller)
420-
'-e enable-impeller true',
420+
'-e enable-impeller true'
421+
else
422+
'-e enable-impeller false',
421423
if (impellerBackend != null)
422424
'-e impeller-backend ${impellerBackend.name}',
423425
if (forceSurfaceProducerSurfaceTexture)

0 commit comments

Comments
 (0)