diff --git a/engine/src/flutter/lib/ui/ui_dart_state.cc b/engine/src/flutter/lib/ui/ui_dart_state.cc index 9382215a2d..a8c1347162 100644 --- a/engine/src/flutter/lib/ui/ui_dart_state.cc +++ b/engine/src/flutter/lib/ui/ui_dart_state.cc @@ -24,43 +24,50 @@ using tonic::ToDart; namespace flutter { -UIDartState::UIDartState( - TaskRunners task_runners, - TaskObserverAdd add_callback, - TaskObserverRemove remove_callback, +UIDartState::Context::Context(const TaskRunners& task_runners) + : task_runners(task_runners) {} + +UIDartState::Context::Context( + const TaskRunners& task_runners, fml::WeakPtr snapshot_delegate, fml::WeakPtr hint_freed_delegate, fml::WeakPtr io_manager, - fml::RefPtr skia_unref_queue, + fml::RefPtr unref_queue, fml::WeakPtr image_decoder, fml::WeakPtr image_generator_registry, std::string advisory_script_uri, std::string advisory_script_entrypoint, + std::shared_ptr volatile_path_tracker) + : task_runners(task_runners), + snapshot_delegate(snapshot_delegate), + hint_freed_delegate(hint_freed_delegate), + io_manager(io_manager), + unref_queue(unref_queue), + image_decoder(image_decoder), + image_generator_registry(image_generator_registry), + advisory_script_uri(advisory_script_uri), + advisory_script_entrypoint(advisory_script_entrypoint), + volatile_path_tracker(volatile_path_tracker) {} + +UIDartState::UIDartState( + TaskObserverAdd add_callback, + TaskObserverRemove remove_callback, std::string logger_prefix, UnhandledExceptionCallback unhandled_exception_callback, LogMessageCallback log_message_callback, std::shared_ptr isolate_name_server, bool is_root_isolate, - std::shared_ptr volatile_path_tracker, - bool enable_skparagraph) - : task_runners_(std::move(task_runners)), - add_callback_(std::move(add_callback)), + bool enable_skparagraph, + const UIDartState::Context& context) + : add_callback_(std::move(add_callback)), remove_callback_(std::move(remove_callback)), - snapshot_delegate_(std::move(snapshot_delegate)), - hint_freed_delegate_(std::move(hint_freed_delegate)), - io_manager_(std::move(io_manager)), - skia_unref_queue_(std::move(skia_unref_queue)), - image_decoder_(std::move(image_decoder)), - image_generator_registry_(std::move(image_generator_registry)), - volatile_path_tracker_(std::move(volatile_path_tracker)), - advisory_script_uri_(std::move(advisory_script_uri)), - advisory_script_entrypoint_(std::move(advisory_script_entrypoint)), logger_prefix_(std::move(logger_prefix)), is_root_isolate_(is_root_isolate), unhandled_exception_callback_(unhandled_exception_callback), log_message_callback_(log_message_callback), isolate_name_server_(std::move(isolate_name_server)), - enable_skparagraph_(enable_skparagraph) { + enable_skparagraph_(enable_skparagraph), + context_(std::move(context)) { AddOrRemoveTaskObserver(true /* add */); } @@ -69,19 +76,19 @@ UIDartState::~UIDartState() { } const std::string& UIDartState::GetAdvisoryScriptURI() const { - return advisory_script_uri_; + return context_.advisory_script_uri; } const std::string& UIDartState::GetAdvisoryScriptEntrypoint() const { - return advisory_script_entrypoint_; + return context_.advisory_script_entrypoint; } void UIDartState::DidSetIsolate() { main_port_ = Dart_GetMainPortId(); std::ostringstream debug_name; // main.dart$main-1234 - debug_name << advisory_script_uri_ << "$" << advisory_script_entrypoint_ - << "-" << main_port_; + debug_name << context_.advisory_script_uri << "$" + << context_.advisory_script_entrypoint << "-" << main_port_; SetDebugName(debug_name.str()); } @@ -114,20 +121,20 @@ void UIDartState::SetPlatformConfiguration( } const TaskRunners& UIDartState::GetTaskRunners() const { - return task_runners_; + return context_.task_runners; } fml::WeakPtr UIDartState::GetIOManager() const { - return io_manager_; + return context_.io_manager; } fml::RefPtr UIDartState::GetSkiaUnrefQueue() const { - return skia_unref_queue_; + return context_.unref_queue; } std::shared_ptr UIDartState::GetVolatilePathTracker() const { - return volatile_path_tracker_; + return context_.volatile_path_tracker; } void UIDartState::ScheduleMicrotask(Dart_Handle closure) { @@ -143,7 +150,7 @@ void UIDartState::FlushMicrotasksNow() { } void UIDartState::AddOrRemoveTaskObserver(bool add) { - auto task_runner = task_runners_.GetUITaskRunner(); + auto task_runner = context_.task_runners.GetUITaskRunner(); if (!task_runner) { // This may happen in case the isolate has no thread affinity (for example, // the service isolate). @@ -159,27 +166,27 @@ void UIDartState::AddOrRemoveTaskObserver(bool add) { } fml::WeakPtr UIDartState::GetSnapshotDelegate() const { - return snapshot_delegate_; + return context_.snapshot_delegate; } fml::WeakPtr UIDartState::GetHintFreedDelegate() const { - return hint_freed_delegate_; + return context_.hint_freed_delegate; } fml::WeakPtr UIDartState::GetResourceContext() const { - if (!io_manager_) { + if (!context_.io_manager) { return {}; } - return io_manager_->GetResourceContext(); + return context_.io_manager->GetResourceContext(); } fml::WeakPtr UIDartState::GetImageDecoder() const { - return image_decoder_; + return context_.image_decoder; } fml::WeakPtr UIDartState::GetImageGeneratorRegistry() const { - return image_generator_registry_; + return context_.image_generator_registry; } std::shared_ptr UIDartState::GetIsolateNameServer() const { diff --git a/engine/src/flutter/lib/ui/ui_dart_state.h b/engine/src/flutter/lib/ui/ui_dart_state.h index b08e989307..e72c05679f 100644 --- a/engine/src/flutter/lib/ui/ui_dart_state.h +++ b/engine/src/flutter/lib/ui/ui_dart_state.h @@ -36,6 +36,67 @@ class UIDartState : public tonic::DartState { public: static UIDartState* Current(); + /// @brief The subset of state which is owned by the shell or engine + /// and passed through the RuntimeController into DartIsolates. + /// If a shell-owned resource needs to be exposed to the framework via + /// UIDartState, a pointer to the resource can be added to this + /// struct with appropriate default construction. + struct Context { + Context(const TaskRunners& task_runners); + + Context(const TaskRunners& task_runners, + fml::WeakPtr snapshot_delegate, + fml::WeakPtr hint_freed_delegate, + fml::WeakPtr io_manager, + fml::RefPtr unref_queue, + fml::WeakPtr image_decoder, + fml::WeakPtr image_generator_registry, + std::string advisory_script_uri, + std::string advisory_script_entrypoint, + std::shared_ptr volatile_path_tracker); + + /// The task runners used by the shell hosting this runtime controller. This + /// may be used by the isolate to scheduled asynchronous texture uploads or + /// post tasks to the platform task runner. + const TaskRunners task_runners; + + /// The snapshot delegate used by the + /// isolate to gather raster snapshots + /// of Flutter view hierarchies. + fml::WeakPtr snapshot_delegate; + + /// The delegate used by the isolate to hint the Dart VM when additional + /// memory may be freed if a GC ran at the next NotifyIdle. + fml::WeakPtr hint_freed_delegate; + + /// The IO manager used by the isolate for asynchronous texture uploads. + fml::WeakPtr io_manager; + + /// The unref queue used by the isolate to collect resources that may + /// reference resources on the GPU. + fml::RefPtr unref_queue; + + /// The image decoder. + fml::WeakPtr image_decoder; + + /// Cascading registry of image generator builders. Given compressed image + /// bytes as input, this is used to find and create image generators, which + /// can then be used for image decoding. + fml::WeakPtr image_generator_registry; + + /// The advisory script URI (only used for debugging). This does not affect + /// the code being run in the isolate in any way. + std::string advisory_script_uri; + + /// The advisory script entrypoint (only used for debugging). This does not + /// affect the code being run in the isolate in any way. The isolate must be + /// transitioned to the running state explicitly by the caller. + std::string advisory_script_entrypoint; + + /// Cache for tracking path volatility. + std::shared_ptr volatile_path_tracker; + }; + Dart_Port main_port() const { return main_port_; } // Root isolate of the VM application bool IsRootIsolate() const { return is_root_isolate_; } @@ -102,24 +163,15 @@ class UIDartState : public tonic::DartState { }; protected: - UIDartState(TaskRunners task_runners, - TaskObserverAdd add_callback, + UIDartState(TaskObserverAdd add_callback, TaskObserverRemove remove_callback, - fml::WeakPtr snapshot_delegate, - fml::WeakPtr hint_freed_delegate, - fml::WeakPtr io_manager, - fml::RefPtr skia_unref_queue, - fml::WeakPtr image_decoder, - fml::WeakPtr image_generator_registry, - std::string advisory_script_uri, - std::string advisory_script_entrypoint, std::string logger_prefix, UnhandledExceptionCallback unhandled_exception_callback, LogMessageCallback log_message_callback, std::shared_ptr isolate_name_server, bool is_root_isolate_, - std::shared_ptr volatile_path_tracker, - bool enable_skparagraph); + bool enable_skparagraph, + const UIDartState::Context& context); ~UIDartState() override; @@ -133,18 +185,8 @@ class UIDartState : public tonic::DartState { private: void DidSetIsolate() override; - const TaskRunners task_runners_; const TaskObserverAdd add_callback_; const TaskObserverRemove remove_callback_; - fml::WeakPtr snapshot_delegate_; - fml::WeakPtr hint_freed_delegate_; - fml::WeakPtr io_manager_; - fml::RefPtr skia_unref_queue_; - fml::WeakPtr image_decoder_; - fml::WeakPtr image_generator_registry_; - std::shared_ptr volatile_path_tracker_; - const std::string advisory_script_uri_; - const std::string advisory_script_entrypoint_; const std::string logger_prefix_; Dart_Port main_port_ = ILLEGAL_PORT; const bool is_root_isolate_; @@ -155,6 +197,7 @@ class UIDartState : public tonic::DartState { LogMessageCallback log_message_callback_; const std::shared_ptr isolate_name_server_; const bool enable_skparagraph_; + UIDartState::Context context_; void AddOrRemoveTaskObserver(bool add); }; diff --git a/engine/src/flutter/runtime/dart_isolate.cc b/engine/src/flutter/runtime/dart_isolate.cc index ec2fa3b89e..49f2d8b8d8 100644 --- a/engine/src/flutter/runtime/dart_isolate.cc +++ b/engine/src/flutter/runtime/dart_isolate.cc @@ -92,35 +92,40 @@ std::weak_ptr DartIsolate::SpawnIsolate( std::optional dart_entrypoint_library, std::unique_ptr isolate_configration) const { return CreateRunningRootIsolate( - settings, GetIsolateGroupData().GetIsolateSnapshot(), GetTaskRunners(), - std::move(platform_configuration), snapshot_delegate, hint_freed_delegate, - GetIOManager(), GetSkiaUnrefQueue(), GetImageDecoder(), - GetImageGeneratorRegistry(), advisory_script_uri, - advisory_script_entrypoint, flags, isolate_create_callback, - isolate_shutdown_callback, dart_entrypoint, dart_entrypoint_library, - std::move(isolate_configration), GetVolatilePathTracker(), this); + settings, // + GetIsolateGroupData().GetIsolateSnapshot(), // + std::move(platform_configuration), // + flags, // + isolate_create_callback, // + isolate_shutdown_callback, // + dart_entrypoint, // + dart_entrypoint_library, // + std::move(isolate_configration), // + UIDartState::Context{GetTaskRunners(), // + snapshot_delegate, // + hint_freed_delegate, // + GetIOManager(), // + GetSkiaUnrefQueue(), // + GetImageDecoder(), // + GetImageGeneratorRegistry(), // + advisory_script_uri, // + advisory_script_entrypoint, // + GetVolatilePathTracker()}, // + this // + ); } std::weak_ptr DartIsolate::CreateRunningRootIsolate( const Settings& settings, fml::RefPtr isolate_snapshot, - TaskRunners task_runners, std::unique_ptr platform_configuration, - fml::WeakPtr snapshot_delegate, - fml::WeakPtr hint_freed_delegate, - fml::WeakPtr io_manager, - fml::RefPtr skia_unref_queue, - fml::WeakPtr image_decoder, - fml::WeakPtr image_generator_registry, - std::string advisory_script_uri, - std::string advisory_script_entrypoint, Flags isolate_flags, const fml::closure& isolate_create_callback, const fml::closure& isolate_shutdown_callback, std::optional dart_entrypoint, std::optional dart_entrypoint_library, std::unique_ptr isolate_configration, - std::shared_ptr volatile_path_tracker, + const UIDartState::Context& context, const DartIsolate* spawning_isolate) { if (!isolate_snapshot) { FML_LOG(ERROR) << "Invalid isolate snapshot."; @@ -137,20 +142,11 @@ std::weak_ptr DartIsolate::CreateRunningRootIsolate( auto isolate = CreateRootIsolate(settings, // isolate_snapshot, // - task_runners, // std::move(platform_configuration), // - snapshot_delegate, // - hint_freed_delegate, // - io_manager, // - skia_unref_queue, // - image_decoder, // - image_generator_registry, // - advisory_script_uri, // - advisory_script_entrypoint, // isolate_flags, // isolate_create_callback, // isolate_shutdown_callback, // - std::move(volatile_path_tracker), // + context, // spawning_isolate // ) .lock(); @@ -217,20 +213,11 @@ void DartIsolate::SpawnIsolateShutdownCallback( std::weak_ptr DartIsolate::CreateRootIsolate( const Settings& settings, fml::RefPtr isolate_snapshot, - TaskRunners task_runners, std::unique_ptr platform_configuration, - fml::WeakPtr snapshot_delegate, - fml::WeakPtr hint_freed_delegate, - fml::WeakPtr io_manager, - fml::RefPtr unref_queue, - fml::WeakPtr image_decoder, - fml::WeakPtr image_generator_registry, - std::string advisory_script_uri, - std::string advisory_script_entrypoint, Flags flags, const fml::closure& isolate_create_callback, const fml::closure& isolate_shutdown_callback, - std::shared_ptr volatile_path_tracker, + const UIDartState::Context& context, const DartIsolate* spawning_isolate) { TRACE_EVENT0("flutter", "DartIsolate::CreateRootIsolate"); @@ -239,29 +226,20 @@ std::weak_ptr DartIsolate::CreateRootIsolate( auto isolate_group_data = std::make_unique>( std::shared_ptr(new DartIsolateGroupData( - settings, // settings - std::move(isolate_snapshot), // isolate snapshot - advisory_script_uri, // advisory URI - advisory_script_entrypoint, // advisory entrypoint - nullptr, // child isolate preparer - isolate_create_callback, // isolate create callback - isolate_shutdown_callback // isolate shutdown callback + settings, // settings + std::move(isolate_snapshot), // isolate snapshot + context.advisory_script_uri, // advisory URI + context.advisory_script_entrypoint, // advisory entrypoint + nullptr, // child isolate preparer + isolate_create_callback, // isolate create callback + isolate_shutdown_callback // isolate shutdown callback ))); auto isolate_data = std::make_unique>( std::shared_ptr(new DartIsolate( - settings, // settings - task_runners, // task runners - std::move(snapshot_delegate), // snapshot delegate - std::move(hint_freed_delegate), // hint freed delegate - std::move(io_manager), // IO manager - std::move(unref_queue), // Skia unref queue - std::move(image_decoder), // Image Decoder - std::move(image_generator_registry), // Image generator registry - advisory_script_uri, // advisory URI - advisory_script_entrypoint, // advisory entrypoint - true, // is_root_isolate - std::move(volatile_path_tracker) // volatile path tracker + settings, // settings + true, // is_root_isolate + std::move(context) // context ))); DartErrorString error; @@ -322,37 +300,18 @@ std::weak_ptr DartIsolate::CreateRootIsolate( return (*root_isolate_data)->GetWeakIsolatePtr(); } -DartIsolate::DartIsolate( - const Settings& settings, - TaskRunners task_runners, - fml::WeakPtr snapshot_delegate, - fml::WeakPtr hint_freed_delegate, - fml::WeakPtr io_manager, - fml::RefPtr unref_queue, - fml::WeakPtr image_decoder, - fml::WeakPtr image_generator_registry, - std::string advisory_script_uri, - std::string advisory_script_entrypoint, - bool is_root_isolate, - std::shared_ptr volatile_path_tracker) - : UIDartState(std::move(task_runners), - settings.task_observer_add, +DartIsolate::DartIsolate(const Settings& settings, + bool is_root_isolate, + const UIDartState::Context& context) + : UIDartState(settings.task_observer_add, settings.task_observer_remove, - std::move(snapshot_delegate), - std::move(hint_freed_delegate), - std::move(io_manager), - std::move(unref_queue), - std::move(image_decoder), - std::move(image_generator_registry), - advisory_script_uri, - advisory_script_entrypoint, settings.log_tag, settings.unhandled_exception_callback, settings.log_message_callback, DartVMRef::GetIsolateNameServer(), is_root_isolate, - std::move(volatile_path_tracker), - settings.enable_skparagraph), + settings.enable_skparagraph, + std::move(context)), may_insecurely_connect_to_all_domains_( settings.may_insecurely_connect_to_all_domains), domain_network_policy_(settings.domain_network_policy) { @@ -852,9 +811,6 @@ Dart_Isolate DartIsolate::DartCreateAndStartServiceIsolate( return nullptr; } - TaskRunners null_task_runners("io.flutter." DART_VM_SERVICE_ISOLATE_NAME, - nullptr, nullptr, nullptr, nullptr); - flags->load_vmservice_library = true; #if (FLUTTER_RUNTIME_MODE != FLUTTER_RUNTIME_MODE_DEBUG) @@ -865,25 +821,19 @@ Dart_Isolate DartIsolate::DartCreateAndStartServiceIsolate( vm_data->GetIsolateSnapshot()->IsNullSafetyEnabled(nullptr); #endif + UIDartState::Context context( + TaskRunners("io.flutter." DART_VM_SERVICE_ISOLATE_NAME, nullptr, nullptr, + nullptr, nullptr)); + context.advisory_script_uri = DART_VM_SERVICE_ISOLATE_NAME; + context.advisory_script_entrypoint = DART_VM_SERVICE_ISOLATE_NAME; std::weak_ptr weak_service_isolate = - DartIsolate::CreateRootIsolate( - vm_data->GetSettings(), // settings - vm_data->GetIsolateSnapshot(), // isolate snapshot - null_task_runners, // task runners - nullptr, // platform_configuration - {}, // snapshot delegate - {}, // Hint freed delegate - {}, // IO Manager - {}, // Skia unref queue - {}, // Image Decoder - {}, // Image generator registry - DART_VM_SERVICE_ISOLATE_NAME, // script uri - DART_VM_SERVICE_ISOLATE_NAME, // script entrypoint - DartIsolate::Flags{flags}, // flags - nullptr, // isolate create callback - nullptr, // isolate shutdown callback - nullptr // volatile path tracker - ); + DartIsolate::CreateRootIsolate(vm_data->GetSettings(), // + vm_data->GetIsolateSnapshot(), // + nullptr, // + DartIsolate::Flags{flags}, // + nullptr, // + nullptr, // + context); // std::shared_ptr service_isolate = weak_service_isolate.lock(); if (!service_isolate) { @@ -990,20 +940,14 @@ Dart_Isolate DartIsolate::DartIsolateGroupCreateCallback( /* ui= */ nullptr, /* io= */ nullptr); + UIDartState::Context context(null_task_runners); + context.advisory_script_uri = advisory_script_uri; + context.advisory_script_entrypoint = advisory_script_entrypoint; auto isolate_data = std::make_unique>( - std::shared_ptr(new DartIsolate( - (*isolate_group_data)->GetSettings(), // settings - null_task_runners, // task_runners - fml::WeakPtr{}, // snapshot_delegate - fml::WeakPtr{}, // hint_freed_delegate - fml::WeakPtr{}, // io_manager - fml::RefPtr{}, // unref_queue - fml::WeakPtr{}, // image_decoder - fml::WeakPtr{}, // image_generator_registry - advisory_script_uri, // advisory_script_uri - advisory_script_entrypoint, // advisory_script_entrypoint - false, // is_root_isolate - nullptr))); // volatile path tracker + std::shared_ptr( + new DartIsolate((*isolate_group_data)->GetSettings(), // settings + false, // is_root_isolate + context))); // context Dart_Isolate vm_isolate = CreateDartIsolateGroup( std::move(isolate_group_data), std::move(isolate_data), flags, error, @@ -1048,21 +992,15 @@ bool DartIsolate::DartIsolateInitializeCallback(void** child_callback_data, /* ui= */ nullptr, /* io= */ nullptr); + UIDartState::Context context(null_task_runners); + context.advisory_script_uri = (*isolate_group_data)->GetAdvisoryScriptURI(); + context.advisory_script_entrypoint = + (*isolate_group_data)->GetAdvisoryScriptEntrypoint(); auto embedder_isolate = std::make_unique>( - std::shared_ptr(new DartIsolate( - (*isolate_group_data)->GetSettings(), // settings - null_task_runners, // task_runners - fml::WeakPtr{}, // snapshot_delegate - fml::WeakPtr{}, // hint_freed_delegate - fml::WeakPtr{}, // io_manager - fml::RefPtr{}, // unref_queue - fml::WeakPtr{}, // image_decoder - fml::WeakPtr{}, // image_generator_registry - (*isolate_group_data)->GetAdvisoryScriptURI(), // advisory_script_uri - (*isolate_group_data) - ->GetAdvisoryScriptEntrypoint(), // advisory_script_entrypoint - false, // is_root_isolate - nullptr))); // volatile path tracker + std::shared_ptr( + new DartIsolate((*isolate_group_data)->GetSettings(), // settings + false, // is_root_isolate + context))); // context // root isolate should have been created via CreateRootIsolate if (!InitializeIsolate(*embedder_isolate, isolate, error)) { diff --git a/engine/src/flutter/runtime/dart_isolate.h b/engine/src/flutter/runtime/dart_isolate.h index 1c83f58123..b41d1fb44a 100644 --- a/engine/src/flutter/runtime/dart_isolate.h +++ b/engine/src/flutter/runtime/dart_isolate.h @@ -161,57 +161,34 @@ class DartIsolate : public UIDartState { /// /// @param[in] settings The settings used to create the /// isolate. - /// @param[in] isolate_snapshot The isolate snapshot. This is - /// usually obtained from the - /// DartVMData associated with the - /// running Dart VM instance. - /// @param[in] task_runners The task runners used by the - /// isolate. Via UI bindings, the - /// isolate will use the IO task - /// runner to scheduled texture - /// decompression jobs and post tasks - /// back to the UI task runner. - /// @param[in] window The weak pointer to the window - /// associated with this root isolate. - /// @param[in] io_manager The i/o manager. - /// @param[in] unref_queue The Skia unref queue. - /// @param[in] image_decoder The image decoder. - /// @param[in] image_generator_registry Cascading registry of image - /// generator builders. Given - /// compressed image bytes as input, - /// this is used to find and create - /// image generators, which can then - /// be used for image decoding. - /// @param[in] advisory_script_uri The advisory script uri. This is - /// only used in instrumentation. - /// @param[in] advisory_script_entrypoint The advisory script entrypoint. - /// This is only used in - /// instrumentation. Notably, this is - /// NOT the main entrypoint of Dart - /// code in the isolate. That is - /// specified when making one of the - /// `Run` calls. + /// @param[in] platform_configuration The platform configuration for + /// handling communication with the + /// framework. /// @param[in] flags The Dart isolate flags for this /// isolate instance. + /// @param[in] dart_entrypoint The name of the dart entrypoint + /// function to invoke. + /// @param[in] dart_entrypoint_library The name of the dart library + /// containing the entrypoint. + /// @param[in] isolate_configuration The isolate configuration used to + /// configure the isolate before + /// invoking the entrypoint. /// @param[in] isolate_create_callback The isolate create callback. This /// will be called when the before the /// main Dart entrypoint is invoked in /// the root isolate. The isolate is /// already in the running state at /// this point and an isolate scope is - /// current. This callback is made for - /// all isolate launches (including - /// the children of the root isolate). + /// current. /// @param[in] isolate_shutdown_callback The isolate shutdown callback. /// This will be called before the /// isolate is about to transition /// into the Shutdown phase. The /// isolate is still running at this /// point and an isolate scope is - /// current. This callback is made - /// for all isolate shutdowns - /// (including the children of the - /// root isolate). + /// current. + /// @param[in] context Engine-owned state which is + /// accessed by the root dart isolate. /// @param[in] spawning_isolate The isolate that is spawning the /// new isolate. See also /// DartIsolate::SpawnIsolate. @@ -224,23 +201,14 @@ class DartIsolate : public UIDartState { static std::weak_ptr CreateRunningRootIsolate( const Settings& settings, fml::RefPtr isolate_snapshot, - TaskRunners task_runners, std::unique_ptr platform_configuration, - fml::WeakPtr snapshot_delegate, - fml::WeakPtr hint_freed_delegate, - fml::WeakPtr io_manager, - fml::RefPtr skia_unref_queue, - fml::WeakPtr image_decoder, - fml::WeakPtr image_generator_registry, - std::string advisory_script_uri, - std::string advisory_script_entrypoint, Flags flags, const fml::closure& isolate_create_callback, const fml::closure& isolate_shutdown_callback, std::optional dart_entrypoint, std::optional dart_entrypoint_library, std::unique_ptr isolate_configration, - std::shared_ptr volatile_path_tracker, + const UIDartState::Context& context, const DartIsolate* spawning_isolate = nullptr); //---------------------------------------------------------------------------- @@ -460,34 +428,16 @@ class DartIsolate : public UIDartState { static std::weak_ptr CreateRootIsolate( const Settings& settings, fml::RefPtr isolate_snapshot, - TaskRunners task_runners, std::unique_ptr platform_configuration, - fml::WeakPtr snapshot_delegate, - fml::WeakPtr hint_freed_delegate, - fml::WeakPtr io_manager, - fml::RefPtr skia_unref_queue, - fml::WeakPtr image_decoder, - fml::WeakPtr image_generator_registry, - std::string advisory_script_uri, - std::string advisory_script_entrypoint, Flags flags, const fml::closure& isolate_create_callback, const fml::closure& isolate_shutdown_callback, - std::shared_ptr volatile_path_tracker, + const UIDartState::Context& context, const DartIsolate* spawning_isolate = nullptr); DartIsolate(const Settings& settings, - TaskRunners task_runners, - fml::WeakPtr snapshot_delegate, - fml::WeakPtr hint_freed_delegate, - fml::WeakPtr io_manager, - fml::RefPtr unref_queue, - fml::WeakPtr image_decoder, - fml::WeakPtr image_generator_registry, - std::string advisory_script_uri, - std::string advisory_script_entrypoint, bool is_root_isolate, - std::shared_ptr volatile_path_tracker); + const UIDartState::Context& context); [[nodiscard]] bool Initialize(Dart_Isolate isolate); diff --git a/engine/src/flutter/runtime/dart_isolate_unittests.cc b/engine/src/flutter/runtime/dart_isolate_unittests.cc index ed57014853..1ac1252065 100644 --- a/engine/src/flutter/runtime/dart_isolate_unittests.cc +++ b/engine/src/flutter/runtime/dart_isolate_unittests.cc @@ -51,26 +51,20 @@ TEST_F(DartIsolateTest, RootIsolateCreationAndShutdown) { auto isolate_configuration = IsolateConfiguration::InferFromSettings(settings); + UIDartState::Context context(std::move(task_runners)); + context.advisory_script_uri = "main.dart"; + context.advisory_script_entrypoint = "main"; auto weak_isolate = DartIsolate::CreateRunningRootIsolate( vm_data->GetSettings(), // settings vm_data->GetIsolateSnapshot(), // isolate snapshot - std::move(task_runners), // task runners - nullptr, // window - {}, // snapshot delegate - {}, // hint freed delegate - {}, // io manager - {}, // unref queue - {}, // image decoder - {}, // image generator registry - "main.dart", // advisory uri - "main", // advisory entrypoint, + nullptr, // platform configuration DartIsolate::Flags{}, // flags settings.isolate_create_callback, // isolate create callback settings.isolate_shutdown_callback, // isolate shutdown callback "main", // dart entrypoint std::nullopt, // dart entrypoint library std::move(isolate_configuration), // isolate configuration - nullptr // Volatile path tracker + std::move(context) // engine context ); auto root_isolate = weak_isolate.lock(); ASSERT_TRUE(root_isolate); @@ -95,26 +89,20 @@ TEST_F(DartIsolateTest, SpawnIsolate) { auto isolate_configuration = IsolateConfiguration::InferFromSettings(settings); + UIDartState::Context context(std::move(task_runners)); + context.advisory_script_uri = "main.dart"; + context.advisory_script_entrypoint = "main"; auto weak_isolate = DartIsolate::CreateRunningRootIsolate( vm_data->GetSettings(), // settings vm_data->GetIsolateSnapshot(), // isolate snapshot - std::move(task_runners), // task runners - nullptr, // window - {}, // snapshot delegate - {}, // hint freed delegate - {}, // io manager - {}, // unref queue - {}, // image decoder - {}, // image generator registry - "main.dart", // advisory uri - "main", // advisory entrypoint, + nullptr, // platform configuration DartIsolate::Flags{}, // flags settings.isolate_create_callback, // isolate create callback settings.isolate_shutdown_callback, // isolate shutdown callback "main", // dart entrypoint std::nullopt, // dart entrypoint library std::move(isolate_configuration), // isolate configuration - nullptr // Volatile path tracker + std::move(context) // engine context ); auto root_isolate = weak_isolate.lock(); ASSERT_TRUE(root_isolate); @@ -174,26 +162,21 @@ TEST_F(DartIsolateTest, IsolateShutdownCallbackIsInIsolateScope) { ); auto isolate_configuration = IsolateConfiguration::InferFromSettings(settings); + + UIDartState::Context context(std::move(task_runners)); + context.advisory_script_uri = "main.dart"; + context.advisory_script_entrypoint = "main"; auto weak_isolate = DartIsolate::CreateRunningRootIsolate( vm_data->GetSettings(), // settings vm_data->GetIsolateSnapshot(), // isolate snapshot - std::move(task_runners), // task runners - nullptr, // window - {}, // snapshot delegate - {}, // hint freed delegate - {}, // io manager - {}, // unref queue - {}, // image decoder - {}, // image generator registry - "main.dart", // advisory uri - "main", // advisory entrypoint + nullptr, // platform configuration DartIsolate::Flags{}, // flags settings.isolate_create_callback, // isolate create callback settings.isolate_shutdown_callback, // isolate shutdown callback "main", // dart entrypoint std::nullopt, // dart entrypoint library std::move(isolate_configuration), // isolate configuration - nullptr // Volatile path tracker + std::move(context) // engine context ); auto root_isolate = weak_isolate.lock(); ASSERT_TRUE(root_isolate); @@ -434,27 +417,23 @@ TEST_F(DartIsolateTest, CanCreateServiceIsolate) { auto isolate_configuration = IsolateConfiguration::InferFromSettings(settings); + + UIDartState::Context context(std::move(task_runners)); + context.advisory_script_uri = "main.dart"; + context.advisory_script_entrypoint = "main"; auto weak_isolate = DartIsolate::CreateRunningRootIsolate( vm_data->GetSettings(), // settings vm_data->GetIsolateSnapshot(), // isolate snapshot - std::move(task_runners), // task runners - nullptr, // window - {}, // snapshot delegate - {}, // hint freed delegate - {}, // io manager - {}, // unref queue - {}, // image decoder - {}, // image generator registry - "main.dart", // advisory uri - "main", // advisory entrypoint, + nullptr, // platform configuration DartIsolate::Flags{}, // flags settings.isolate_create_callback, // isolate create callback settings.isolate_shutdown_callback, // isolate shutdown callback "main", // dart entrypoint std::nullopt, // dart entrypoint library std::move(isolate_configuration), // isolate configuration - nullptr // Volatile path tracker + std::move(context) // engine context ); + auto root_isolate = weak_isolate.lock(); ASSERT_TRUE(root_isolate); ASSERT_EQ(root_isolate->GetPhase(), DartIsolate::Phase::Running); @@ -536,27 +515,23 @@ TEST_F(DartIsolateTest, InvalidLoadingUnitFails) { ); auto isolate_configuration = IsolateConfiguration::InferFromSettings(settings); + + UIDartState::Context context(std::move(task_runners)); + context.advisory_script_uri = "main.dart"; + context.advisory_script_entrypoint = "main"; auto weak_isolate = DartIsolate::CreateRunningRootIsolate( vm_data->GetSettings(), // settings vm_data->GetIsolateSnapshot(), // isolate snapshot - std::move(task_runners), // task runners - nullptr, // window - {}, // snapshot delegate - {}, // hint freed delegate - {}, // io manager - {}, // unref queue - {}, // image decoder - {}, // image generator registry - "main.dart", // advisory uri - "main", // advisory entrypoint + nullptr, // platform configuration DartIsolate::Flags{}, // flags settings.isolate_create_callback, // isolate create callback settings.isolate_shutdown_callback, // isolate shutdown callback "main", // dart entrypoint std::nullopt, // dart entrypoint library std::move(isolate_configuration), // isolate configuration - nullptr // volatile path tracker + std::move(context) // engine context ); + auto root_isolate = weak_isolate.lock(); ASSERT_TRUE(root_isolate); ASSERT_EQ(root_isolate->GetPhase(), DartIsolate::Phase::Running); diff --git a/engine/src/flutter/runtime/dart_lifecycle_unittests.cc b/engine/src/flutter/runtime/dart_lifecycle_unittests.cc index 02a18798d3..b2beed0dd9 100644 --- a/engine/src/flutter/runtime/dart_lifecycle_unittests.cc +++ b/engine/src/flutter/runtime/dart_lifecycle_unittests.cc @@ -55,27 +55,21 @@ static std::shared_ptr CreateAndRunRootIsolate( auto isolate_configuration = IsolateConfiguration::InferFromSettings(settings); + UIDartState::Context context(runners); + context.advisory_script_uri = "main.dart"; + context.advisory_script_entrypoint = entrypoint.c_str(); auto isolate = DartIsolate::CreateRunningRootIsolate( vm.GetSettings(), // settings vm.GetIsolateSnapshot(), // isolate_snapshot - runners, // task_runners - {}, // window - {}, // snapshot_delegate - {}, // hint_freed_delegate - {}, // io_manager - {}, // unref_queue - {}, // image_decoder - {}, // image_generator_registry - "main.dart", // advisory_script_uri - entrypoint.c_str(), // advisory_script_entrypoint + {}, // platform configuration DartIsolate::Flags{}, // flags settings.isolate_create_callback, // isolate create callback settings.isolate_shutdown_callback, // isolate shutdown callback, entrypoint, // dart entrypoint std::nullopt, // dart entrypoint library std::move(isolate_configuration), // isolate configuration - nullptr // Volatile path tracker + std::move(context) // engine context ) .lock(); diff --git a/engine/src/flutter/runtime/runtime_controller.cc b/engine/src/flutter/runtime/runtime_controller.cc index 7da1ecaca4..3c77de4ffd 100644 --- a/engine/src/flutter/runtime/runtime_controller.cc +++ b/engine/src/flutter/runtime/runtime_controller.cc @@ -17,63 +17,48 @@ namespace flutter { -RuntimeController::RuntimeController(RuntimeDelegate& client, - TaskRunners p_task_runners) - : client_(client), vm_(nullptr), task_runners_(p_task_runners) {} +RuntimeController::RuntimeController(RuntimeDelegate& p_client, + TaskRunners task_runners) + : client_(p_client), vm_(nullptr), context_(task_runners) {} RuntimeController::RuntimeController( RuntimeDelegate& p_client, DartVM* p_vm, fml::RefPtr p_isolate_snapshot, - TaskRunners p_task_runners, - fml::WeakPtr p_snapshot_delegate, - fml::WeakPtr p_hint_freed_delegate, - fml::WeakPtr p_io_manager, - fml::RefPtr p_unref_queue, - fml::WeakPtr p_image_decoder, - fml::WeakPtr p_image_generator_registry, - std::string p_advisory_script_uri, - std::string p_advisory_script_entrypoint, - const std::function& idle_notification_callback, + const std::function& p_idle_notification_callback, const PlatformData& p_platform_data, const fml::closure& p_isolate_create_callback, const fml::closure& p_isolate_shutdown_callback, std::shared_ptr p_persistent_isolate_data, - std::shared_ptr p_volatile_path_tracker) + const UIDartState::Context& p_context) : client_(p_client), vm_(p_vm), - isolate_snapshot_(std::move(p_isolate_snapshot)), - task_runners_(p_task_runners), - snapshot_delegate_(p_snapshot_delegate), - hint_freed_delegate_(p_hint_freed_delegate), - io_manager_(p_io_manager), - unref_queue_(p_unref_queue), - image_decoder_(p_image_decoder), - image_generator_registry_(p_image_generator_registry), - advisory_script_uri_(p_advisory_script_uri), - advisory_script_entrypoint_(p_advisory_script_entrypoint), - idle_notification_callback_(idle_notification_callback), + isolate_snapshot_(p_isolate_snapshot), + idle_notification_callback_(p_idle_notification_callback), platform_data_(std::move(p_platform_data)), isolate_create_callback_(p_isolate_create_callback), isolate_shutdown_callback_(p_isolate_shutdown_callback), persistent_isolate_data_(std::move(p_persistent_isolate_data)), - volatile_path_tracker_(std::move(p_volatile_path_tracker)) {} + context_(p_context) {} std::unique_ptr RuntimeController::Spawn( - RuntimeDelegate& client, + RuntimeDelegate& p_client, std::string advisory_script_uri, std::string advisory_script_entrypoint, - const std::function& idle_notification_callback, - const fml::closure& isolate_create_callback, - const fml::closure& isolate_shutdown_callback, - std::shared_ptr persistent_isolate_data) const { - auto result = std::make_unique( - client, vm_, isolate_snapshot_, task_runners_, snapshot_delegate_, - hint_freed_delegate_, io_manager_, unref_queue_, image_decoder_, - image_generator_registry_, advisory_script_uri, - advisory_script_entrypoint, idle_notification_callback, platform_data_, - isolate_create_callback, isolate_shutdown_callback, - persistent_isolate_data, volatile_path_tracker_); + const std::function& p_idle_notification_callback, + const fml::closure& p_isolate_create_callback, + const fml::closure& p_isolate_shutdown_callback, + std::shared_ptr p_persistent_isolate_data) const { + auto result = + std::make_unique(p_client, // + vm_, // + isolate_snapshot_, // + p_idle_notification_callback, // + platform_data_, // + p_isolate_create_callback, // + p_isolate_shutdown_callback, // + p_persistent_isolate_data, // + context_); // result->spawning_isolate_ = root_isolate_; return result; } @@ -100,26 +85,16 @@ bool RuntimeController::IsRootIsolateRunning() { } std::unique_ptr RuntimeController::Clone() const { - return std::unique_ptr(new RuntimeController( - client_, // - vm_, // - isolate_snapshot_, // - task_runners_, // - snapshot_delegate_, // - hint_freed_delegate_, // - io_manager_, // - unref_queue_, // - image_decoder_, // - image_generator_registry_, // - advisory_script_uri_, // - advisory_script_entrypoint_, // - idle_notification_callback_, // - platform_data_, // - isolate_create_callback_, // - isolate_shutdown_callback_, // - persistent_isolate_data_, // - volatile_path_tracker_ // - )); + return std::make_unique(client_, // + vm_, // + isolate_snapshot_, // + idle_notification_callback_, // + platform_data_, // + isolate_create_callback_, // + isolate_shutdown_callback_, // + persistent_isolate_data_, // + context_ // + ); } bool RuntimeController::FlushRuntimeStateToIsolate() { @@ -394,25 +369,15 @@ bool RuntimeController::LaunchRootIsolate( DartIsolate::CreateRunningRootIsolate( settings, // isolate_snapshot_, // - task_runners_, // std::make_unique(this), // - snapshot_delegate_, // - hint_freed_delegate_, // - io_manager_, // - unref_queue_, // - image_decoder_, // - image_generator_registry_, // - advisory_script_uri_, // - advisory_script_entrypoint_, // DartIsolate::Flags{}, // isolate_create_callback_, // isolate_shutdown_callback_, // dart_entrypoint, // dart_entrypoint_library, // std::move(isolate_configuration), // - volatile_path_tracker_, // - spawning_isolate_.lock().get() // - ) + context_, // + spawning_isolate_.lock().get()) // .lock(); if (!strong_root_isolate) { diff --git a/engine/src/flutter/runtime/runtime_controller.h b/engine/src/flutter/runtime/runtime_controller.h index 9276d522df..ba7794b265 100644 --- a/engine/src/flutter/runtime/runtime_controller.h +++ b/engine/src/flutter/runtime/runtime_controller.h @@ -55,50 +55,6 @@ class RuntimeController : public PlatformConfigurationClient { /// collected before the VM is /// destroyed (this order is /// guaranteed by the shell). - /// @param[in] isolate_snapshot The isolate snapshot used to start - /// the root isolate managed by this - /// runtime controller. The isolate - /// must be transitioned into the - /// running phase manually by the - /// caller. - /// @param[in] task_runners The task runners used by the shell - /// hosting this runtime controller. - /// This may be used by the isolate to - /// scheduled asynchronous texture - /// uploads or post tasks to the - /// platform task runner. - /// @param[in] snapshot_delegate The snapshot delegate used by the - /// isolate to gather raster snapshots - /// of Flutter view hierarchies. - /// @param[in] hint_freed_delegate The delegate used by the isolate - /// to hint the Dart VM when - /// additional memory may be freed - /// if a GC ran at the next - /// NotifyIdle. - /// @param[in] io_manager The IO manager used by the isolate - /// for asynchronous texture uploads. - /// @param[in] unref_queue The unref queue used by the - /// isolate to collect resources that - /// may reference resources on the - /// GPU. - /// @param[in] image_decoder The image decoder. - /// @param[in] image_generator_registry Cascading registry of image - /// generator builders. Given - /// compressed image bytes as input, - /// this is used to find and create - /// image generators, which can then - /// be used for image decoding. - /// @param[in] advisory_script_uri The advisory script URI (only used - /// for debugging). This does not - /// affect the code being run in the - /// isolate in any way. - /// @param[in] advisory_script_entrypoint The advisory script entrypoint - /// (only used for debugging). This - /// does not affect the code being run - /// in the isolate in any way. The - /// isolate must be transitioned to - /// the running state explicitly by - /// the caller. /// @param[in] idle_notification_callback The idle notification callback. /// This allows callers to run native /// code in isolate scope when the VM @@ -118,28 +74,19 @@ class RuntimeController : public PlatformConfigurationClient { /// @param[in] persistent_isolate_data Unstructured persistent read-only /// data that the root isolate can /// access in a synchronous manner. - /// @param[in] volatile_path_tracker Cache for tracking path - /// volatility. + /// @param[in] context Engine-owned state which is + /// accessed by the root dart isolate. /// RuntimeController( - RuntimeDelegate& client, + RuntimeDelegate& p_client, DartVM* vm, - fml::RefPtr isolate_snapshot, - TaskRunners task_runners, - fml::WeakPtr snapshot_delegate, - fml::WeakPtr hint_freed_delegate, - fml::WeakPtr io_manager, - fml::RefPtr unref_queue, - fml::WeakPtr image_decoder, - fml::WeakPtr image_generator_registry, - std::string advisory_script_uri, - std::string advisory_script_entrypoint, + fml::RefPtr p_isolate_snapshot, const std::function& idle_notification_callback, const PlatformData& platform_data, const fml::closure& isolate_create_callback, const fml::closure& isolate_shutdown_callback, - std::shared_ptr persistent_isolate_data, - std::shared_ptr volatile_path_tracker); + std::shared_ptr p_persistent_isolate_data, + const UIDartState::Context& context); //---------------------------------------------------------------------------- /// @brief Create a RuntimeController that shares as many resources as @@ -149,7 +96,7 @@ class RuntimeController : public PlatformConfigurationClient { /// @see RuntimeController::RuntimeController /// std::unique_ptr Spawn( - RuntimeDelegate& client, + RuntimeDelegate& p_client, std::string advisory_script_uri, std::string advisory_script_entrypoint, const std::function& idle_notification_callback, @@ -589,7 +536,9 @@ class RuntimeController : public PlatformConfigurationClient { // |PlatformConfigurationClient| void RequestDartDeferredLibrary(intptr_t loading_unit_id) override; - const fml::WeakPtr& GetIOManager() const { return io_manager_; } + const fml::WeakPtr& GetIOManager() const { + return context_.io_manager; + } virtual DartVM* GetDartVM() const { return vm_; } @@ -600,16 +549,16 @@ class RuntimeController : public PlatformConfigurationClient { const PlatformData& GetPlatformData() const { return platform_data_; } const fml::RefPtr& GetSkiaUnrefQueue() const { - return unref_queue_; + return context_.unref_queue; } const fml::WeakPtr& GetSnapshotDelegate() const { - return snapshot_delegate_; + return context_.snapshot_delegate; } protected: /// Constructor for Mocks. - RuntimeController(RuntimeDelegate& client, TaskRunners p_task_runners); + RuntimeController(RuntimeDelegate& p_client, TaskRunners task_runners); private: struct Locale { @@ -629,15 +578,6 @@ class RuntimeController : public PlatformConfigurationClient { RuntimeDelegate& client_; DartVM* const vm_; fml::RefPtr isolate_snapshot_; - TaskRunners task_runners_; - fml::WeakPtr snapshot_delegate_; - fml::WeakPtr hint_freed_delegate_; - fml::WeakPtr io_manager_; - fml::RefPtr unref_queue_; - fml::WeakPtr image_decoder_; - fml::WeakPtr image_generator_registry_; - std::string advisory_script_uri_; - std::string advisory_script_entrypoint_; std::function idle_notification_callback_; PlatformData platform_data_; std::weak_ptr root_isolate_; @@ -646,7 +586,7 @@ class RuntimeController : public PlatformConfigurationClient { const fml::closure isolate_create_callback_; const fml::closure isolate_shutdown_callback_; std::shared_ptr persistent_isolate_data_; - std::shared_ptr volatile_path_tracker_; + UIDartState::Context context_; PlatformConfiguration* GetPlatformConfigurationIfAvailable(); diff --git a/engine/src/flutter/shell/common/engine.cc b/engine/src/flutter/shell/common/engine.cc index 678ff65eb0..3cca483b0c 100644 --- a/engine/src/flutter/shell/common/engine.cc +++ b/engine/src/flutter/shell/common/engine.cc @@ -87,25 +87,26 @@ Engine::Engine(Delegate& delegate, std::make_shared(), nullptr) { runtime_controller_ = std::make_unique( - *this, // runtime delegate - &vm, // VM - std::move(isolate_snapshot), // isolate snapshot - task_runners_, // task runners - std::move(snapshot_delegate), // snapshot delegate - GetWeakPtr(), // hint freed delegate - std::move(io_manager), // io manager - std::move(unref_queue), // Skia unref queue - image_decoder_.GetWeakPtr(), // image decoder - image_generator_registry_.GetWeakPtr(), // image generator registry - settings_.advisory_script_uri, // advisory script uri - settings_.advisory_script_entrypoint, // advisory script entrypoint - settings_.idle_notification_callback, // idle notification callback - platform_data, // platform data - settings_.isolate_create_callback, // isolate create callback - settings_.isolate_shutdown_callback, // isolate shutdown callback - settings_.persistent_isolate_data, // persistent isolate data - std::move(volatile_path_tracker) // volatile path tracker - ); + *this, // runtime delegate + &vm, // VM + std::move(isolate_snapshot), // isolate snapshot + settings_.idle_notification_callback, // idle notification callback + platform_data, // platform data + settings_.isolate_create_callback, // isolate create callback + settings_.isolate_shutdown_callback, // isolate shutdown callback + settings_.persistent_isolate_data, // persistent isolate data + UIDartState::Context{ + task_runners_, // task runners + std::move(snapshot_delegate), // snapshot delegate + GetWeakPtr(), // hint freed delegate + std::move(io_manager), // io manager + std::move(unref_queue), // Skia unref queue + image_decoder_.GetWeakPtr(), // image decoder + image_generator_registry_.GetWeakPtr(), // image generator registry + settings_.advisory_script_uri, // advisory script uri + settings_.advisory_script_entrypoint, // advisory script entrypoint + std::move(volatile_path_tracker), // volatile path tracker + }); } std::unique_ptr Engine::Spawn( diff --git a/engine/src/flutter/testing/dart_isolate_runner.cc b/engine/src/flutter/testing/dart_isolate_runner.cc index e8f3d0875a..84f9bd3008 100644 --- a/engine/src/flutter/testing/dart_isolate_runner.cc +++ b/engine/src/flutter/testing/dart_isolate_runner.cc @@ -119,27 +119,23 @@ std::unique_ptr RunDartCodeInIsolateOnUITaskRunner( auto isolate_configuration = IsolateConfiguration::InferFromSettings(settings); + UIDartState::Context context(std::move(task_runners)); + context.io_manager = io_manager; + context.advisory_script_uri = "main.dart"; + context.advisory_script_entrypoint = entrypoint.c_str(); + auto isolate = DartIsolate::CreateRunningRootIsolate( settings, // settings vm_data->GetIsolateSnapshot(), // isolate snapshot - std::move(task_runners), // task runners - nullptr, // window - {}, // snapshot delegate - {}, // hint freed delegate - io_manager, // io manager - {}, // unref queue - {}, // image decoder - {}, // image generator registry - "main.dart", // advisory uri - entrypoint.c_str(), // advisory entrypoint + nullptr, // platform configuration DartIsolate::Flags{}, // flags settings.isolate_create_callback, // isolate create callback settings.isolate_shutdown_callback, // isolate shutdown callback entrypoint, // entrypoint std::nullopt, // library std::move(isolate_configuration), // isolate configuration - std::move(volatile_path_tracker) // volatile path tracker + context // engine context ) .lock(); diff --git a/engine/src/flutter/third_party/tonic/tests/dart_state_unittest.cc b/engine/src/flutter/third_party/tonic/tests/dart_state_unittest.cc index f5725cbfc8..dd0c15f26f 100644 --- a/engine/src/flutter/third_party/tonic/tests/dart_state_unittest.cc +++ b/engine/src/flutter/third_party/tonic/tests/dart_state_unittest.cc @@ -27,26 +27,21 @@ TEST_F(DartState, IsShuttingDown) { ); auto isolate_configuration = IsolateConfiguration::InferFromSettings(settings); + + UIDartState::Context context(std::move(task_runners)); + context.advisory_script_uri = "main.dart"; + context.advisory_script_entrypoint = "main"; auto weak_isolate = DartIsolate::CreateRunningRootIsolate( vm_data->GetSettings(), // settings vm_data->GetIsolateSnapshot(), // isolate snapshot - std::move(task_runners), // task runners - nullptr, // window - {}, // snapshot delegate - {}, // hint freed delegate - {}, // io manager - {}, // unref queue - {}, // image decoder - {}, // image generator registry - "main.dart", // advisory uri - "main", // advisory entrypoint + nullptr, // platform configuration DartIsolate::Flags{}, // flags settings.isolate_create_callback, // isolate create callback settings.isolate_shutdown_callback, // isolate shutdown callback "main", // dart entrypoint std::nullopt, // dart entrypoint library std::move(isolate_configuration), // isolate configuration - nullptr // Volatile path tracker + std::move(context) // engine context ); auto root_isolate = weak_isolate.lock(); ASSERT_TRUE(root_isolate);