Flutter Engine
 
Loading...
Searching...
No Matches
flutter::Engine::Delegate Class Referenceabstract

While the engine operates entirely on the UI task runner, it needs the capabilities of the other components to fulfill the requirements of the root isolate. The shell is the only class that implements this interface as no other component has access to all components in a thread safe manner. The engine delegates these tasks to the shell via this interface. More...

#include <engine.h>

Inheritance diagram for flutter::Engine::Delegate:
flutter::Shell

Public Member Functions

virtual void OnEngineUpdateSemantics (int64_t view_id, SemanticsNodeUpdates updates, CustomAccessibilityActionUpdates actions)=0
 When the accessibility tree has been updated by the Flutter application, this new information needs to be conveyed to the underlying platform. The engine delegates this task to the shell via this call. The engine cannot access the underlying platform directly because of threading considerations. Most platform specific APIs to convey accessibility information are only safe to access on the platform task runner while the engine is running on the UI task runner.
 
virtual void OnEngineSetApplicationLocale (std::string locale)=0
 Framework sets the application locale.
 
virtual void OnEngineSetSemanticsTreeEnabled (bool enabled)=0
 When the Framework starts or stops generating semantics tree, this new information needs to be conveyed to the underlying platform so that they can prepare to accept semantics update. The engine delegates this task to the shell via this call.
 
