5#include "flutter/testing/dart_isolate_runner.h"
9#include "flutter/runtime/isolate_configuration.h"
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(
71 std::string entrypoint,
72 const std::vector<std::string>&
args,
73 const std::string& kernel_file_path,
75 const std::shared_ptr<VolatilePathTracker>& volatile_path_tracker,
76 std::unique_ptr<PlatformConfiguration> platform_configuration) {
97 auto kernel_file =
fml::OpenFile(kernel_file_path.c_str(),
false,
100 if (!kernel_file.is_valid()) {
101 FML_LOG(
ERROR) <<
"Kernel file descriptor was invalid.";
105 auto kernel_mapping = std::make_unique<fml::FileMapping>(kernel_file);
107 if (kernel_mapping->GetMapping() ==
nullptr) {
113 [kernel_mapping = std::move(kernel_mapping)]()
mutable ->
Mappings {
115 mappings.emplace_back(std::move(kernel_mapping));
120 auto isolate_configuration =
132 vm_data->GetIsolateSnapshot(),
133 std::move(platform_configuration),
141 std::move(isolate_configuration),
151 return std::make_unique<AutoIsolateShutdown>(
159 std::string entrypoint,
160 const std::vector<std::string>&
args,
161 const std::string& kernel_file_path,
163 std::shared_ptr<VolatilePathTracker> volatile_path_tracker,
164 std::unique_ptr<PlatformConfiguration> platform_configuration) {
165 std::unique_ptr<AutoIsolateShutdown>
result;
169 result = RunDartCodeInIsolateOnUITaskRunner(
170 vm_ref, settings, task_runners, entrypoint, args, kernel_file_path,
171 io_manager, volatile_path_tracker,
172 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)
Creates an instance of a root isolate and returns a weak pointer to the same. The isolate instance ma...
static std::shared_ptr< const DartVMData > GetVMData()
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::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)
Dart_NativeFunction function
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::shared_ptr< VolatilePathTracker > volatile_path_tracker, 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, const std::shared_ptr< VolatilePathTracker > &volatile_path_tracker, 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)
std::function< void()> closure
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