15 : isolate_(
std::move(isolate)), runner_(
std::move(runner)) {}
18 if (!isolate_->IsShuttingDown()) {
36 runner_, [isolate = isolate_.get(), &latch]() {
37 if (!isolate->Shutdown()) {
38 FML_LOG(ERROR) <<
"Could not shutdown isolate.";
46[[nodiscard]]
bool AutoIsolateShutdown::RunInIsolateScope(
47 const std::function<
bool(
void)>& closure) {
55 runner_, [
this, &result, &latch, closure]() {
71 std::string entrypoint,
72 const std::vector<std::string>&
args,
73 const std::string& kernel_file_path,
75 std::unique_ptr<PlatformConfiguration> platform_configuration) {
88 auto settings = p_settings;
92 FML_LOG(ERROR) <<
"Could not locate kernel file.";
96 auto kernel_file =
fml::OpenFile(kernel_file_path.c_str(),
false,
99 if (!kernel_file.is_valid()) {
100 FML_LOG(ERROR) <<
"Kernel file descriptor was invalid.";
104 auto kernel_mapping = std::make_unique<fml::FileMapping>(kernel_file);
106 if (kernel_mapping->GetMapping() ==
nullptr) {
107 FML_LOG(ERROR) <<
"Could not set up kernel mapping.";
112 [kernel_mapping = std::move(kernel_mapping)]()
mutable ->
Mappings {
114 mappings.emplace_back(std::move(kernel_mapping));
119 auto isolate_configuration =
131 vm_data->GetIsolateSnapshot(),
132 std::move(platform_configuration),
135 settings.isolate_create_callback,
136 settings.isolate_shutdown_callback,
140 std::move(isolate_configuration),
146 FML_LOG(ERROR) <<
"Could not create running isolate.";
150 return std::make_unique<AutoIsolateShutdown>(
158 std::string entrypoint,
159 const std::vector<std::string>&
args,
160 const std::string& kernel_file_path,
162 std::unique_ptr<PlatformConfiguration> platform_configuration) {
163 std::unique_ptr<AutoIsolateShutdown> result;
167 result = RunDartCodeInIsolateOnUITaskRunner(
168 vm_ref, settings, task_runners, entrypoint, args, kernel_file_path,
169 io_manager, std::move(platform_configuration));
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, std::shared_ptr< NativeAssetsManager > native_assets_manager=nullptr)
Creates an instance of a root isolate and returns a weak pointer to the same. The isolate instance ma...
static bool IsRunningPrecompiledCode()
Checks if VM instances in the process can run precompiled code. This call can be made at any time and...
static std::shared_ptr< const DartVMData > GetVMData()
static std::unique_ptr< IsolateConfiguration > InferFromSettings(const Settings &settings, const std::shared_ptr< AssetManager > &asset_manager=nullptr, const fml::RefPtr< fml::TaskRunner > &io_worker=nullptr, IsolateLaunchType launch_type=IsolateLaunchType::kNewGroup)
Attempts to infer the isolate configuration from the Settings object. If the VM is configured for AOT...
fml::RefPtr< fml::TaskRunner > GetUITaskRunner() const
AutoIsolateShutdown()=default
static void RunNowOrPostTask(const fml::RefPtr< fml::TaskRunner > &runner, const fml::closure &task)
virtual bool RunsTasksOnCurrentThread()
G_BEGIN_DECLS G_MODULE_EXPORT FlValue * args
#define FML_LOG(severity)
#define FML_CHECK(condition)
std::unique_ptr< AutoIsolateShutdown > RunDartCodeInIsolate(DartVMRef &vm_ref, const Settings &settings, const TaskRunners &task_runners, std::string entrypoint, const std::vector< std::string > &args, const std::string &kernel_file_path, fml::WeakPtr< IOManager > io_manager, std::unique_ptr< PlatformConfiguration > platform_configuration)
std::unique_ptr< AutoIsolateShutdown > RunDartCodeInIsolateOnUITaskRunner(DartVMRef &vm_ref, const Settings &p_settings, const TaskRunners &task_runners, std::string entrypoint, const std::vector< std::string > &args, const std::string &kernel_file_path, fml::WeakPtr< IOManager > io_manager, std::unique_ptr< PlatformConfiguration > platform_configuration)
std::vector< std::unique_ptr< const fml::Mapping > > Mappings
internal::CopyableLambda< T > MakeCopyable(T lambda)
bool IsFile(const std::string &path)
fml::UniqueFD OpenFile(const char *path, bool create_if_necessary, FilePermission permission)
This can open a directory on POSIX, but not on Windows.
The subset of state which is owned by the shell or engine and passed through the RuntimeController in...
fml::WeakPtr< IOManager > io_manager
The IO manager used by the isolate for asynchronous texture uploads.
std::string advisory_script_uri
const TaskRunners task_runners
bool enable_impeller
Whether Impeller is enabled or not.
std::string advisory_script_entrypoint