Flutter Engine
The Flutter Engine
|
#include <runtime_controller.h>
Public Types | |
using | AddViewCallback = std::function< void(bool added)> |
Public Member Functions | |
RuntimeController (RuntimeDelegate &p_client, DartVM *vm, fml::RefPtr< const DartSnapshot > p_isolate_snapshot, const std::function< void(int64_t)> &idle_notification_callback, const PlatformData &platform_data, const fml::closure &isolate_create_callback, const fml::closure &isolate_shutdown_callback, std::shared_ptr< const fml::Mapping > p_persistent_isolate_data, const UIDartState::Context &context) | |
Creates a new instance of a runtime controller. This is usually only done by the engine instance associated with the shell. More... | |
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::WeakPtr< ImageDecoder > image_decoder, fml::WeakPtr< ImageGeneratorRegistry > image_generator_registry, fml::TaskRunnerAffineWeakPtr< SnapshotDelegate > snapshot_delegate) const |
Create a RuntimeController that shares as many resources as possible with the calling RuntimeController such that together they occupy less memory. More... | |
~RuntimeController () override | |
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) |
Launches the isolate using the window data associated with this runtime controller. Before this call, the Dart isolate has not been initialized. On successful return, the caller can assume that the isolate is in the DartIsolate::Phase::Running phase. More... | |
std::unique_ptr< RuntimeController > | Clone () const |
Clone the runtime controller. Launching an isolate with a cloned runtime controller will use the same snapshots and copies all window data to the new instance. This is usually only used in the debug runtime mode to support the cold-restart scenario. More... | |
void | AddView (int64_t view_id, const ViewportMetrics &view_metrics, AddViewCallback callback) |
Notify the isolate that a new view is available. More... | |
bool | RemoveView (int64_t view_id) |
Notify the isolate that a view is no longer available. More... | |
bool | SetViewportMetrics (int64_t view_id, const ViewportMetrics &metrics) |
Forward the specified viewport metrics to the running isolate. If the isolate is not running, these metrics will be saved and flushed to the isolate when it starts. More... | |
bool | SetDisplays (const std::vector< DisplayData > &displays) |
Forward the specified display metrics to the running isolate. If the isolate is not running, these metrics will be saved and flushed to the isolate when it starts. More... | |
bool | SetLocales (const std::vector< std::string > &locale_data) |
Forward the specified locale data to the running isolate. If the isolate is not running, this data will be saved and flushed to the isolate when it starts running. More... | |
bool | SetUserSettingsData (const std::string &data) |
Forward the user settings data to the running isolate. If the isolate is not running, this data will be saved and flushed to the isolate when it starts running. More... | |
bool | SetInitialLifecycleState (const std::string &data) |
Forward the initial lifecycle state data to the running isolate. If the isolate is not running, this data will be saved and flushed to the isolate when it starts running. After the isolate starts running, the current lifecycle state is pushed to it via the "flutter/lifecycle" channel. More... | |
bool | SetSemanticsEnabled (bool enabled) |
Notifies the running isolate about whether the semantics tree should be generated or not. If the isolate is not running, this preference will be saved and flushed to the isolate when it starts running. More... | |
bool | SetAccessibilityFeatures (int32_t flags) |
Forward the preference of accessibility features that must be enabled in the semantics tree to the running isolate. If the isolate is not running, this data will be saved and flushed to the isolate when it starts running. More... | |
bool | BeginFrame (fml::TimePoint frame_time, uint64_t frame_number) |
Notifies the running isolate that it should start generating a new frame. More... | |
bool | ReportTimings (std::vector< int64_t > timings) |
Dart code cannot fully measure the time it takes for a specific frame to be rendered. This is because Dart code only runs on the UI task runner. That is only a small part of the overall frame workload. The raster task runner frame workload is executed on a thread where Dart code cannot run (and hence instrument). Besides, due to the pipelined nature of rendering in Flutter, there may be multiple frame workloads being processed at any given time. However, for non-Timeline based profiling, it is useful for trace collection and processing to happen in Dart. To do this, the raster task runner frame workloads need to be instrumented separately. After a set number of these profiles have been gathered, they need to be reported back to Dart code. The engine reports this extra instrumentation information back to Dart code running on the engine by invoking this method at predefined intervals. More... | |
virtual bool | NotifyIdle (fml::TimeDelta deadline) |
Notify the Dart VM that no frame workloads are expected on the UI task runner till the specified deadline. The VM uses this opportunity to perform garbage collection operations is a manner that interferes as little as possible with frame rendering. More... | |
virtual bool | NotifyDestroyed () |
Notify the Dart VM that the attached flutter view has been destroyed. This gives the Dart VM to perform some cleanup activities e.g: perform garbage collection to free up any unused memory. More... | |
virtual bool | IsRootIsolateRunning () |
Returns if the root isolate is running. The isolate must be transitioned to the running phase manually. The isolate can stop running if it terminates execution on its own. More... | |
virtual bool | DispatchPlatformMessage (std::unique_ptr< PlatformMessage > message) |
Dispatch the specified platform message to running root isolate. More... | |
bool | DispatchPointerDataPacket (const PointerDataPacket &packet) |
Dispatch the specified pointer data message to the running root isolate. More... | |
bool | DispatchSemanticsAction (int32_t node_id, SemanticsAction action, fml::MallocMapping args) |
Dispatch the semantics action to the specified accessibility node. More... | |
Dart_Port | GetMainPort () |
Gets the main port identifier of the root isolate. More... | |
std::string | GetIsolateName () |
Gets the debug name of the root isolate. But default, the debug name of the isolate is derived from its advisory script URI, advisory main entrypoint and its main port name. For example, "main.dart$main-1234" where the script URI is "main.dart", the entrypoint is "main" and the port name "1234". Once launched, the isolate may re-christen itself using a name it selects via setIsolateDebugName in window.dart . This name is purely advisory and only used by instrumentation and reporting purposes. More... | |
bool | HasLivePorts () |
Returns if the root isolate has any live receive ports. More... | |
tonic::DartErrorHandleType | GetLastError () |
Get the last error encountered by the microtask queue. More... | |
std::optional< std::string > | GetRootIsolateServiceID () const |
Get the service ID of the root isolate if the root isolate is running. More... | |
std::optional< uint32_t > | GetRootIsolateReturnCode () |
Get the return code specified by the root isolate (if one is present). More... | |
uint64_t | GetRootIsolateGroup () const |
Get an identifier that represents the Dart isolate group the root isolate is in. More... | |
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, the Dart future returned by the originating loadLibrary() call completes. More... | |
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 id has failed. More... | |
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 deferred library identified by the specified loading unit id should be downloaded and loaded into the Dart VM via LoadDartDeferredLibrary More... | |
std::shared_ptr< const fml::Mapping > | GetPersistentIsolateData () override |
The embedder can specify data that the isolate can request synchronously on launch. This accessor fetches that data. More... | |
const fml::WeakPtr< IOManager > & | GetIOManager () const |
virtual DartVM * | GetDartVM () const |
const fml::RefPtr< const DartSnapshot > & | GetIsolateSnapshot () const |
const PlatformData & | GetPlatformData () const |
const fml::RefPtr< SkiaUnrefQueue > & | GetSkiaUnrefQueue () const |
const fml::TaskRunnerAffineWeakPtr< SnapshotDelegate > & | GetSnapshotDelegate () const |
std::weak_ptr< const DartIsolate > | GetRootIsolate () const |
std::shared_ptr< PlatformIsolateManager > | GetPlatformIsolateManager () override |
void | ShutdownPlatformIsolates () |
Shuts down all registered platform isolates. Must be called from the platform thread. More... | |
virtual std::string | DefaultRouteName ()=0 |
The route or path that the embedder requested when the application was launched. More... | |
virtual void | ScheduleFrame ()=0 |
Requests that, at the next appropriate opportunity, a new frame be scheduled for rendering. More... | |
virtual void | EndWarmUpFrame ()=0 |
Called when a warm up frame has ended. More... | |
virtual void | Render (int64_t view_id, Scene *scene, double width, double height)=0 |
Updates the client's rendering on the GPU with the newly provided Scene. More... | |
virtual void | UpdateSemantics (SemanticsUpdate *update)=0 |
Receives an updated semantics tree from the Framework. More... | |
virtual void | HandlePlatformMessage (std::unique_ptr< PlatformMessage > message)=0 |
When the Flutter application has a message to send to the underlying platform, the message needs to be forwarded to the platform on the appropriate thread (via the platform task runner). The PlatformConfiguration delegates this task to the engine via this method. More... | |
virtual FontCollection & | GetFontCollection ()=0 |
Returns the current collection of fonts available on the platform. More... | |
virtual std::shared_ptr< AssetManager > | GetAssetManager ()=0 |
Returns the current collection of assets available on the platform. More... | |
virtual void | UpdateIsolateDescription (const std::string isolate_name, int64_t isolate_port)=0 |
Notifies this client of the name of the root isolate and its port when that isolate is launched, restarted (in the cold-restart scenario) or the application itself updates the name of the root isolate (via Window.setIsolateDebugName in window.dart ). The name of the isolate is meaningless to the engine but is used in instrumentation and tooling. Currently, this information is to update the service protocol list of available root isolates running in the VM and their names so that the appropriate isolate can be selected in the tools for debugging and instrumentation. More... | |
virtual void | SetNeedsReportTimings (bool value)=0 |
Notifies this client that the application has an opinion about whether its frame timings need to be reported backed to it. Due to the asynchronous nature of rendering in Flutter, it is not possible for the application to determine the total time it took to render a specific frame. While the layer-tree is constructed on the UI thread, it needs to be rendering on the raster thread. Dart code cannot execute on this thread. So any instrumentation about the frame times gathered on this thread needs to be aggregated and sent back to the UI thread for processing in Dart. More... | |
virtual std::shared_ptr< const fml::Mapping > | GetPersistentIsolateData ()=0 |
The embedder can specify data that the isolate can request synchronously on launch. This accessor fetches that data. More... | |
virtual std::unique_ptr< std::vector< std::string > > | ComputePlatformResolvedLocale (const std::vector< std::string > &supported_locale_data)=0 |
Directly invokes platform-specific APIs to compute the locale the platform would have natively resolved to. More... | |
virtual void | RequestDartDeferredLibrary (intptr_t loading_unit_id)=0 |
Invoked when the Dart VM requests that a deferred library be loaded. Notifies the engine that the deferred library identified by the specified loading unit id should be downloaded and loaded into the Dart VM via LoadDartDeferredLibrary More... | |
virtual void | SendChannelUpdate (std::string name, bool listening)=0 |
Invoked when a listener is registered on a platform channel. More... | |
virtual double | GetScaledFontSize (double unscaled_font_size, int configuration_id) const =0 |
Synchronously invokes platform-specific APIs to apply the system text scaling on the given unscaled font size. More... | |
virtual std::shared_ptr< PlatformIsolateManager > | GetPlatformIsolateManager ()=0 |
Protected Member Functions | |
RuntimeController (RuntimeDelegate &p_client, const TaskRunners &task_runners) | |
Constructor for Mocks. More... | |
Protected Member Functions inherited from flutter::PlatformConfigurationClient | |
virtual | ~PlatformConfigurationClient () |
Represents an instance of a running root isolate with window bindings. In normal operation, a single instance of this object is owned by the engine per shell. This object may only be created, used, and collected on the UI task runner. Window state queried by the root isolate is stored by this object. In cold-restart scenarios, the engine may collect this before installing a new runtime controller in its place. The Clone method may be used by the engine to copy the currently accumulated window state so it can be referenced by the new runtime controller.
When RuntimeController
is created, it takes some time before the root isolate becomes ready. Operation during this gap is stored by RuntimeController
and flushed to the Dart VM when the isolate becomes ready before the entrypoint function. See PlatformData
.
Definition at line 52 of file runtime_controller.h.
using flutter::RuntimeController::AddViewCallback = std::function<void(bool added)> |
A callback that's invoked after this RuntimeController
attempts to add a view to the Dart isolate.
If the Dart isolate is not launched yet, this callback will be stored and invoked after the isolate is launched.
The added
parameter is false if the add operation fails or was cancelled while pending using RemoveView
.
Definition at line 63 of file runtime_controller.h.
flutter::RuntimeController::RuntimeController | ( | RuntimeDelegate & | p_client, |
DartVM * | vm, | ||
fml::RefPtr< const DartSnapshot > | p_isolate_snapshot, | ||
const std::function< void(int64_t)> & | idle_notification_callback, | ||
const PlatformData & | platform_data, | ||
const fml::closure & | isolate_create_callback, | ||
const fml::closure & | isolate_shutdown_callback, | ||
std::shared_ptr< const fml::Mapping > | p_persistent_isolate_data, | ||
const UIDartState::Context & | context | ||
) |
Creates a new instance of a runtime controller. This is usually only done by the engine instance associated with the shell.
client | The runtime delegate. This is usually the Engine instance. | |
vm | A reference to a running Dart VM. The runtime controller must be collected before the VM is destroyed (this order is guaranteed by the shell). | |
[in] | idle_notification_callback | The idle notification callback. This allows callers to run native code in isolate scope when the VM is about to be notified that the engine is going to be idle. |
[in] | platform_data | The window data (if exists). |
[in] | isolate_create_callback | The isolate create callback. This allows callers to run native code in isolate scope on the UI task runner as soon as the root isolate has been created. |
[in] | isolate_shutdown_callback | The isolate shutdown callback. This allows callers to run native code in isolate scoped on the UI task runner just as the root isolate is about to be torn down. |
[in] | persistent_isolate_data | Unstructured persistent read-only data that the root isolate can access in a synchronous manner. |
[in] | context | Engine-owned state which is accessed by the root dart isolate. |
Definition at line 31 of file runtime_controller.cc.
|
override |
Definition at line 90 of file runtime_controller.cc.
|
protected |
Constructor for Mocks.
Definition at line 24 of file runtime_controller.cc.
void flutter::RuntimeController::AddView | ( | int64_t | view_id, |
const ViewportMetrics & | view_metrics, | ||
AddViewCallback | callback | ||
) |
Notify the isolate that a new view is available.
A view must be added before other methods can refer to it, including the implicit view. Adding a view that already exists is an error. The `callback` is invoked when the add operation is attempted, failed, or is cancelled. If the isolate is not running, the view add will be queued and flushed to the isolate when it starts. Calling `RemoveView` before the isolate is launched cancels the add operation. If the isolate is running, a frame will be scheduled.
[in] | view_id | The ID of the new view. |
[in] | viewport_metrics | The initial viewport metrics for the view. |
[in] | callback | Callback that will be invoked after the add operation is attempted or cancelled. |
Definition at line 161 of file runtime_controller.cc.
bool flutter::RuntimeController::BeginFrame | ( | fml::TimePoint | frame_time, |
uint64_t | frame_number | ||
) |
Notifies the running isolate that it should start generating a new frame.
Engine::BeginFrame
for more context.[in] | frame_time | The point at which the current frame interval began. May be used by animation interpolators, physics simulations, etc. |
Definition at line 289 of file runtime_controller.cc.
std::unique_ptr< RuntimeController > flutter::RuntimeController::Clone | ( | ) | const |
Clone the runtime controller. Launching an isolate with a cloned runtime controller will use the same snapshots and copies all window data to the new instance. This is usually only used in the debug runtime mode to support the cold-restart scenario.
Definition at line 111 of file runtime_controller.cc.
|
virtual |
Dispatch the specified platform message to running root isolate.
[in] | message | The message to dispatch to the isolate. |
Definition at line 354 of file runtime_controller.cc.
bool flutter::RuntimeController::DispatchPointerDataPacket | ( | const PointerDataPacket & | packet | ) |
Dispatch the specified pointer data message to the running root isolate.
[in] | packet | The pointer data message to dispatch to the isolate. |
Definition at line 365 of file runtime_controller.cc.
bool flutter::RuntimeController::DispatchSemanticsAction | ( | int32_t | node_id, |
SemanticsAction | action, | ||
fml::MallocMapping | args | ||
) |
Dispatch the semantics action to the specified accessibility node.
[in] | node_id | The identified of the accessibility node. |
[in] | action | The semantics action to perform on the specified accessibility node. |
[in] | args | Optional data that applies to the specified action. |
Definition at line 380 of file runtime_controller.cc.
|
inlinevirtual |
Definition at line 630 of file runtime_controller.h.
|
inline |
Definition at line 626 of file runtime_controller.h.
std::string flutter::RuntimeController::GetIsolateName | ( | ) |
Gets the debug name of the root isolate. But default, the debug name of the isolate is derived from its advisory script URI, advisory main entrypoint and its main port name. For example, "main.dart$main-1234" where the script URI is "main.dart", the entrypoint is "main" and the port name "1234". Once launched, the isolate may re-christen itself using a name it selects via setIsolateDebugName
in window.dart
. This name is purely advisory and only used by instrumentation and reporting purposes.
Definition at line 500 of file runtime_controller.cc.
|
inline |
Definition at line 632 of file runtime_controller.h.
tonic::DartErrorHandleType flutter::RuntimeController::GetLastError | ( | ) |
Get the last error encountered by the microtask queue.
Definition at line 514 of file runtime_controller.cc.
Dart_Port flutter::RuntimeController::GetMainPort | ( | ) |
Gets the main port identifier of the root isolate.
ILLEGAL_PORT
. Definition at line 495 of file runtime_controller.cc.
|
overridevirtual |
The embedder can specify data that the isolate can request synchronously on launch. This accessor fetches that data.
This data is persistent for the duration of the Flutter application and is available even after isolate restarts. Because of this lifecycle, the size of this data must be kept to a minimum.
For asynchronous communication between the embedder and isolate, a platform channel may be used.
Implements flutter::PlatformConfigurationClient.
Definition at line 479 of file runtime_controller.cc.
|
inline |
Definition at line 636 of file runtime_controller.h.
|
inlineoverridevirtual |
Implements flutter::PlatformConfigurationClient.
Definition at line 651 of file runtime_controller.h.
|
inline |
Definition at line 647 of file runtime_controller.h.
uint64_t flutter::RuntimeController::GetRootIsolateGroup | ( | ) | const |
Get an identifier that represents the Dart isolate group the root isolate is in.
Definition at line 595 of file runtime_controller.cc.
std::optional< uint32_t > flutter::RuntimeController::GetRootIsolateReturnCode | ( | ) |
Get the return code specified by the root isolate (if one is present).
Definition at line 591 of file runtime_controller.cc.
std::optional< std::string > flutter::RuntimeController::GetRootIsolateServiceID | ( | ) | const |
Get the service ID of the root isolate if the root isolate is running.
Definition at line 584 of file runtime_controller.cc.
|
inline |
Definition at line 638 of file runtime_controller.h.
|
inline |
Definition at line 642 of file runtime_controller.h.
bool flutter::RuntimeController::HasLivePorts | ( | ) |
Returns if the root isolate has any live receive ports.
Definition at line 505 of file runtime_controller.cc.
|
virtual |
Returns if the root isolate is running. The isolate must be transitioned to the running phase manually. The isolate can stop running if it terminates execution on its own.
Definition at line 103 of file runtime_controller.cc.
bool flutter::RuntimeController::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 | ||
) |
Launches the isolate using the window data associated with this runtime controller. Before this call, the Dart isolate has not been initialized. On successful return, the caller can assume that the isolate is in the DartIsolate::Phase::Running
phase.
This call will fail if a root isolate is already running. To re-create an isolate with the window data associated with this runtime controller, Clone
this runtime controller and Launch an isolate in that runtime controller instead.
[in] | settings | The per engine instance settings. |
[in] | root_isolate_create_callback | A callback invoked before the root isolate has launched the Dart program, but after it has been created. This is called without isolate scope, and after any root isolate callback in the settings. |
[in] | dart_entrypoint | The dart entrypoint. If std::nullopt or empty, main will be attempted. |
[in] | dart_entrypoint_library | The dart entrypoint library. If std::nullopt or empty, the core library will be attempted. |
[in] | dart_entrypoint_args | Arguments passed as a List<String> to Dart's entrypoint function. |
[in] | isolate_configuration | The isolate configuration |
DartIsolate::Phase::Running
phase. Definition at line 519 of file runtime_controller.cc.
void flutter::RuntimeController::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, the Dart future returned by the originating loadLibrary() call completes.
The Dart compiler may generate separate shared libraries files called 'loading units' when libraries are imported as deferred. Each of these shared libraries are identified by a unique loading unit id. Callers should open and resolve a SymbolMapping from the shared library. The Mappings should be moved into this method, as ownership will be assumed by the dart root isolate after successful loading and released after shutdown of the root isolate. The loading unit may not be used after isolate shutdown. If loading fails, the mappings will be released.
This method is paired with a RequestDartDeferredLibrary invocation that provides the embedder with the loading unit id of the deferred library to load.
[in] | loading_unit_id | The unique id of the deferred library's loading unit, as passed in by RequestDartDeferredLibrary. |
[in] | snapshot_data | Dart snapshot data of the loading unit's shared library. |
[in] | snapshot_data | Dart snapshot instructions of the loading unit's shared library. |
Definition at line 606 of file runtime_controller.cc.
|
virtual |
Indicates to the dart VM that the request to load a deferred library with the specified loading unit id has failed.
The dart future returned by the initiating loadLibrary() call will complete with an error.
[in] | loading_unit_id | The unique id of the deferred library's loading unit, as passed in by RequestDartDeferredLibrary. |
[in] | error_message | The error message that will appear in the dart Future. |
[in] | transient | A transient error is a failure due to temporary conditions such as no network. Transient errors allow the dart VM to re-request the same deferred library and loading_unit_id again. Non-transient errors are permanent and attempts to re-request the library will instantly complete with an error. |
Definition at line 615 of file runtime_controller.cc.
|
virtual |
Notify the Dart VM that the attached flutter view has been destroyed. This gives the Dart VM to perform some cleanup activities e.g: perform garbage collection to free up any unused memory.
NotifyDestroyed is advisory. The VM may or may not perform any clean up activities.
Definition at line 341 of file runtime_controller.cc.
|
virtual |
Notify the Dart VM that no frame workloads are expected on the UI task runner till the specified deadline. The VM uses this opportunity to perform garbage collection operations is a manner that interferes as little as possible with frame rendering.
NotifyIdle is advisory. The VM may or may not run a garbage collection when this is called, and will eventually perform garbage collections even if it is not called or it is called with insufficient deadlines.
The garbage collection mechanism and its thresholds are internal implementation details and absolutely no guarantees are made about the threshold discussed below. This discussion is also an oversimplification but hopefully serves to calibrate expectations about GC behavior:
Dart_TimelineGetMicros
deadline
argument must be converted to std::chrono
instead of a raw integer.[in] | deadline | The deadline is used by the VM to determine if the corresponding sweep can be performed within the deadline. |
Definition at line 309 of file runtime_controller.cc.
bool flutter::RuntimeController::RemoveView | ( | int64_t | view_id | ) |
Notify the isolate that a view is no longer available.
Views that are added before the isolate is started are queued until the isolate is launched. If one of these "pending" views are removed, the view add is cancelled: the `AddViewCallback` will be invoked with an `added` of false and `RemoveView` will return false. The implicit view (kFlutterImplicitViewId) should never be removed. Doing so triggers an assertion.
[in] | view_id | The ID of the view. |
Definition at line 193 of file runtime_controller.cc.
bool flutter::RuntimeController::ReportTimings | ( | std::vector< int64_t > | timings | ) |
Dart code cannot fully measure the time it takes for a specific frame to be rendered. This is because Dart code only runs on the UI task runner. That is only a small part of the overall frame workload. The raster task runner frame workload is executed on a thread where Dart code cannot run (and hence instrument). Besides, due to the pipelined nature of rendering in Flutter, there may be multiple frame workloads being processed at any given time. However, for non-Timeline based profiling, it is useful for trace collection and processing to happen in Dart. To do this, the raster task runner frame workloads need to be instrumented separately. After a set number of these profiles have been gathered, they need to be reported back to Dart code. The engine reports this extra instrumentation information back to Dart code running on the engine by invoking this method at predefined intervals.
Engine::ReportTimings
, FrameTiming
[in] | timings | Collection of FrameTiming::kCount * n timestamps for n frames whose timings have not been reported yet. A collection of integers is reported here for easier conversions to Dart objects. The timestamps are measured against the system monotonic clock measured in microseconds. |
Definition at line 300 of file runtime_controller.cc.
|
overridevirtual |
Invoked when the Dart VM requests that a deferred library be loaded. Notifies the engine that the deferred library identified by the specified loading unit id should be downloaded and loaded into the Dart VM via LoadDartDeferredLibrary
Upon encountering errors or otherwise failing to load a loading unit with the specified id, the failure should be directly reported to dart by calling LoadDartDeferredLibraryFailure
to ensure the waiting dart future completes with an error.
[in] | loading_unit_id | The unique id of the deferred library's loading unit. This id is to be passed back into LoadDartDeferredLibrary in order to identify which deferred library to load. |
Implements flutter::PlatformConfigurationClient.
Definition at line 624 of file runtime_controller.cc.
bool flutter::RuntimeController::SetAccessibilityFeatures | ( | int32_t | flags | ) |
Forward the preference of accessibility features that must be enabled in the semantics tree to the running isolate. If the isolate is not running, this data will be saved and flushed to the isolate when it starts running.
[in] | flags | The accessibility features that must be generated in the semantics tree. |
Definition at line 278 of file runtime_controller.cc.
bool flutter::RuntimeController::SetDisplays | ( | const std::vector< DisplayData > & | displays | ) |
Forward the specified display metrics to the running isolate. If the isolate is not running, these metrics will be saved and flushed to the isolate when it starts.
[in] | displays | The available displays. |
Definition at line 628 of file runtime_controller.cc.
bool flutter::RuntimeController::SetInitialLifecycleState | ( | const std::string & | data | ) |
Forward the initial lifecycle state data to the running isolate. If the isolate is not running, this data will be saved and flushed to the isolate when it starts running. After the isolate starts running, the current lifecycle state is pushed to it via the "flutter/lifecycle" channel.
[in] | data | The lifecycle state data. |
Definition at line 254 of file runtime_controller.cc.
bool flutter::RuntimeController::SetLocales | ( | const std::vector< std::string > & | locale_data | ) |
Forward the specified locale data to the running isolate. If the isolate is not running, this data will be saved and flushed to the isolate when it starts running.
[in] | locale_data | The locale data. This should consist of groups of 4 strings, each group representing a single locale. |
Definition at line 230 of file runtime_controller.cc.
bool flutter::RuntimeController::SetSemanticsEnabled | ( | bool | enabled | ) |
Notifies the running isolate about whether the semantics tree should be generated or not. If the isolate is not running, this preference will be saved and flushed to the isolate when it starts running.
[in] | enabled | Indicates whether to generate the semantics tree. |
Definition at line 266 of file runtime_controller.cc.
bool flutter::RuntimeController::SetUserSettingsData | ( | const std::string & | data | ) |
Forward the user settings data to the running isolate. If the isolate is not running, this data will be saved and flushed to the isolate when it starts running.
[in] | data | The user settings data. |
Definition at line 242 of file runtime_controller.cc.
bool flutter::RuntimeController::SetViewportMetrics | ( | int64_t | view_id, |
const ViewportMetrics & | metrics | ||
) |
Forward the specified viewport metrics to the running isolate. If the isolate is not running, these metrics will be saved and flushed to the isolate when it starts.
[in] | view_id | The ID for the view that metrics describes. |
[in] | metrics | The window's viewport metrics. |
Definition at line 218 of file runtime_controller.cc.
void flutter::RuntimeController::ShutdownPlatformIsolates | ( | ) |
Shuts down all registered platform isolates. Must be called from the platform thread.
Definition at line 644 of file runtime_controller.cc.
std::unique_ptr< RuntimeController > flutter::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::WeakPtr< ImageDecoder > | image_decoder, | ||
fml::WeakPtr< ImageGeneratorRegistry > | image_generator_registry, | ||
fml::TaskRunnerAffineWeakPtr< SnapshotDelegate > | snapshot_delegate | ||
) | const |
Create a RuntimeController that shares as many resources as possible with the calling RuntimeController such that together they occupy less memory.
Definition at line 52 of file runtime_controller.cc.