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

Commit 0a2034e

Browse files
authored
[fuchsia] MaybeRunInitialVsyncCallback should only called once (#56429)
Currently, flutter keeps calling MaybeRunInitialVsyncCallback() until 1 OnNextFrameBegin() called from Fuchsia which maybe problem when display is off. Tested manually. Bug: http://fxbug.dev/376079469 ## Pre-launch Checklist - [x] I read the [Contributor Guide] and followed the process outlined there for submitting PRs. - [x] I read the [Tree Hygiene] wiki page, which explains my responsibilities. - [x] I read and followed the [Flutter Style Guide] and the [C++, Objective-C, Java style guides]. - [x] I listed at least one issue that this PR fixes in the description above. - [x] I added new tests to check the change I am making or feature I am adding, or the PR is [test-exempt]. See [testing the engine] for instructions on writing and running engine tests. - [x] I updated/added relevant documentation (doc comments with `///`). - [x] I signed the [CLA]. - [x] All existing and new tests are passing.
1 parent 8b5560c commit 0a2034e

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_.initial_vsync_callback_ran_) {
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_.initial_vsync_callback_ran_ = 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 initial_vsync_callback_ran_ = false;
141141
} threadsafe_state_;
142142

143143
// Acquire fences sent to Flatland.

0 commit comments

Comments
 (0)