Skip to content

Commit c8f665c

Browse files
Allow embedders to disable causal async stacks in the Dart VM (flutter#13004)
Fixes flutter#39511
1 parent ed39280 commit c8f665c

File tree

1 file changed

+15
-9
lines changed

1 file changed

+15
-9
lines changed

shell/common/switches.cc

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,17 @@ struct SwitchDesc {
3737
#define DEF_SWITCHES_END };
3838
// clang-format on
3939

40-
#if !FLUTTER_RELEASE
41-
4240
// List of common and safe VM flags to allow to be passed directly to the VM.
41+
#if FLUTTER_RELEASE
42+
43+
// clang-format off
44+
static const std::string gDartFlagsWhitelist[] = {
45+
"--no-causal_async_stacks",
46+
};
47+
// clang-format on
48+
49+
#else
50+
4351
// clang-format off
4452
static const std::string gDartFlagsWhitelist[] = {
4553
"--max_profile_depth",
@@ -48,10 +56,11 @@ static const std::string gDartFlagsWhitelist[] = {
4856
"--enable_mirrors",
4957
"--write-service-info",
5058
"--sample-buffer-duration",
59+
"--no-causal_async_stacks",
5160
};
5261
// clang-format on
5362

54-
#endif
63+
#endif // FLUTTER_RELEASE
5564

5665
// Include again for struct definition.
5766
#include "flutter/shell/common/switches.h"
@@ -135,8 +144,6 @@ const std::string_view FlagForSwitch(Switch swtch) {
135144
return std::string_view();
136145
}
137146

138-
#if !FLUTTER_RELEASE
139-
140147
static bool IsWhitelistedDartVMFlag(const std::string& flag) {
141148
for (uint32_t i = 0; i < fml::size(gDartFlagsWhitelist); ++i) {
142149
const std::string& allowed = gDartFlagsWhitelist[i];
@@ -150,8 +157,6 @@ static bool IsWhitelistedDartVMFlag(const std::string& flag) {
150157
return false;
151158
}
152159

153-
#endif
154-
155160
template <typename T>
156161
static bool GetSwitchValue(const fml::CommandLine& command_line,
157162
Switch sw,
@@ -329,8 +334,6 @@ Settings SettingsFromCommandLine(const fml::CommandLine& command_line) {
329334
settings.use_test_fonts =
330335
command_line.HasOption(FlagForSwitch(Switch::UseTestFonts));
331336

332-
#if !FLUTTER_RELEASE
333-
command_line.GetOptionValue(FlagForSwitch(Switch::LogTag), &settings.log_tag);
334337
std::string all_dart_flags;
335338
if (command_line.GetOptionValue(FlagForSwitch(Switch::DartFlags),
336339
&all_dart_flags)) {
@@ -346,6 +349,9 @@ Settings SettingsFromCommandLine(const fml::CommandLine& command_line) {
346349
}
347350
}
348351

352+
#if !FLUTTER_RELEASE
353+
command_line.GetOptionValue(FlagForSwitch(Switch::LogTag), &settings.log_tag);
354+
349355
settings.trace_skia =
350356
command_line.HasOption(FlagForSwitch(Switch::TraceSkia));
351357
settings.trace_systrace =

0 commit comments

Comments
 (0)