Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit 7a519a2

Browse files
committed
[fuchsia] change kMaxFramesInFlight to 3
To give more flexibiltiy in scheduling, we change the number of frames in flight we can have at one time to 3. We also introduce an offset from VSync that Flutter can use to begin its work at. It is currently set at 0ms, signalling no change from previous behavior.
1 parent 11b7704 commit 7a519a2

File tree

3 files changed

+13
-2
lines changed

3 files changed

+13
-2
lines changed

shell/platform/fuchsia/flutter/session_connection.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ class SessionConnection final {
9494
// The maximum number of frames Flutter sent to Scenic that it can have
9595
// outstanding at any time. This is equivalent to how many times it has
9696
// called Present2() before receiving an OnFramePresented() event.
97-
static constexpr int kMaxFramesInFlight = 2;
97+
static constexpr int kMaxFramesInFlight = 3;
9898
int frames_in_flight_ = 0;
9999

100100
int frames_in_flight_allowed_ = 0;

shell/platform/fuchsia/flutter/vsync_waiter.cc

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,14 @@ void VsyncWaiter::AwaitVSync() {
131131
VsyncRecorder::GetInstance().GetLastPresentationTime();
132132
fml::TimePoint next_vsync = SnapToNextPhase(now, last_presentation_time,
133133
vsync_info.presentation_interval);
134+
135+
auto next_vsync_start_time = next_vsync - vsync_offset;
136+
137+
if (now >= next_vsync_start_time)
138+
next_vsync_start_time = next_vsync_start_time + vsync_info.presentation_interval;
139+
140+
fml::TimeDelta delta = next_vsync_start_time - now;
141+
134142
task_runners_.GetUITaskRunner()->PostDelayedTask(
135143
[& weak_factory_ui = this->weak_factory_ui_] {
136144
if (!weak_factory_ui) {
@@ -143,7 +151,7 @@ void VsyncWaiter::AwaitVSync() {
143151
self->FireCallbackWhenSessionAvailable();
144152
}
145153
},
146-
next_vsync - now);
154+
delta);
147155
}
148156

149157
void VsyncWaiter::FireCallbackWhenSessionAvailable() {

shell/platform/fuchsia/flutter/vsync_waiter.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,9 @@ class VsyncWaiter final : public flutter::VsyncWaiter {
3434
async::Wait session_wait_;
3535
fml::WeakPtrFactory<VsyncWaiter> weak_factory_;
3636

37+
static constexpr fml::TimeDelta vsync_offset =
38+
fml::TimeDelta::FromNanoseconds(0);
39+
3740
// For accessing the VsyncWaiter via the UI thread, necessary for the callback
3841
// for AwaitVSync()
3942
std::unique_ptr<fml::WeakPtrFactory<VsyncWaiter>> weak_factory_ui_;

0 commit comments

Comments
 (0)