Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
1950e72
Impl engine
dkwingsmt Feb 12, 2024
f55dfdf
Web
dkwingsmt Feb 12, 2024
7f76c5f
Rename to RequestWarmUpFrame and add web time
dkwingsmt Feb 13, 2024
31a5ea3
Change to scheduleWarmUpFrame and EndWarmUpFrame
dkwingsmt Feb 13, 2024
590287d
Comment
dkwingsmt Feb 13, 2024
40b269b
Doc
dkwingsmt Feb 13, 2024
2d70a0f
Simplify web implementation
dkwingsmt Feb 14, 2024
4af9f06
Fix comment
dkwingsmt Feb 14, 2024
bfe5570
More doc
dkwingsmt Feb 14, 2024
21439c4
Fix doc
dkwingsmt Feb 14, 2024
1bd21db
More doc
dkwingsmt Feb 14, 2024
4f41658
Fix linter
dkwingsmt Feb 14, 2024
eeac064
Fix comment
dkwingsmt Feb 14, 2024
9c5bce4
Add test
dkwingsmt Feb 15, 2024
cdcf71a
Fix test
dkwingsmt Feb 15, 2024
7ab7d8e
Better test
dkwingsmt Feb 15, 2024
afbcfae
Merge remote-tracking branch 'origin/main' into force-sync-frame
dkwingsmt Feb 15, 2024
7381087
Simplify test and add platformdispatcher test
dkwingsmt Feb 15, 2024
05d3d2d
Better structure
dkwingsmt Feb 15, 2024
06957bb
Better name
dkwingsmt Feb 15, 2024
68953c0
Merge branch 'main' into force-sync-frame
dkwingsmt Feb 15, 2024
a9b7511
Merge branch 'main' into force-sync-frame
dkwingsmt Feb 20, 2024
7789d11
Original changes
dkwingsmt Feb 20, 2024
06b4a50
Merge branch 'force-sync-frame' into reland-3-mv-pipeline-base
dkwingsmt Feb 20, 2024
3464c05
Additional changes
dkwingsmt Feb 20, 2024
fe14311
Comments
dkwingsmt Feb 20, 2024
5b0719b
Merge branch 'main' into reland-3-mv-pipeline
dkwingsmt Feb 20, 2024
8731e47
Add web platform dispatcher test
dkwingsmt Feb 20, 2024
cdeffd9
Merge branch 'main' into force-sync-frame
dkwingsmt Feb 20, 2024
4c91a9e
Merge branch 'force-sync-frame' into reland-3-mv-pipeline
dkwingsmt Feb 20, 2024
34998fa
Fix lint
dkwingsmt Feb 20, 2024
658d5d1
Merge branch 'main' into reland-3-mv-pipeline
dkwingsmt Feb 21, 2024
946ffb5
Merge remote-tracking branch 'origin/main' into reland-3-mv-pipeline
dkwingsmt Feb 23, 2024
f9d5ad3
Merge remote-tracking branch 'dkwingsmt/reland-3-mv-pipeline' into re…
dkwingsmt Feb 23, 2024
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
Next Next commit
Impl engine
  • Loading branch information
dkwingsmt committed Feb 12, 2024
commit 1950e72cd034ce8b6ddb7821f5d2d2bb4a4d4f64
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
25 changes: 25 additions & 0 deletions lib/ui/platform_dispatcher.dart
Original file line number Diff line number Diff line change
Expand Up @@ -801,11 +801,36 @@ 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].
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
5 changes: 5 additions & 0 deletions lib/ui/window/platform_configuration.cc
Original file line number Diff line number Diff line change
Expand Up @@ -589,6 +589,11 @@ void PlatformConfigurationNativeApi::ScheduleFrame() {
UIDartState::Current()->platform_configuration()->client()->ScheduleFrame();
}

void PlatformConfigurationNativeApi::ForceSyncFrame() {
UIDartState::ThrowIfUIOperationsProhibited();
UIDartState::Current()->platform_configuration()->client()->ForceSyncFrame();
}

