-
Notifications
You must be signed in to change notification settings - Fork 6k
Add a Dart FFI method to synchronously render a frame #50492
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -801,11 +801,41 @@ class PlatformDispatcher { | |
| /// | ||
| /// * [SchedulerBinding], the Flutter framework class which manages the | ||
| /// scheduling of frames. | ||
| /// * [imposeSyncFrame], a similar method that is used in rare cases that | ||
| /// a frame must be rendered immediately. | ||
| void scheduleFrame() => _scheduleFrame(); | ||
|
|
||
| @Native<Void Function()>(symbol: 'PlatformConfigurationNativeApi::ScheduleFrame') | ||
| external static void _scheduleFrame(); | ||
|
|
||
| /// Immediately render a frame by invoking the [onBeginFrame] and | ||
| /// [onDrawFrame] callbacks synchronously. | ||
| /// | ||
| /// This method performs the same computation for a frame as [scheduleFrame] | ||
| /// does, but instead of doing so at an appropriate opportunity, the render is | ||
| /// completed synchronously within this call. | ||
| /// | ||
| /// This method should not be used in usual cases. It is designed for | ||
| /// situations that require a frame is rendered as soon as possible, even at | ||
| /// the cost of rendering quality. | ||
| /// | ||
| /// See also: | ||
| /// | ||
| /// * [SchedulerBinding], the Flutter framework class which manages the | ||
| /// scheduling of frames. | ||
| /// * [scheduleFrame]. | ||
| /// | ||
| // TODO(dkwingsmt): This method is not used for now, and is not implemented by | ||
| // the engine yet. This is because we have to land the Dart FFI method first | ||
| // before being able to run the performance test for the full changes due to | ||
| // the restriction of the performance test. Eventually, we should either land | ||
| // the full changes, or remove this method. | ||
| // https://github.com/flutter/flutter/issues/142851 | ||
| void imposeSyncFrame() => _imposeSyncFrame(); | ||
|
||
|
|
||
| @Native<Void Function()>(symbol: 'PlatformConfigurationNativeApi::ImposeSyncFrame') | ||
| external static void _imposeSyncFrame(); | ||
|
|
||
| /// Additional accessibility features that may be enabled by the platform. | ||
| AccessibilityFeatures get accessibilityFeatures => _configuration.accessibilityFeatures; | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -589,6 +589,16 @@ void PlatformConfigurationNativeApi::ScheduleFrame() { | |
| UIDartState::Current()->platform_configuration()->client()->ScheduleFrame(); | ||
| } | ||
|
|
||
| void PlatformConfigurationNativeApi::ImposeSyncFrame() { | ||
| // TODO(dkwingsmt): This method is not implemented and is not used for now. | ||
| // This is because we have to land the Dart FFI method first before being able | ||
| // to run the performance test for the full changes due to the restriction of | ||
| // the performance test. Eventually, we should either land the full changes, | ||
| // or remove this method. | ||
| // https://github.com/flutter/flutter/issues/142851 | ||
| FML_UNREACHABLE(); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is in fact quite reachable. You could error log if you want to discourage calling this method but leaving a process exit accessible from dart:ui does not seem reasonable.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This PR has been merged to #49950 because I realized that this PR does not improve the situation alone. Now this method is implemented. |
||
| } | ||
|
|
||
| void PlatformConfigurationNativeApi::UpdateSemantics(SemanticsUpdate* update) { | ||
| UIDartState::ThrowIfUIOperationsProhibited(); | ||
| UIDartState::Current()->platform_configuration()->client()->UpdateSemantics( | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you give the warmup frame as an explicit example here? Some of the verbiage from https://main-api.flutter.dev/flutter/scheduler/SchedulerBinding/scheduleWarmUpFrame.html would fit here as well to motivate that use case.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done, can you take a look?