From 742a3dc7d828f90a8f361a4f02b4639f47d0180c Mon Sep 17 00:00:00 2001 From: ColdPaleLight <31977171+ColdPaleLight@users.noreply.github.com> Date: Tue, 23 Nov 2021 10:43:02 +0800 Subject: [PATCH] Remove the dart entry point args from the Settings struct (flutter/engine#29831) --- engine/src/flutter/common/settings.h | 5 ----- engine/src/flutter/runtime/dart_isolate.cc | 7 +------ engine/src/flutter/shell/common/run_configuration.cc | 4 ++-- engine/src/flutter/shell/common/run_configuration.h | 2 +- .../shell/platform/android/android_shell_holder.cc | 2 +- .../darwin/ios/framework/Source/FlutterDartProject.mm | 2 +- engine/src/flutter/shell/platform/embedder/embedder.cc | 2 +- .../shell/platform/fuchsia/flutter/component_v1.cc | 4 +++- .../flutter/shell/platform/fuchsia/flutter/component_v1.h | 1 + .../shell/platform/fuchsia/flutter/component_v2.cc | 2 ++ .../src/flutter/shell/platform/fuchsia/flutter/engine.cc | 8 ++++++-- .../src/flutter/shell/platform/fuchsia/flutter/engine.h | 3 +++ engine/src/flutter/testing/dart_isolate_runner.cc | 4 +--- 13 files changed, 23 insertions(+), 23 deletions(-) diff --git a/engine/src/flutter/common/settings.h b/engine/src/flutter/common/settings.h index b9b35b1a3b..3c060e2c81 100644 --- a/engine/src/flutter/common/settings.h +++ b/engine/src/flutter/common/settings.h @@ -126,11 +126,6 @@ struct Settings { std::string temp_directory_path; std::vector dart_flags; - // Arguments passed as a List to Dart's entrypoint function. - // TODO(93459): Remove it when it is no longer used. - // https://github.com/flutter/flutter/issues/93459 - std::vector dart_entrypoint_args; - // Isolate settings bool enable_checked_mode = false; bool start_paused = false; diff --git a/engine/src/flutter/runtime/dart_isolate.cc b/engine/src/flutter/runtime/dart_isolate.cc index ca2f384d12..3ef7788c30 100644 --- a/engine/src/flutter/runtime/dart_isolate.cc +++ b/engine/src/flutter/runtime/dart_isolate.cc @@ -198,14 +198,9 @@ std::weak_ptr DartIsolate::CreateRunningRootIsolate( root_isolate_create_callback(); } - FML_DCHECK(dart_entrypoint_args.empty() || - settings.dart_entrypoint_args.empty()); - const std::vector& args = !dart_entrypoint_args.empty() - ? dart_entrypoint_args - : settings.dart_entrypoint_args; if (!isolate->RunFromLibrary(dart_entrypoint_library, // dart_entrypoint, // - args)) { + dart_entrypoint_args)) { FML_LOG(ERROR) << "Could not run the run main Dart entrypoint."; return {}; } diff --git a/engine/src/flutter/shell/common/run_configuration.cc b/engine/src/flutter/shell/common/run_configuration.cc index 0d905e2791..91d7a413c0 100644 --- a/engine/src/flutter/shell/common/run_configuration.cc +++ b/engine/src/flutter/shell/common/run_configuration.cc @@ -78,8 +78,8 @@ void RunConfiguration::SetEntrypointAndLibrary(std::string entrypoint, } void RunConfiguration::SetEntrypointArgs( - const std::vector& entrypoint_args) { - entrypoint_args_ = entrypoint_args; + std::vector entrypoint_args) { + entrypoint_args_ = std::move(entrypoint_args); } std::shared_ptr RunConfiguration::GetAssetManager() const { diff --git a/engine/src/flutter/shell/common/run_configuration.h b/engine/src/flutter/shell/common/run_configuration.h index ee680fd6ab..15a3ce4e5b 100644 --- a/engine/src/flutter/shell/common/run_configuration.h +++ b/engine/src/flutter/shell/common/run_configuration.h @@ -155,7 +155,7 @@ class RunConfiguration { /// @brief Updates the main application entrypoint arguments. /// /// @param[in] entrypoint_args The entrypoint arguments to use. - void SetEntrypointArgs(const std::vector& entrypoint_args); + void SetEntrypointArgs(std::vector entrypoint_args); //---------------------------------------------------------------------------- /// @return The asset manager referencing all previously registered asset diff --git a/engine/src/flutter/shell/platform/android/android_shell_holder.cc b/engine/src/flutter/shell/platform/android/android_shell_holder.cc index 1634f55b0d..f425e2041c 100644 --- a/engine/src/flutter/shell/platform/android/android_shell_holder.cc +++ b/engine/src/flutter/shell/platform/android/android_shell_holder.cc @@ -311,7 +311,7 @@ std::optional AndroidShellHolder::BuildRunConfiguration( config.SetEntrypoint(std::move(entrypoint)); } if (entrypoint_args.size() > 0) { - config.SetEntrypointArgs(entrypoint_args); + config.SetEntrypointArgs(std::move(entrypoint_args)); } } return config; diff --git a/engine/src/flutter/shell/platform/darwin/ios/framework/Source/FlutterDartProject.mm b/engine/src/flutter/shell/platform/darwin/ios/framework/Source/FlutterDartProject.mm index f9069751ed..c4c9ced24a 100644 --- a/engine/src/flutter/shell/platform/darwin/ios/framework/Source/FlutterDartProject.mm +++ b/engine/src/flutter/shell/platform/darwin/ios/framework/Source/FlutterDartProject.mm @@ -263,7 +263,7 @@ flutter::Settings FLTDefaultSettingsForBundle(NSBundle* bundle) { for (NSString* arg in entrypointArgs) { cppEntrypointArgs.push_back(std::string([arg UTF8String])); } - config.SetEntrypointArgs(cppEntrypointArgs); + config.SetEntrypointArgs(std::move(cppEntrypointArgs)); } return config; diff --git a/engine/src/flutter/shell/platform/embedder/embedder.cc b/engine/src/flutter/shell/platform/embedder/embedder.cc index 8c37bbdf6a..f8496ffc0b 100644 --- a/engine/src/flutter/shell/platform/embedder/embedder.cc +++ b/engine/src/flutter/shell/platform/embedder/embedder.cc @@ -1317,7 +1317,7 @@ FlutterEngineResult FlutterEngineInitialize(size_t version, for (int i = 0; i < args->dart_entrypoint_argc; ++i) { arguments[i] = std::string{args->dart_entrypoint_argv[i]}; } - settings.dart_entrypoint_args = std::move(arguments); + run_configuration.SetEntrypointArgs(std::move(arguments)); } if (!run_configuration.IsValid()) { diff --git a/engine/src/flutter/shell/platform/fuchsia/flutter/component_v1.cc b/engine/src/flutter/shell/platform/fuchsia/flutter/component_v1.cc index 80992f21ef..0c7dd4c937 100644 --- a/engine/src/flutter/shell/platform/fuchsia/flutter/component_v1.cc +++ b/engine/src/flutter/shell/platform/fuchsia/flutter/component_v1.cc @@ -125,7 +125,7 @@ ComponentV1::ComponentV1( // LaunchInfo::arguments optional. if (auto& arguments = launch_info.arguments) { - settings_.dart_entrypoint_args = arguments.value(); + dart_entrypoint_args_ = arguments.value(); } // Determine where data and assets are stored within /pkg. @@ -549,6 +549,7 @@ void ComponentV1::CreateViewWithViewRef( std::move(fdio_ns_), // FDIO namespace std::move(directory_request_), // outgoing request product_config_, // product configuration + dart_entrypoint_args_, // dart entrypoint args true // v1 component )); } @@ -573,6 +574,7 @@ void ComponentV1::CreateView2(fuchsia::ui::app::CreateView2Args view_args) { std::move(fdio_ns_), // FDIO namespace std::move(directory_request_), // outgoing request product_config_, // product configuration + dart_entrypoint_args_, // dart entrypoint args true // v1 component )); } diff --git a/engine/src/flutter/shell/platform/fuchsia/flutter/component_v1.h b/engine/src/flutter/shell/platform/fuchsia/flutter/component_v1.h index 4fa6cbaf40..86abf5df66 100644 --- a/engine/src/flutter/shell/platform/fuchsia/flutter/component_v1.h +++ b/engine/src/flutter/shell/platform/fuchsia/flutter/component_v1.h @@ -131,6 +131,7 @@ class ComponentV1 final : public Engine::Delegate, fml::RefPtr isolate_snapshot_; std::set> shell_holders_; std::pair last_return_code_; + std::vector dart_entrypoint_args_; fml::WeakPtrFactory weak_factory_; // Must be the last member. FML_DISALLOW_COPY_AND_ASSIGN(ComponentV1); }; diff --git a/engine/src/flutter/shell/platform/fuchsia/flutter/component_v2.cc b/engine/src/flutter/shell/platform/fuchsia/flutter/component_v2.cc index 510044073a..f11e1d7993 100644 --- a/engine/src/flutter/shell/platform/fuchsia/flutter/component_v2.cc +++ b/engine/src/flutter/shell/platform/fuchsia/flutter/component_v2.cc @@ -599,6 +599,7 @@ void ComponentV2::CreateViewWithViewRef( std::move(fdio_ns_), // FDIO namespace std::move(directory_request_), // outgoing request product_config_, // product configuration + std::vector(), // dart entrypoint args false // not a v1 component )); } @@ -623,6 +624,7 @@ void ComponentV2::CreateView2(fuchsia::ui::app::CreateView2Args view_args) { std::move(fdio_ns_), // FDIO namespace std::move(directory_request_), // outgoing request product_config_, // product configuration + std::vector(), // dart entrypoint args false // not a v1 component )); } diff --git a/engine/src/flutter/shell/platform/fuchsia/flutter/engine.cc b/engine/src/flutter/shell/platform/fuchsia/flutter/engine.cc index a56fa58a11..5fd6bac268 100644 --- a/engine/src/flutter/shell/platform/fuchsia/flutter/engine.cc +++ b/engine/src/flutter/shell/platform/fuchsia/flutter/engine.cc @@ -71,6 +71,7 @@ Engine::Engine(Delegate& delegate, UniqueFDIONS fdio_ns, fidl::InterfaceRequest directory_request, FlutterRunnerProductConfiguration product_config, + const std::vector& dart_entrypoint_args, bool for_v1_component) : delegate_(delegate), thread_label_(std::move(thread_label)), @@ -83,7 +84,7 @@ Engine::Engine(Delegate& delegate, Initialize(/*=use_flatland*/ false, std::move(view_ref_pair), std::move(svc), std::move(runner_services), std::move(settings), std::move(fdio_ns), std::move(directory_request), - std::move(product_config), for_v1_component); + std::move(product_config), dart_entrypoint_args, for_v1_component); } Engine::Engine(Delegate& delegate, @@ -96,6 +97,7 @@ Engine::Engine(Delegate& delegate, UniqueFDIONS fdio_ns, fidl::InterfaceRequest directory_request, FlutterRunnerProductConfiguration product_config, + const std::vector& dart_entrypoint_args, bool for_v1_component) : delegate_(delegate), thread_label_(std::move(thread_label)), @@ -108,7 +110,7 @@ Engine::Engine(Delegate& delegate, Initialize(/*=use_flatland*/ true, std::move(view_ref_pair), std::move(svc), std::move(runner_services), std::move(settings), std::move(fdio_ns), std::move(directory_request), - std::move(product_config), for_v1_component); + std::move(product_config), dart_entrypoint_args, for_v1_component); } void Engine::Initialize( @@ -120,6 +122,7 @@ void Engine::Initialize( UniqueFDIONS fdio_ns, fidl::InterfaceRequest directory_request, FlutterRunnerProductConfiguration product_config, + const std::vector& dart_entrypoint_args, bool for_v1_component) { // Flatland uses |view_creation_token_| for linking. Gfx uses |view_token_|. FML_CHECK((use_flatland && view_creation_token_.value.is_valid()) || @@ -356,6 +359,7 @@ void Engine::Initialize( // so it must be called before WarmupSkps() is called below. auto run_configuration = flutter::RunConfiguration::InferFromSettings( settings, task_runners.GetIOTaskRunner()); + run_configuration.SetEntrypointArgs(std::move(dart_entrypoint_args)); OnSemanticsNodeUpdate on_semantics_node_update_callback = [this](flutter::SemanticsNodeUpdates updates, float pixel_ratio) { diff --git a/engine/src/flutter/shell/platform/fuchsia/flutter/engine.h b/engine/src/flutter/shell/platform/fuchsia/flutter/engine.h index fe9861e819..7f49589ebf 100644 --- a/engine/src/flutter/shell/platform/fuchsia/flutter/engine.h +++ b/engine/src/flutter/shell/platform/fuchsia/flutter/engine.h @@ -61,6 +61,7 @@ class Engine final : public fuchsia::memorypressure::Watcher { UniqueFDIONS fdio_ns, fidl::InterfaceRequest directory_request, FlutterRunnerProductConfiguration product_config, + const std::vector& dart_entrypoint_args, bool for_v1_component); // Flatland connection ctor. @@ -74,6 +75,7 @@ class Engine final : public fuchsia::memorypressure::Watcher { UniqueFDIONS fdio_ns, fidl::InterfaceRequest directory_request, FlutterRunnerProductConfiguration product_config, + const std::vector& dart_entrypoint_args, bool for_v1_component); ~Engine(); @@ -96,6 +98,7 @@ class Engine final : public fuchsia::memorypressure::Watcher { UniqueFDIONS fdio_ns, fidl::InterfaceRequest directory_request, FlutterRunnerProductConfiguration product_config, + const std::vector& dart_entrypoint_args, bool for_v1_component); static void WarmupSkps( diff --git a/engine/src/flutter/testing/dart_isolate_runner.cc b/engine/src/flutter/testing/dart_isolate_runner.cc index 760764b93f..f3e225f3fe 100644 --- a/engine/src/flutter/testing/dart_isolate_runner.cc +++ b/engine/src/flutter/testing/dart_isolate_runner.cc @@ -85,8 +85,6 @@ std::unique_ptr RunDartCodeInIsolateOnUITaskRunner( auto settings = p_settings; - settings.dart_entrypoint_args = args; - if (!DartVM::IsRunningPrecompiledCode()) { if (!fml::IsFile(kernel_file_path)) { FML_LOG(ERROR) << "Could not locate kernel file."; @@ -135,7 +133,7 @@ std::unique_ptr RunDartCodeInIsolateOnUITaskRunner( settings.isolate_shutdown_callback, // isolate shutdown callback entrypoint, // entrypoint std::nullopt, // library - {}, // args + args, // args std::move(isolate_configuration), // isolate configuration context // engine context )