diff --git a/lib/ui/dart_ui.cc b/lib/ui/dart_ui.cc index a1ba414316245..205df18059879 100644 --- a/lib/ui/dart_ui.cc +++ b/lib/ui/dart_ui.cc @@ -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) \ diff --git a/lib/ui/platform_dispatcher.dart b/lib/ui/platform_dispatcher.dart index 250ea04d6aa74..9b27f822614c6 100644 --- a/lib/ui/platform_dispatcher.dart +++ b/lib/ui/platform_dispatcher.dart @@ -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(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(symbol: 'PlatformConfigurationNativeApi::ForceSyncFrame') + external static void _forceSyncFrame(); + /// Additional accessibility features that may be enabled by the platform. AccessibilityFeatures get accessibilityFeatures => _configuration.accessibilityFeatures; diff --git a/lib/ui/window/platform_configuration.cc b/lib/ui/window/platform_configuration.cc index 3ecadac12fe6f..8c3253f54cb3b 100644 --- a/lib/ui/window/platform_configuration.cc +++ b/lib/ui/window/platform_configuration.cc @@ -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(); +} + void PlatformConfigurationNativeApi::UpdateSemantics(SemanticsUpdate* update) { UIDartState::ThrowIfUIOperationsProhibited(); UIDartState::Current()->platform_configuration()->client()->UpdateSemantics( diff --git a/lib/ui/window/platform_configuration.h b/lib/ui/window/platform_configuration.h index 5f21051110472..d10b38e0032cb 100644 --- a/lib/ui/window/platform_configuration.h +++ b/lib/ui/window/platform_configuration.h @@ -557,6 +557,8 @@ class PlatformConfigurationNativeApi { static void ScheduleFrame(); + static void ForceSyncFrame(); + static void Render(int64_t view_id, Scene* scene, double width,