From 1759de2b98bee8b87d2fa9af7ff7049c42a7c8b7 Mon Sep 17 00:00:00 2001 From: Jason Simmons Date: Thu, 10 Oct 2019 10:09:03 -0700 Subject: [PATCH] Allow embedders to disable causal async stacks in the Dart VM (flutter/engine#13004) Fixes https://github.com/flutter/flutter/issues/39511 --- engine/src/flutter/shell/common/switches.cc | 24 +++++++++++++-------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/engine/src/flutter/shell/common/switches.cc b/engine/src/flutter/shell/common/switches.cc index ad3b322acad..6d31cb99ff7 100644 --- a/engine/src/flutter/shell/common/switches.cc +++ b/engine/src/flutter/shell/common/switches.cc @@ -37,9 +37,17 @@ struct SwitchDesc { #define DEF_SWITCHES_END }; // clang-format on -#if !FLUTTER_RELEASE - // List of common and safe VM flags to allow to be passed directly to the VM. +#if FLUTTER_RELEASE + +// clang-format off +static const std::string gDartFlagsWhitelist[] = { + "--no-causal_async_stacks", +}; +// clang-format on + +#else + // clang-format off static const std::string gDartFlagsWhitelist[] = { "--max_profile_depth", @@ -48,10 +56,11 @@ static const std::string gDartFlagsWhitelist[] = { "--enable_mirrors", "--write-service-info", "--sample-buffer-duration", + "--no-causal_async_stacks", }; // clang-format on -#endif +#endif // FLUTTER_RELEASE // Include again for struct definition. #include "flutter/shell/common/switches.h" @@ -135,8 +144,6 @@ const std::string_view FlagForSwitch(Switch swtch) { return std::string_view(); } -#if !FLUTTER_RELEASE - static bool IsWhitelistedDartVMFlag(const std::string& flag) { for (uint32_t i = 0; i < fml::size(gDartFlagsWhitelist); ++i) { const std::string& allowed = gDartFlagsWhitelist[i]; @@ -150,8 +157,6 @@ static bool IsWhitelistedDartVMFlag(const std::string& flag) { return false; } -#endif - template static bool GetSwitchValue(const fml::CommandLine& command_line, Switch sw, @@ -329,8 +334,6 @@ Settings SettingsFromCommandLine(const fml::CommandLine& command_line) { settings.use_test_fonts = command_line.HasOption(FlagForSwitch(Switch::UseTestFonts)); -#if !FLUTTER_RELEASE - command_line.GetOptionValue(FlagForSwitch(Switch::LogTag), &settings.log_tag); std::string all_dart_flags; if (command_line.GetOptionValue(FlagForSwitch(Switch::DartFlags), &all_dart_flags)) { @@ -346,6 +349,9 @@ Settings SettingsFromCommandLine(const fml::CommandLine& command_line) { } } +#if !FLUTTER_RELEASE + command_line.GetOptionValue(FlagForSwitch(Switch::LogTag), &settings.log_tag); + settings.trace_skia = command_line.HasOption(FlagForSwitch(Switch::TraceSkia)); settings.trace_systrace =