5#ifndef FLUTTER_RUNTIME_DART_ISOLATE_H_
6#define FLUTTER_RUNTIME_DART_ISOLATE_H_
12#include <unordered_set>
14#include "flutter/common/task_runners.h"
15#include "flutter/fml/compiler_specific.h"
16#include "flutter/fml/macros.h"
17#include "flutter/fml/mapping.h"
18#include "flutter/lib/ui/io_manager.h"
19#include "flutter/lib/ui/snapshot_delegate.h"
20#include "flutter/lib/ui/ui_dart_state.h"
21#include "flutter/lib/ui/window/platform_configuration.h"
22#include "flutter/runtime/dart_snapshot.h"
23#include "flutter/runtime/isolate_configuration.h"
24#include "third_party/dart/runtime/include/dart_api.h"
30class DartIsolateGroupData;
31class IsolateConfiguration;
220 std::optional<std::string> dart_entrypoint,
221 std::optional<std::string> dart_entrypoint_library,
222 const std::vector<std::string>& dart_entrypoint_args,
223 std::unique_ptr<IsolateConfiguration> isolate_configuration,
289 const std::shared_ptr<const fml::Mapping>& kernel,
309 std::vector<std::shared_ptr<const fml::Mapping>> kernels);
327 std::vector<std::unique_ptr<const fml::Mapping>> kernels);
343 [[nodiscard]]
bool RunFromLibrary(std::optional<std::string> library_name,
344 std::optional<std::string> entrypoint,
345 const std::vector<std::string>&
args);
399 char**
error)
override;
402 intptr_t loading_unit_id,
403 std::unique_ptr<const fml::Mapping> snapshot_data,
404 std::unique_ptr<const fml::Mapping> snapshot_instructions);
407 const std::string& error_message,
417 const std::shared_ptr<const fml::Mapping>& mapping);
421 class AutoFireClosure {
434 std::vector<std::unique_ptr<AutoFireClosure>> shutdown_callbacks_;
435 std::unordered_set<fml::RefPtr<DartSnapshot>> loading_unit_snapshots_;
437 const bool may_insecurely_connect_to_all_domains_;
438 const bool is_platform_isolate_;
439 const bool is_spawning_in_group_;
440 std::string domain_network_policy_;
441 std::shared_ptr<PlatformIsolateManager> platform_isolate_manager_;
443 static std::weak_ptr<DartIsolate> CreateRootIsolate(
454 bool is_root_isolate,
456 bool is_spawning_in_group =
false);
460 std::shared_ptr<PlatformIsolateManager> platform_isolate_manager);
474 bool post_directly_to_runner);
476 bool LoadKernel(
const std::shared_ptr<const fml::Mapping>& mapping,
479 [[nodiscard]]
bool LoadLibraries();
481 bool UpdateThreadPoolNames()
const;
483 [[nodiscard]]
bool MarkIsolateRunnable();
485 void OnShutdownCallback();
489 const char* advisory_script_uri,
490 const char* advisory_script_entrypoint,
491 const char* package_root,
492 const char* package_config,
494 std::shared_ptr<DartIsolate>* parent_isolate_group,
498 static bool DartIsolateInitializeCallback(
void** child_callback_data,
502 const char* package_root,
503 const char* package_config,
508 std::shared_ptr<DartIsolate>*,
514 std::unique_ptr<std::shared_ptr<DartIsolateGroupData>> isolate_group_data,
515 std::unique_ptr<std::shared_ptr<DartIsolate>> isolate_data,
518 const IsolateMaker& make_isolate);
520 static bool InitializeIsolate(
521 const std::shared_ptr<DartIsolate>& embedder_isolate,
526 static void DartIsolateShutdownCallback(
527 std::shared_ptr<DartIsolateGroupData>* isolate_group_data,
528 std::shared_ptr<DartIsolate>* isolate_data);
531 static void DartIsolateCleanupCallback(
532 std::shared_ptr<DartIsolateGroupData>* isolate_group_data,
533 std::shared_ptr<DartIsolate>* isolate_data);
536 static void DartIsolateGroupCleanupCallback(
537 std::shared_ptr<DartIsolateGroupData>* isolate_group_data);
540 static Dart_Handle OnDartLoadLibrary(intptr_t loading_unit_id);
542 static void SpawnIsolateShutdownCallback(
543 std::shared_ptr<DartIsolateGroupData>* isolate_group_data,
544 std::shared_ptr<DartIsolate>* isolate_data);
void SetNullSafetyEnabled(bool enabled)
void SetIsDontNeedSafe(bool value)
Dart_IsolateFlags Get() const
Represents an instance of a live isolate. An isolate is a separate Dart execution context....
bool PrepareForRunningFromKernel(const std::shared_ptr< const fml::Mapping > &kernel, bool child_isolate, bool last_piece)
Prepare the isolate for running for a a list of kernel files.
std::string GetServiceId()
Returns the ID for an isolate which is used to query the service protocol.
void LoadLoadingUnitError(intptr_t loading_unit_id, const std::string &error_message, bool transient)
std::weak_ptr< DartIsolate > GetWeakIsolatePtr()
A weak pointer to the Dart isolate instance. This instance may only be used on the task runner that c...
Dart_Isolate CreatePlatformIsolate(Dart_Handle entry_point, char **error) override
Creates a new isolate in the same group as this isolate, which runs on the platform thread....
static std::weak_ptr< DartIsolate > CreateRunningRootIsolate(const Settings &settings, const fml::RefPtr< const DartSnapshot > &isolate_snapshot, std::unique_ptr< PlatformConfiguration > platform_configuration, Flags flags, const fml::closure &root_isolate_create_callback, const fml::closure &isolate_create_callback, const fml::closure &isolate_shutdown_callback, std::optional< std::string > dart_entrypoint, std::optional< std::string > dart_entrypoint_library, const std::vector< std::string > &dart_entrypoint_args, std::unique_ptr< IsolateConfiguration > isolate_configuration, const UIDartState::Context &context, const DartIsolate *spawning_isolate=nullptr)
Creates an instance of a root isolate and returns a weak pointer to the same. The isolate instance ma...
bool PrepareForRunningFromKernels(std::vector< std::shared_ptr< const fml::Mapping > > kernels)
Prepare the isolate for running for a a list of kernel files.
static Dart_Handle LoadLibraryFromKernel(const std::shared_ptr< const fml::Mapping > &mapping)
bool RunFromLibrary(std::optional< std::string > library_name, std::optional< std::string > entrypoint, const std::vector< std::string > &args)
Transition the root isolate to the Phase::Running phase and invoke the main entrypoint (the "main" me...
DartIsolateGroupData & GetIsolateGroupData()
void AddIsolateShutdownCallback(const fml::closure &closure)
Registers a callback that will be invoked in isolate scope just before the isolate transitions to the...
fml::RefPtr< fml::TaskRunner > GetMessageHandlingTaskRunner() const
The task runner on which the Dart code for the root isolate is running. For the root isolate,...
bool Shutdown()
Transition the isolate to the Phase::Shutdown phase. The only thing left to do is to collect the isol...
Phase GetPhase() const
The current phase of the isolate. The engine represents all dart isolates as being in one of the know...
bool PrepareForRunningFromPrecompiledCode()
Prepare the isolate for running for a precompiled code bundle. The Dart VM must be configured for run...
bool LoadLoadingUnit(intptr_t loading_unit_id, std::unique_ptr< const fml::Mapping > snapshot_data, std::unique_ptr< const fml::Mapping > snapshot_instructions)
Phase
The engine represents all dart isolates as being in one of the known phases. By invoking various meth...
Describes a running instance of the Dart VM. There may only be one running instance of the Dart VM in...
An isolate configuration is a collection of snapshots and asset managers that the engine will use to ...
PlatformConfiguration * platform_configuration() const
struct _Dart_Handle * Dart_Handle
struct _Dart_Isolate * Dart_Isolate
FlutterSemanticsFlag flags
G_BEGIN_DECLS G_MODULE_EXPORT FlValue * args
const uint8_t uint32_t uint32_t GError ** error
#define FML_DISALLOW_COPY_AND_ASSIGN(TypeName)
Dart_NativeFunction function
std::function< void()> closure
void Initialize(zx::channel directory_request, std::optional< zx::eventpair > view_ref)
Initializes Dart bindings for the Fuchsia application model.
The subset of state which is owned by the shell or engine and passed through the RuntimeController in...
flags to indicate/promise which of the optional texture coordinates or colors will be supplied during...