5#ifndef FLUTTER_RUNTIME_RUNTIME_CONTROLLER_H_
6#define FLUTTER_RUNTIME_RUNTIME_CONTROLLER_H_
103 const std::function<
void(int64_t)>& idle_notification_callback,
107 std::shared_ptr<const fml::Mapping> p_persistent_isolate_data,
117 std::unique_ptr<RuntimeController>
Spawn(
119 const std::string& advisory_script_uri,
120 const std::string& advisory_script_entrypoint,
121 const std::function<
void(int64_t)>& idle_notification_callback,
124 const std::shared_ptr<const fml::Mapping>& persistent_isolate_data,
128 image_generator_registry,
171 std::optional<std::string> dart_entrypoint,
172 std::optional<std::string> dart_entrypoint_library,
173 const std::vector<std::string>& dart_entrypoint_args,
174 std::unique_ptr<IsolateConfiguration> isolate_configuration,
175 std::shared_ptr<NativeAssetsManager> native_assets_manager,
176 std::optional<int64_t> engine_id);
187 std::unique_ptr<RuntimeController>
Clone()
const;
274 bool SetLocales(
const std::vector<std::string>& locale_data);
468 std::unique_ptr<PlatformMessage>
message);
613 intptr_t loading_unit_id,
614 std::unique_ptr<const fml::Mapping> snapshot_data,
615 std::unique_ptr<const fml::Mapping> snapshot_instructions);
640 const std::string error_message,
665 return isolate_snapshot_;
680 return root_isolate_;
684 if (
auto isolate = root_isolate_.lock()) {
685 isolate->FlushMicrotasksNow();
690 return platform_isolate_manager_;
707 Locale(std::string language_code_,
708 std::string country_code_,
709 std::string script_code_,
710 std::string variant_code_);
714 std::string language_code;
715 std::string country_code;
716 std::string script_code;
717 std::string variant_code;
720 RuntimeDelegate& client_;
723 std::function<void(int64_t)> idle_notification_callback_;
724 PlatformData platform_data_;
725 std::weak_ptr<DartIsolate> root_isolate_;
726 std::weak_ptr<DartIsolate> spawning_isolate_;
727 std::optional<uint32_t> root_isolate_return_code_;
730 std::shared_ptr<const fml::Mapping> persistent_isolate_data_;
731 UIDartState::Context context_;
732 PointerDataPacketConverter pointer_data_packet_converter_;
733 std::shared_ptr<PlatformIsolateManager> platform_isolate_manager_ =
734 std::shared_ptr<PlatformIsolateManager>(
new PlatformIsolateManager());
735 bool has_flushed_runtime_state_ =
false;
741 std::unordered_map<int64_t, AddViewCallback> pending_add_view_callbacks_;
757 std::unordered_set<uint64_t> rendered_views_during_frame_;
759 void MarkAsFrameBorder();
761 void CheckIfAllViewsRendered();
763 PlatformConfiguration* GetPlatformConfigurationIfAvailable();
765 bool FlushRuntimeStateToIsolate();
768 bool ViewExists(int64_t
view_id)
const override;
771 std::string DefaultRouteName()
override;
774 void ScheduleFrame()
override;
777 void EndWarmUpFrame()
override;
786 void HandlePlatformMessage(std::unique_ptr<PlatformMessage>
message)
override;
789 FontCollection& GetFontCollection()
override;
792 std::shared_ptr<AssetManager> GetAssetManager()
override;
795 void UpdateIsolateDescription(
const std::string isolate_name,
796 int64_t isolate_port)
override;
799 void SetNeedsReportTimings(
bool value)
override;
802 std::unique_ptr<std::vector<std::string>> ComputePlatformResolvedLocale(
803 const std::vector<std::string>& supported_locale_data)
override;
806 void SendChannelUpdate(std::string
name,
bool listening)
override;
809 double GetScaledFontSize(
double unscaled_font_size,
810 int configuration_id)
const override;
813 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()
HitTestResponse HitTest(int64_t view_id, const flutter::PointData offset)
Requests to perform framework hit test from the engine.
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 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