Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions lib/ui/dart_ui.cc
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ typedef CanvasPath Path;
V(NativeStringAttribute::initSpellOutStringAttribute) \
V(PlatformConfigurationNativeApi::DefaultRouteName) \
V(PlatformConfigurationNativeApi::ScheduleFrame) \
V(PlatformConfigurationNativeApi::ForceSyncFrame) \
V(PlatformConfigurationNativeApi::Render) \
V(PlatformConfigurationNativeApi::UpdateSemantics) \
V(PlatformConfigurationNativeApi::SetNeedsReportTimings) \
Expand Down
32 changes: 32 additions & 0 deletions lib/ui/platform_dispatcher.dart
Original file line number Diff line number Diff line change
Expand Up @@ -801,11 +801,43 @@ class PlatformDispatcher {
///
/// * [SchedulerBinding], the Flutter framework class which manages the
/// scheduling of frames.
/// * [forceSyncFrame], 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.
///
/// Prefer [scheduleFrame] to update the display in normal operation. The
/// [forceSyncFrame] method is designed for situations that require a frame is
/// rendered as soon as possible, even at the cost of rendering quality. An
/// example of using this method is [SchedulerBinding.scheduleWarmUpFrame],
/// which is called during application startup so that the first frame can be
/// presented to the screen a few extra milliseconds earlier.
///
/// See also:
///
/// * [SchedulerBinding.scheduleWarmUpFrame], which uses this method.
/// * [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 forceSyncFrame() => _forceSyncFrame();

@Native<Void Function()>(symbol: 'PlatformConfigurationNativeApi::ForceSyncFrame')
external static void _forceSyncFrame();

/// Additional accessibility features that may be enabled by the platform.
AccessibilityFeatures get accessibilityFeatures => _configuration.accessibilityFeatures;

Expand Down
10 changes: 10 additions & 0 deletions lib/ui/window/platform_configuration.cc
Original file line number Diff line number Diff line change
Expand Up @@ -589,6 +589,16 @@ void PlatformConfigurationNativeApi::ScheduleFrame() {
UIDartState::Current()->platform_configuration()->client()->ScheduleFrame();
}

void PlatformConfigurationNativeApi::ForceSyncFrame() {
// 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();
Copy link
Contributor

Choose a reason for hiding this comment

The 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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The 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(
Expand Down
2 changes: 2 additions & 0 deletions lib/ui/window/platform_configuration.h
Original file line number Diff line number Diff line change
Expand Up @@ -557,6 +557,8 @@ class PlatformConfigurationNativeApi {

static void ScheduleFrame();

static void ForceSyncFrame();

static void Render(int64_t view_id,
Scene* scene,
double width,
Expand Down