From 191884bbc1e5a8b6e65db5bc8fed93f68e5ccf60 Mon Sep 17 00:00:00 2001 From: Mehmet Fidanboylu Date: Fri, 22 Feb 2019 14:49:15 -0800 Subject: [PATCH] New setting to decide whether we want the engine to load ICU mapping. (flutter/engine#7928) --- engine/src/flutter/common/settings.cc | 2 ++ engine/src/flutter/common/settings.h | 6 ++++++ engine/src/flutter/shell/common/shell.cc | 14 ++++++++------ engine/src/flutter/shell/common/switches.cc | 20 +++++++++++--------- 4 files changed, 27 insertions(+), 15 deletions(-) diff --git a/engine/src/flutter/common/settings.cc b/engine/src/flutter/common/settings.cc index d03c52157e1..d2d1c702787 100644 --- a/engine/src/flutter/common/settings.cc +++ b/engine/src/flutter/common/settings.cc @@ -43,6 +43,8 @@ std::string Settings::ToString() const { stream << "enable_software_rendering: " << enable_software_rendering << std::endl; stream << "log_tag: " << log_tag << std::endl; + stream << "icu_initialization_required: " << icu_initialization_required + << std::endl; stream << "icu_data_path: " << icu_data_path << std::endl; stream << "assets_dir: " << assets_dir << std::endl; stream << "assets_path: " << assets_path << std::endl; diff --git a/engine/src/flutter/common/settings.h b/engine/src/flutter/common/settings.h index c95e6eb7a52..07c70369fd1 100644 --- a/engine/src/flutter/common/settings.h +++ b/engine/src/flutter/common/settings.h @@ -104,6 +104,12 @@ struct Settings { bool skia_deterministic_rendering_on_cpu = false; bool verbose_logging = false; std::string log_tag = "flutter"; + + // The icu_initialization_required setting does not have a corresponding + // switch because it is intended to be decided during build time, not runtime. + // Some companies apply source modification here because their build system + // brings its own ICU data files. + bool icu_initialization_required = true; std::string icu_data_path; MappingCallback icu_mapper; diff --git a/engine/src/flutter/shell/common/shell.cc b/engine/src/flutter/shell/common/shell.cc index c1dec19f6ae..4a501d3af7d 100644 --- a/engine/src/flutter/shell/common/shell.cc +++ b/engine/src/flutter/shell/common/shell.cc @@ -187,12 +187,14 @@ static void PerformInitializationTasks(const blink::Settings& settings) { FML_DLOG(INFO) << "Skia deterministic rendering is enabled."; } - if (settings.icu_data_path.size() != 0) { - fml::icu::InitializeICU(settings.icu_data_path); - } else if (settings.icu_mapper) { - fml::icu::InitializeICUFromMapping(settings.icu_mapper()); - } else { - FML_DLOG(WARNING) << "Skipping ICU initialization in the shell."; + if (settings.icu_initialization_required) { + if (settings.icu_data_path.size() != 0) { + fml::icu::InitializeICU(settings.icu_data_path); + } else if (settings.icu_mapper) { + fml::icu::InitializeICUFromMapping(settings.icu_mapper()); + } else { + FML_DLOG(WARNING) << "Skipping ICU initialization in the shell."; + } } }); } diff --git a/engine/src/flutter/shell/common/switches.cc b/engine/src/flutter/shell/common/switches.cc index dc25956fca9..0ef45a944a6 100644 --- a/engine/src/flutter/shell/common/switches.cc +++ b/engine/src/flutter/shell/common/switches.cc @@ -224,15 +224,17 @@ blink::Settings SettingsFromCommandLine(const fml::CommandLine& command_line) { command_line.GetOptionValue(FlagForSwitch(Switch::CacheDirPath), &settings.temp_directory_path); - command_line.GetOptionValue(FlagForSwitch(Switch::ICUDataFilePath), - &settings.icu_data_path); - if (command_line.HasOption(FlagForSwitch(Switch::ICUSymbolPrefix))) { - std::string icu_symbol_prefix; - command_line.GetOptionValue(FlagForSwitch(Switch::ICUSymbolPrefix), - &icu_symbol_prefix); - settings.icu_mapper = [icu_symbol_prefix] { - return GetSymbolMapping(icu_symbol_prefix); - }; + if (settings.icu_initialization_required) { + command_line.GetOptionValue(FlagForSwitch(Switch::ICUDataFilePath), + &settings.icu_data_path); + if (command_line.HasOption(FlagForSwitch(Switch::ICUSymbolPrefix))) { + std::string icu_symbol_prefix; + command_line.GetOptionValue(FlagForSwitch(Switch::ICUSymbolPrefix), + &icu_symbol_prefix); + settings.icu_mapper = [icu_symbol_prefix] { + return GetSymbolMapping(icu_symbol_prefix); + }; + } } settings.use_test_fonts =