Skip to content

Commit

Permalink
[fuchsia] MaybeRunInitialVsyncCallback should only called once
Browse files Browse the repository at this point in the history
Currently, flutter keeps calling MaybeRunInitialVsyncCallback() until 1
OnNextFrameBegin() called from Fuchsia which maybe problem when display
is off.

Bug: http://fxbug.dev/376079469
  • Loading branch information
chaopeng committed Nov 8, 2024
1 parent 44d788f commit f743e22
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
18 changes: 9 additions & 9 deletions shell/platform/fuchsia/flutter/flatland_connection.cc
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,6 @@ void FlatlandConnection::OnNextFrameBegin(
const auto now = fml::TimePoint::Now();

std::scoped_lock<std::mutex> lock(threadsafe_state_.mutex_);
threadsafe_state_.first_feedback_received_ = true;
threadsafe_state_.present_credits_ += values.additional_present_credits();
TRACE_DURATION("flutter", "FlatlandConnection::OnNextFrameBegin",
"present_credits", threadsafe_state_.present_credits_);
Expand Down Expand Up @@ -319,15 +318,16 @@ fml::TimePoint FlatlandConnection::GetNextPresentationTime(
bool FlatlandConnection::MaybeRunInitialVsyncCallback(
const fml::TimePoint& now,
FireCallbackCallback& callback) {
if (!threadsafe_state_.first_feedback_received_) {
TRACE_DURATION("flutter",
"FlatlandConnection::MaybeRunInitialVsyncCallback");
const auto frame_end = now + kInitialFlatlandVsyncOffset;
threadsafe_state_.last_presentation_time_ = frame_end;
callback(now, frame_end);
return true;
// Only sent maybe_run_initial_vsync once.
if (threadsafe_state_.maybe_run_initial_vsync_callback_sent_) {
return false;
}
return false;
TRACE_DURATION("flutter", "FlatlandConnection::MaybeRunInitialVsyncCallback");
const auto frame_end = now + kInitialFlatlandVsyncOffset;
threadsafe_state_.last_presentation_time_ = frame_end;
threadsafe_state_.maybe_run_initial_vsync_callback_sent_ = true;
callback(now, frame_end);
return true;
}

// This method may be called from the raster or UI thread, but it is safe
Expand Down
2 changes: 1 addition & 1 deletion shell/platform/fuchsia/flutter/flatland_connection.h
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ class FlatlandConnection final {
fml::TimePoint last_presentation_time_;
FireCallbackCallback pending_fire_callback_;
uint32_t present_credits_ = 1;
bool first_feedback_received_ = false;
bool maybe_run_initial_vsync_callback_sent_ = false;
} threadsafe_state_;

// Acquire fences sent to Flatland.
Expand Down

0 comments on commit f743e22

Please sign in to comment.