5#ifndef FLUTTER_RUNTIME_RUNTIME_CONTROLLER_H_
6#define FLUTTER_RUNTIME_RUNTIME_CONTROLLER_H_
101 const std::function<
void(int64_t)>& idle_notification_callback,
105 std::shared_ptr<const fml::Mapping> p_persistent_isolate_data,
115 std::unique_ptr<RuntimeController>
Spawn(
117 const std::string& advisory_script_uri,
118 const std::string& advisory_script_entrypoint,
119 const std::function<
void(int64_t)>& idle_notification_callback,
122 const std::shared_ptr<const fml::Mapping>& persistent_isolate_data,
126 image_generator_registry,
169 std::optional<std::string> dart_entrypoint,
170 std::optional<std::string> dart_entrypoint_library,
171 const std::vector<std::string>& dart_entrypoint_args,
172 std::unique_ptr<IsolateConfiguration> isolate_configuration,
173 std::shared_ptr<NativeAssetsManager> native_assets_manager,
174 std::optional<int64_t> engine_id);
185 std::unique_ptr<RuntimeController>
Clone()
const;
272 bool SetLocales(
const std::vector<std::string>& locale_data);
466 std::unique_ptr<PlatformMessage>
message);
600 intptr_t loading_unit_id,
601 std::unique_ptr<const fml::Mapping> snapshot_data,
602 std::unique_ptr<const fml::Mapping> snapshot_instructions);
627 const std::string error_message,
652 return isolate_snapshot_;
667 return root_isolate_;
671 if (
auto isolate = root_isolate_.lock()) {
672 isolate->FlushMicrotasksNow();
677 return platform_isolate_manager_;
694 Locale(std::string language_code_,
695 std::string country_code_,
696 std::string script_code_,
697 std::string variant_code_);
701 std::string language_code;
702 std::string country_code;
703 std::string script_code;
704 std::string variant_code;
707 RuntimeDelegate& client_;
710 std::function<void(int64_t)> idle_notification_callback_;
711 PlatformData platform_data_;
712 std::weak_ptr<DartIsolate> root_isolate_;
713 std::weak_ptr<DartIsolate> spawning_isolate_;
714 std::optional<uint32_t> root_isolate_return_code_;
717 std::shared_ptr<const fml::Mapping> persistent_isolate_data_;
718 UIDartState::Context context_;
719 PointerDataPacketConverter pointer_data_packet_converter_;
720 std::shared_ptr<PlatformIsolateManager> platform_isolate_manager_ =
721 std::shared_ptr<PlatformIsolateManager>(
new PlatformIsolateManager());
722 bool has_flushed_runtime_state_ =
false;
728 std::unordered_map<int64_t, AddViewCallback> pending_add_view_callbacks_;
744 std::unordered_set<uint64_t> rendered_views_during_frame_;
746 void MarkAsFrameBorder();
748 void CheckIfAllViewsRendered();
750 PlatformConfiguration* GetPlatformConfigurationIfAvailable();
752 bool FlushRuntimeStateToIsolate();
755 bool ViewExists(int64_t
view_id)
const override;
758 std::string DefaultRouteName()
override;
761 void ScheduleFrame()
override;
764 void EndWarmUpFrame()
override;
773 void HandlePlatformMessage(std::unique_ptr<PlatformMessage>
message)
override;
776 FontCollection& GetFontCollection()
override;
779 std::shared_ptr<AssetManager> GetAssetManager()
override;
782 void UpdateIsolateDescription(
const std::string isolate_name,
783 int64_t isolate_port)
override;
786 void SetNeedsReportTimings(
bool value)
override;
789 std::unique_ptr<std::vector<std::string>> ComputePlatformResolvedLocale(
790 const std::vector<std::string>& supported_locale_data)
override;
793 void SendChannelUpdate(std::string
name,
bool listening)
override;
796 double GetScaledFontSize(
double unscaled_font_size,
797 int configuration_id)
const override;
800 void RequestViewFocusChange(
const ViewFocusChangeRequest& request)
override;
Describes a running instance of the Dart VM. There may only be one running instance of the Dart VM in...
void AddView(int64_t view_id, const ViewportMetrics &view_metrics, AddViewCallback callback)
Notify the isolate that a new view is available.
~RuntimeController() override
bool SetAccessibilityFeatures(int32_t flags)
Forward the preference of accessibility features that must be enabled in the semantics tree to the ru...
void SetRootIsolateOwnerToCurrentThread()
void SetSemanticsTreeEnabled(bool enabled) override
Notifies whether Framework starts generating semantics tree.
Dart_Port GetMainPort()
Gets the main port identifier of the root isolate.
bool SetSemanticsEnabled(bool enabled)
Notifies the running isolate about whether the semantics tree should be generated or not....
bool SetViewportMetrics(int64_t view_id, const ViewportMetrics &metrics)
Forward the specified viewport metrics to the running isolate. If the isolate is not running,...
uint64_t GetRootIsolateGroup() const
Get an identifier that represents the Dart isolate group the root isolate is in.
virtual bool NotifyIdle(fml::TimeDelta deadline)
Notify the Dart VM that no frame workloads are expected on the UI task runner till the specified dead...
bool HasPendingMicrotasks()
Returns if the root isolate has any pending microtasks.
std::weak_ptr< const DartIsolate > GetRootIsolate() const
bool DispatchPointerDataPacket(const PointerDataPacket &packet)
Dispatch the specified pointer data message to the running root isolate.
bool SetInitialLifecycleState(const std::string &data)
Forward the initial lifecycle state data to the running isolate. If the isolate is not running,...
std::function< void(bool added)> AddViewCallback
std::shared_ptr< PlatformIsolateManager > GetPlatformIsolateManager() override
bool SetLocales(const std::vector< std::string > &locale_data)
Forward the specified locale data to the running isolate. If the isolate is not running,...
void RequestDartDeferredLibrary(intptr_t loading_unit_id) override
Invoked when the Dart VM requests that a deferred library be loaded. Notifies the engine that the def...
bool SetDisplays(const std::vector< DisplayData > &displays)
Forward the specified display metrics to the running isolate. If the isolate is not running,...
void FlushMicrotaskQueue()
bool HasLivePorts()
Returns if the root isolate has any live receive ports.
bool RemoveView(int64_t view_id)
Notify the isolate that a view is no longer available.
std::optional< std::string > GetRootIsolateServiceID() const
Get the service ID of the root isolate if the root isolate is running.
const fml::RefPtr< const DartSnapshot > & GetIsolateSnapshot() const
const PlatformData & GetPlatformData() const
virtual bool IsRootIsolateRunning() const
Returns if the root isolate is running. The isolate must be transitioned to the running phase manuall...
bool LaunchRootIsolate(const Settings &settings, const fml::closure &root_isolate_create_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, std::shared_ptr< NativeAssetsManager > native_assets_manager, std::optional< int64_t > engine_id)
Launches the isolate using the window data associated with this runtime controller....
bool ReportTimings(std::vector< int64_t > timings)
Dart code cannot fully measure the time it takes for a specific frame to be rendered....
const fml::RefPtr< SkiaUnrefQueue > & GetSkiaUnrefQueue() const
const fml::TaskRunnerAffineWeakPtr< SnapshotDelegate > & GetSnapshotDelegate() const
bool DispatchSemanticsAction(int64_t view_id, int32_t node_id, SemanticsAction action, fml::MallocMapping args)
Dispatch the semantics action to the specified accessibility node.
virtual bool DispatchPlatformMessage(std::unique_ptr< PlatformMessage > message)
Dispatch the specified platform message to running root isolate.
tonic::DartErrorHandleType GetLastError()
Get the last error encountered by the microtask queue.
bool SetUserSettingsData(const std::string &data)
Forward the user settings data to the running isolate. If the isolate is not running,...
void LoadDartDeferredLibrary(intptr_t loading_unit_id, std::unique_ptr< const fml::Mapping > snapshot_data, std::unique_ptr< const fml::Mapping > snapshot_instructions)
Loads the Dart shared library into the Dart VM. When the Dart library is loaded successfully,...
std::unique_ptr< RuntimeController > Clone() const
Clone the runtime controller. Launching an isolate with a cloned runtime controller will use the same...
bool SendViewFocusEvent(const ViewFocusEvent &event)
Notify the isolate that the focus state of a native view has changed.
void ShutdownPlatformIsolates()
Shuts down all registered platform isolates. Must be called from the platform thread.
std::unique_ptr< RuntimeController > Spawn(RuntimeDelegate &p_client, const std::string &advisory_script_uri, const std::string &advisory_script_entrypoint, const std::function< void(int64_t)> &idle_notification_callback, const fml::closure &isolate_create_callback, const fml::closure &isolate_shutdown_callback, const std::shared_ptr< const fml::Mapping > &persistent_isolate_data, fml::WeakPtr< IOManager > io_manager, fml::TaskRunnerAffineWeakPtr< ImageDecoder > image_decoder, fml::TaskRunnerAffineWeakPtr< ImageGeneratorRegistry > image_generator_registry, fml::TaskRunnerAffineWeakPtr< SnapshotDelegate > snapshot_delegate) const
Create a RuntimeController that shares as many resources as possible with the calling RuntimeControll...
void UpdateSemantics(int64_t view_id, SemanticsUpdate *update) override
Receives an updated semantics tree from the Framework.
virtual DartVM * GetDartVM() const
bool BeginFrame(fml::TimePoint frame_time, uint64_t frame_number)
Notifies the running isolate that it should start generating a new frame.
std::optional< uint32_t > GetRootIsolateReturnCode()
Get the return code specified by the root isolate (if one is present).
std::shared_ptr< const fml::Mapping > GetPersistentIsolateData() override
The embedder can specify data that the isolate can request synchronously on launch....
const fml::WeakPtr< IOManager > & GetIOManager() const
virtual void LoadDartDeferredLibraryError(intptr_t loading_unit_id, const std::string error_message, bool transient)
Indicates to the dart VM that the request to load a deferred library with the specified loading unit ...
void SetApplicationLocale(std::string locale) override
Framework sets the application locale.
std::string GetIsolateName()
Gets the debug name of the root isolate. But default, the debug name of the isolate is derived from i...
A Mapping like NonOwnedMapping, but uses Free as its release proc.
G_BEGIN_DECLS G_MODULE_EXPORT FlValue * args
G_BEGIN_DECLS GBytes * message
G_BEGIN_DECLS FlutterViewId view_id
FlutterDesktopBinaryReply callback
#define FML_DISALLOW_COPY_AND_ASSIGN(TypeName)
DEF_SWITCHES_START aot vmservice shared library name
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot data
std::function< void()> closure
The subset of state which is owned by the shell or engine and passed through the RuntimeController in...
fml::RefPtr< SkiaUnrefQueue > unref_queue
fml::WeakPtr< IOManager > io_manager
The IO manager used by the isolate for asynchronous texture uploads.
fml::TaskRunnerAffineWeakPtr< SnapshotDelegate > snapshot_delegate