void PlatformConfigurationNativeApi::UpdateSemantics(SemanticsUpdate* update) {
UIDartState::ThrowIfUIOperationsProhibited();
UIDartState::Current()->platform_configuration()->client()->UpdateSemantics(
Expand Down
7 changes: 7 additions & 0 deletions lib/ui/window/platform_configuration.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,11 @@ class PlatformConfigurationClient {
///
virtual void ScheduleFrame() = 0;

//--------------------------------------------------------------------------
/// @brief
///
virtual void ForceSyncFrame() = 0;

//--------------------------------------------------------------------------
/// @brief Updates the client's rendering on the GPU with the newly
/// provided Scene.
Expand Down Expand Up @@ -557,6 +562,8 @@ class PlatformConfigurationNativeApi {

static void ScheduleFrame();

static void ForceSyncFrame();

static void Render(int64_t view_id,
Scene* scene,
double width,
Expand Down
2 changes: 2 additions & 0 deletions lib/web_ui/lib/platform_dispatcher.dart
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,8 @@ abstract class PlatformDispatcher {

void scheduleFrame();

void forceSyncFrame();

Future<void> render(Scene scene, [FlutterView view]);

AccessibilityFeatures get accessibilityFeatures;
Expand Down
6 changes: 6 additions & 0 deletions lib/web_ui/lib/src/engine/platform_dispatcher.dart
Original file line number Diff line number Diff line change
Expand Up @@ -771,6 +771,12 @@ class EnginePlatformDispatcher extends ui.PlatformDispatcher {
scheduleFrameCallback!();
}

@override
void forceSyncFrame() {
// TODO(dkwingsmt): Call beginFrame and drawFrame, since the framework
// will no longer call them once it switches to forceSyncFrame.
}

/// Updates the application's rendering on the GPU with the newly provided
/// [Scene]. This function must be called within the scope of the
/// [onBeginFrame] or [onDrawFrame] callbacks being invoked. If this function
Expand Down
5 changes: 5 additions & 0 deletions runtime/runtime_controller.cc
Original file line number Diff line number Diff line change
Expand Up @@ -340,6 +340,11 @@ void RuntimeController::ScheduleFrame() {
client_.ScheduleFrame();
}

// |PlatformConfigurationClient|
void RuntimeController::ForceSyncFrame() {
client_.ForceSyncFrame();
}

// |PlatformConfigurationClient|
void RuntimeController::Render(Scene* scene, double width, double height) {
// TODO(dkwingsmt): Currently only supports a single window.
Expand Down
3 changes: 3 additions & 0 deletions runtime/runtime_controller.h
Original file line number Diff line number Diff line change
Expand Up @@ -657,6 +657,9 @@ class RuntimeController : public PlatformConfigurationClient {
// |PlatformConfigurationClient|
void ScheduleFrame() override;

// |PlatformConfigurationClient|
void ForceSyncFrame() override;

// |PlatformConfigurationClient|
void Render(Scene* scene, double width, double height) override;

Expand Down
2 changes: 2 additions & 0 deletions runtime/runtime_delegate.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ class RuntimeDelegate {

virtual void ScheduleFrame(bool regenerate_layer_trees = true) = 0;

virtual void ForceSyncFrame() = 0;

virtual void Render(std::unique_ptr<flutter::LayerTree> layer_tree,
float device_pixel_ratio) = 0;

Expand Down
14 changes: 14 additions & 0 deletions shell/common/animator.cc
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,20 @@ void Animator::AwaitVSync() {
}
}

void Animator::ForceSyncFrame() {
TRACE_EVENT_ASYNC_BEGIN0("flutter", "Forced Frame Request Pending",
frame_request_number_);
regenerate_layer_trees_ = true;

const fml::TimePoint frame_start_time = fml::TimePoint::Now();
const fml::TimePoint frame_target_time = frame_start_time;

std::unique_ptr<FrameTimingsRecorder> frame_timings_recorder =
std::make_unique<FrameTimingsRecorder>();
frame_timings_recorder->RecordVsync(frame_start_time, frame_target_time);
BeginFrame(std::move(frame_timings_recorder));
}

void Animator::ScheduleSecondaryVsyncCallback(uintptr_t id,
const fml::closure& callback) {
waiter_->ScheduleSecondaryCallback(id, callback);
Expand Down
2 changes: 2 additions & 0 deletions shell/common/animator.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ class Animator final {

void RequestFrame(bool regenerate_layer_trees = true);

void ForceSyncFrame();

//--------------------------------------------------------------------------
/// @brief Tells the Animator that this frame needs to render another view.
///
Expand Down
4 changes: 4 additions & 0 deletions shell/common/engine.cc
Original file line number Diff line number Diff line change
Expand Up @@ -462,6 +462,10 @@ void Engine::ScheduleFrame(bool regenerate_layer_trees) {
animator_->RequestFrame(regenerate_layer_trees);
}

void Engine::ForceSyncFrame() {
animator_->ForceSyncFrame();
}

void Engine::Render(std::unique_ptr<flutter::LayerTree> layer_tree,
float device_pixel_ratio) {
if (!layer_tree) {
Expand Down
3 changes: 3 additions & 0 deletions shell/common/engine.h
Original file line number Diff line number Diff line change
Expand Up @@ -837,6 +837,9 @@ class Engine final : public RuntimeDelegate, PointerDataDispatcher::Delegate {
/// tree.
void ScheduleFrame() { ScheduleFrame(true); }

// |RuntimeDelegate|
void ForceSyncFrame() override;

// |RuntimeDelegate|
FontCollection& GetFontCollection() override;

Expand Down
1 change: 1 addition & 0 deletions shell/common/engine_unittests.cc
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ class MockRuntimeDelegate : public RuntimeDelegate {
public:
MOCK_METHOD(std::string, DefaultRouteName, (), (override));
MOCK_METHOD(void, ScheduleFrame, (bool), (override));
MOCK_METHOD(void, ForceSyncFrame, (), (override));
MOCK_METHOD(void,
Render,
(std::unique_ptr<flutter::LayerTree>, float),
Expand Down