diff --git a/engine/src/flutter/shell/common/shell.cc b/engine/src/flutter/shell/common/shell.cc index c6006f1096..78c0821ae3 100644 --- a/engine/src/flutter/shell/common/shell.cc +++ b/engine/src/flutter/shell/common/shell.cc @@ -84,7 +84,13 @@ void Shell::InitStandalone(fxl::CommandLine command_line, fml::icu::InitializeICU(icu_data_path); +#if FLUTTER_RUNTIME_MODE == FLUTTER_RUNTIME_MODE_DEBUG + if (!command_line.HasOption(FlagForSwitch(Switch::SkiaDeterministicRendering))) { + SkGraphics::Init(); + } +#else SkGraphics::Init(); +#endif blink::Settings settings; settings.application_library_path = application_library_path; diff --git a/engine/src/flutter/shell/common/switches.h b/engine/src/flutter/shell/common/switches.h index 6d5bd03a80..397b14417d 100644 --- a/engine/src/flutter/shell/common/switches.h +++ b/engine/src/flutter/shell/common/switches.h @@ -58,6 +58,13 @@ DEF_SWITCH(EnableSoftwareRendering, "Enable rendering using the Skia software backend. This is useful" "when testing Flutter on emulators. By default, Flutter will" "attempt to either use OpenGL or Vulkan.") +DEF_SWITCH(SkiaDeterministicRendering, + "skia-deterministic-rendering", + "Skips the call to SkGraphics::Init(), thus avoiding swapping out" + "some Skia function pointers based on available CPU features. This" + "is used to obtain 100% deterministic behavior in Skia rendering." + "This flag is ignored when the runtime mode is anything other than" + "debug.") DEF_SWITCH(EnableTxt, "enable-txt", "Enable libtxt as the text shaping library instead of Blink.") diff --git a/engine/src/flutter/shell/platform/android/io/flutter/app/FlutterActivityDelegate.java b/engine/src/flutter/shell/platform/android/io/flutter/app/FlutterActivityDelegate.java index 4472b8b194..b136dd377b 100644 --- a/engine/src/flutter/shell/platform/android/io/flutter/app/FlutterActivityDelegate.java +++ b/engine/src/flutter/shell/platform/android/io/flutter/app/FlutterActivityDelegate.java @@ -298,6 +298,9 @@ public final class FlutterActivityDelegate if (intent.getBooleanExtra("enable-software-rendering", false)) { args.add("--enable-software-rendering"); } + if (intent.getBooleanExtra("skia-deterministic-rendering", false)) { + args.add("--skia-deterministic-rendering"); + } if (intent.getBooleanExtra("trace-skia", false)) { args.add("--trace-skia"); }