Skip to content

Commit 6ff3ecc

Browse files
farchondNoamDev
authored andcommitted
[fuchsia] change kMaxFramesInFlight to 3 (flutter#16425)
To give more flexibility 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, matching previous behavior.
1 parent edd07bd commit 6ff3ecc

File tree

3 files changed

+14
-2
lines changed

3 files changed

+14
-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: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,15 @@ 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 =
139+
next_vsync_start_time + vsync_info.presentation_interval;
140+
141+
fml::TimeDelta delta = next_vsync_start_time - now;
142+
134143
task_runners_.GetUITaskRunner()->PostDelayedTask(
135144
[& weak_factory_ui = this->weak_factory_ui_] {
136145
if (!weak_factory_ui) {
@@ -143,7 +152,7 @@ void VsyncWaiter::AwaitVSync() {
143152
self->FireCallbackWhenSessionAvailable();
144153
}
145154
},
146-
next_vsync - now);
155+
delta);
147156
}
148157

149158
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)