virtual void OnEngineHandlePlatformMessage (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 engine delegates this task to the shell via this method.
 
virtual void OnPreEngineRestart ()=0
 Notifies the delegate that the root isolate of the application is about to be discarded and a new isolate with the same runtime started in its place. This should only happen in the Flutter "debug" runtime mode in the cold-restart scenario. The embedder may need to reset native resource in response to the restart.
 
virtual void OnRootIsolateCreated ()=0
 Notifies the shell that the root isolate is created. Currently, this information is to add to 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.
 
virtual void UpdateIsolateDescription (const std::string isolate_name, int64_t isolate_port)=0
 Notifies the shell 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 PlatformDispatcher.setIsolateDebugName in platform_dispatcher.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.
 
virtual void SetNeedsReportTimings (bool needs_reporting)=0
 Notifies the shell 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.
 
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.
 
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
 
virtual fml::TimePoint GetCurrentTimePoint ()=0
 Returns the current fml::TimePoint. This method is primarily provided to allow tests to control Any methods that rely on advancing the clock.
 
virtual const std::shared_ptr< PlatformMessageHandler > & GetPlatformMessageHandler () const =0
 Returns the delegate object that handles PlatformMessage's from Flutter to the host platform (and its responses).
 
virtual void OnEngineChannelUpdate (std::string name, bool listening)=0
 Invoked when a listener is registered on a platform channel.
 
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.
 
virtual void RequestViewFocusChange (const ViewFocusChangeRequest &request)=0
 Notifies the client that the Flutter view focus state has changed and the platform view should be updated.
 

Detailed Description

While the engine operates entirely on the UI task runner, it needs the capabilities of the other components to fulfill the requirements of the root isolate. The shell is the only class that implements this interface as no other component has access to all components in a thread safe manner. The engine delegates these tasks to the shell via this interface.

Definition at line 136 of file engine.h.

Member Function Documentation

◆ ComputePlatformResolvedLocale()

virtual std::unique_ptr< std::vector< std::string > > flutter::Engine::Delegate::ComputePlatformResolvedLocale ( const std::vector< std::string > &  supported_locale_data)
pure virtual

Directly invokes platform-specific APIs to compute the locale the platform would have natively resolved to.

Parameters
[in]supported_locale_dataThe vector of strings that represents the locales supported by the app. Each locale consists of three strings: languageCode, countryCode, and scriptCode in that order.
Returns
A vector of 3 strings languageCode, countryCode, and scriptCode that represents the locale selected by the platform. Empty strings mean the value was unassigned. Empty vector represents a null locale.

◆ GetCurrentTimePoint()

virtual fml::TimePoint flutter::Engine::Delegate::GetCurrentTimePoint ( )
pure virtual

Returns the current fml::TimePoint. This method is primarily provided to allow tests to control Any methods that rely on advancing the clock.

◆ GetPlatformMessageHandler()

virtual const std::shared_ptr< PlatformMessageHandler > & flutter::Engine::Delegate::GetPlatformMessageHandler ( ) const
pure virtual

Returns the delegate object that handles PlatformMessage's from Flutter to the host platform (and its responses).

Implemented in flutter::Shell.

◆ GetScaledFontSize()

virtual double flutter::Engine::Delegate::GetScaledFontSize ( double  unscaled_font_size,
int  configuration_id 
) const
pure virtual

Synchronously invokes platform-specific APIs to apply the system text scaling on the given unscaled font size.

Platforms that support this feature (currently it's only implemented for Android SDK level 34+) will send a valid configuration_id to potential callers, before this method can be called.

Parameters
[in]unscaled_font_sizeThe unscaled font size specified by the app developer. The value is in logical pixels, and is guaranteed to be finite and non-negative.
[in]configuration_idThe unique id of the configuration to use for computing the scaled font size.
Returns
The scaled font size in logical pixels, or -1 when the given configuration_id did not match a valid configuration.

◆ OnEngineChannelUpdate()

virtual void flutter::Engine::Delegate::OnEngineChannelUpdate ( std::string  name,
bool  listening 
)
pure virtual

Invoked when a listener is registered on a platform channel.

Parameters
[in]nameThe name of the platform channel to which a listener has been registered or cleared.
[in]listeningWhether the listener has been set (true) or cleared (false).

◆ OnEngineHandlePlatformMessage()

virtual void flutter::Engine::Delegate::OnEngineHandlePlatformMessage ( std::unique_ptr< PlatformMessage message)
pure virtual

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 engine delegates this task to the shell via this method.

See also
PlatformView::HandlePlatformMessage
Parameters
[in]messageThe message from the Flutter application to send to the underlying platform.

◆ OnEngineSetApplicationLocale()

virtual void flutter::Engine::Delegate::OnEngineSetApplicationLocale ( std::string  locale)
pure virtual

Framework sets the application locale.

Parameters
[in]localeThe application locale in BCP 47 format.

◆ OnEngineSetSemanticsTreeEnabled()

virtual void flutter::Engine::Delegate::OnEngineSetSemanticsTreeEnabled ( bool  enabled)
pure virtual

When the Framework starts or stops generating semantics tree, this new information needs to be conveyed to the underlying platform so that they can prepare to accept semantics update. The engine delegates this task to the shell via this call.

See also
OnEngineUpdateSemantics
Parameters
[in]enabledwhether Framework starts generating semantics tree.

◆ OnEngineUpdateSemantics()

virtual void flutter::Engine::Delegate::OnEngineUpdateSemantics ( int64_t  view_id,
SemanticsNodeUpdates  updates,
CustomAccessibilityActionUpdates  actions 
)
pure virtual

When the accessibility tree has been updated by the Flutter application, this new information needs to be conveyed to the underlying platform. The engine delegates this task to the shell via this call. The engine cannot access the underlying platform directly because of threading considerations. Most platform specific APIs to convey accessibility information are only safe to access on the platform task runner while the engine is running on the UI task runner.

See also
SemanticsNode, SemanticsNodeUpdates, CustomAccessibilityActionUpdates, PlatformView::UpdateSemantics
Parameters
[in]view_idThe ID of the view that this update is for
[in]updatesA map with the stable semantics node identifier as key and the node properties as the value.
[in]actionsA map with the stable semantics node identifier as key and the custom node action as the value.

◆ OnPreEngineRestart()

virtual void flutter::Engine::Delegate::OnPreEngineRestart ( )
pure virtual

Notifies the delegate that the root isolate of the application is about to be discarded and a new isolate with the same runtime started in its place. This should only happen in the Flutter "debug" runtime mode in the cold-restart scenario. The embedder may need to reset native resource in response to the restart.

See also
PlatformView::OnPreEngineRestart

Referenced by flutter::Engine::Restart().

◆ OnRootIsolateCreated()

virtual void flutter::Engine::Delegate::OnRootIsolateCreated ( )
pure virtual

Notifies the shell that the root isolate is created. Currently, this information is to add to 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.

◆ RequestDartDeferredLibrary()

virtual void flutter::Engine::Delegate::RequestDartDeferredLibrary ( intptr_t  loading_unit_id)
pure virtual

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.

Parameters
[in]loading_unit_idThe 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.

◆ RequestViewFocusChange()

virtual void flutter::Engine::Delegate::RequestViewFocusChange ( const ViewFocusChangeRequest request)
pure virtual

Notifies the client that the Flutter view focus state has changed and the platform view should be updated.

Parameters
[in]requestThe request to change the focus state of the view.

◆ SetNeedsReportTimings()

virtual void flutter::Engine::Delegate::SetNeedsReportTimings ( bool  needs_reporting)
pure virtual

Notifies the shell 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.

When the application indicates that frame times need to be reported, it collects this information till a specified number of data points are gathered. Then this information is sent back to Dart code via Engine::ReportTimings.

This option is engine counterpart of the Window._setNeedsReportTimings in window.dart.

Parameters
[in]needs_reportingIf reporting information should be collected and send back to Dart.

◆ UpdateIsolateDescription()

virtual void flutter::Engine::Delegate::UpdateIsolateDescription ( const std::string  isolate_name,
int64_t  isolate_port 
)
pure virtual

Notifies the shell 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 PlatformDispatcher.setIsolateDebugName in platform_dispatcher.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.

Parameters
[in]isolate_nameThe isolate name
[in]isolate_portThe isolate port

The documentation for this class was generated from the following file: