-
Notifications
You must be signed in to change notification settings - Fork 6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
vsync_waiter_fallback should schedule firecallback for future #28817
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,9 +2,14 @@ | |
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
#define FML_USED_ON_EMBEDDER | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Since this is not in the embedder, it seems odd to lift this gate here. This was done so that custom embedders with no custom event loop integration would continue to function. I think this may not be necessary anymore though. Anyway, the base There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done! |
||
|
||
#include "flutter/shell/common/vsync_waiter_fallback.h" | ||
|
||
#include <memory> | ||
|
||
#include "flutter/fml/logging.h" | ||
#include "flutter/fml/message_loop.h" | ||
#include "flutter/fml/trace_event.h" | ||
|
||
namespace flutter { | ||
|
@@ -35,11 +40,21 @@ void VsyncWaiterFallback::AwaitVSync() { | |
|
||
constexpr fml::TimeDelta kSingleFrameInterval = | ||
fml::TimeDelta::FromSecondsF(1.0 / 60.0); | ||
|
||
auto next = | ||
auto frame_start_time = | ||
SnapToNextTick(fml::TimePoint::Now(), phase_, kSingleFrameInterval); | ||
|
||
FireCallback(next, next + kSingleFrameInterval, !for_testing_); | ||
auto frame_target_time = frame_start_time + kSingleFrameInterval; | ||
std::weak_ptr<VsyncWaiterFallback> weak_this = | ||
std::static_pointer_cast<VsyncWaiterFallback>(shared_from_this()); | ||
|
||
auto current_task_runner = fml::MessageLoop::GetCurrent().GetTaskRunner(); | ||
current_task_runner->PostTaskForTime( | ||
[frame_start_time, frame_target_time, weak_this]() { | ||
if (auto vsync_waiter = weak_this.lock()) { | ||
vsync_waiter->FireCallback(frame_start_time, frame_target_time, | ||
!vsync_waiter->for_testing_); | ||
} | ||
}, | ||
frame_start_time); | ||
} | ||
|
||
} // namespace flutter |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the headerdocs for this protected method, can you document that this subclasses must invoke this at (or close to because of scheduling overhead), the frame start time? Also, can you drop a note in the PR commit message that says verification of all vsync waiter subclasses was done to account for the new assertion for the start time requirements in
FireCallback
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done! will also add the comment when I merge.