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

Commit f957776

Browse files
committed
[fuchsia] MaybeRunInitialVsyncCallback should only called once
Currently, flutter keeps calling MaybeRunInitialVsyncCallback() until 1 OnNextFrameBegin() called from Fuchsia which maybe problem when display is off. Bug: http://fxbug.dev/376079469
1 parent 3df1546 commit f957776

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

shell/platform/fuchsia/flutter/flatland_connection.cc

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,6 @@ void FlatlandConnection::OnNextFrameBegin(
222222
const auto now = fml::TimePoint::Now();
223223

224224
std::scoped_lock<std::mutex> lock(threadsafe_state_.mutex_);
225-
threadsafe_state_.first_feedback_received_ = true;
226225
threadsafe_state_.present_credits_ += values.additional_present_credits();
227226
TRACE_DURATION("flutter", "FlatlandConnection::OnNextFrameBegin",
228227
"present_credits", threadsafe_state_.present_credits_);
@@ -319,15 +318,16 @@ fml::TimePoint FlatlandConnection::GetNextPresentationTime(
319318
bool FlatlandConnection::MaybeRunInitialVsyncCallback(
320319
const fml::TimePoint& now,
321320
FireCallbackCallback& callback) {
322-
if (!threadsafe_state_.first_feedback_received_) {
323-
TRACE_DURATION("flutter",
324-
"FlatlandConnection::MaybeRunInitialVsyncCallback");
325-
const auto frame_end = now + kInitialFlatlandVsyncOffset;
326-
threadsafe_state_.last_presentation_time_ = frame_end;
327-
callback(now, frame_end);
328-
return true;
321+
// Only sent maybe_run_initial_vsync once.
322+
if (threadsafe_state_.maybe_run_initial_vsync_callback_sent_) {
323+
return false;
329324
}
330-
return false;
325+
TRACE_DURATION("flutter", "FlatlandConnection::MaybeRunInitialVsyncCallback");
326+
const auto frame_end = now + kInitialFlatlandVsyncOffset;
327+
threadsafe_state_.last_presentation_time_ = frame_end;
328+
threadsafe_state_.maybe_run_initial_vsync_callback_sent_ = true;
329+
callback(now, frame_end);
330+
return true;
331331
}
332332

333333
// This method may be called from the raster or UI thread, but it is safe

shell/platform/fuchsia/flutter/flatland_connection.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ class FlatlandConnection final {
137137
fml::TimePoint last_presentation_time_;
138138
FireCallbackCallback pending_fire_callback_;
139139
uint32_t present_credits_ = 1;
140-
bool first_feedback_received_ = false;
140+
bool maybe_run_initial_vsync_callback_sent_ = false;
141141
} threadsafe_state_;
142142

143143
// Acquire fences sent to Flatland.

0 commit comments

Comments
 (0)