Delay the vsync callback till the frame start time specified by embedder. (flutter/engine#8072)
The current assumption is that the embedder will wait till the vsync event and then fire the callback. However, some embedders have that information upfront. Since the time point has already been specified by the embedder, there is no reason to burden the embedder with having to setup a wait either.
This commit is contained in:
committed by
Chris Bracken
parent
321b66f228
commit
cff370118a
@@ -35,7 +35,7 @@ void VsyncWaiter::FireCallback(fml::TimePoint frame_start_time,
|
||||
return;
|
||||
}
|
||||
|
||||
task_runners_.GetUITaskRunner()->PostTask(
|
||||
task_runners_.GetUITaskRunner()->PostTaskForTime(
|
||||
[callback, frame_start_time, frame_target_time]() {
|
||||
#if defined(OS_FUCHSIA)
|
||||
// In general, traces on Fuchsia are recorded across the whole system.
|
||||
@@ -49,7 +49,8 @@ void VsyncWaiter::FireCallback(fml::TimePoint frame_start_time,
|
||||
TRACE_EVENT0("flutter", "VSYNC");
|
||||
#endif
|
||||
callback(frame_start_time, frame_target_time);
|
||||
});
|
||||
},
|
||||
frame_start_time);
|
||||
}
|
||||
|
||||
float VsyncWaiter::GetDisplayRefreshRate() const {
|
||||
|
||||
@@ -549,13 +549,15 @@ typedef struct {
|
||||
// Flutter application (such as compiled shader programs used by Skia).
|
||||
// This is optional. The string must be NULL terminated.
|
||||
const char* persistent_cache_path;
|
||||
// A callback that gets invoked by the engine when it attempts to wait for
|
||||
// a platform vsync event. The engine will give the platform a baton that
|
||||
// needs to be returned back to the engine via |FlutterEngineOnVsync|. All
|
||||
// vsync operations must occur on the thread that made the call to
|
||||
// |FlutterEngineRun|. All batons must be retured to the engine before
|
||||
// initializing a |FlutterEngineShutdown|. Not doing the same will result in a
|
||||
// memory leak.
|
||||
// A callback that gets invoked by the engine when it attempts to wait for a
|
||||
// platform vsync event. The engine will give the platform a baton that needs
|
||||
// to be returned back to the engine via |FlutterEngineOnVsync|. All batons
|
||||
// must be retured to the engine before initializing a
|
||||
// |FlutterEngineShutdown|. Not doing the same will result in a memory leak.
|
||||
// While the call to |FlutterEngineOnVsync| must occur on the thread that made
|
||||
// the call to |FlutterEngineRun|, the engine will make this callback on an
|
||||
// internal engine-managed thread. If the components accessed on the embedder
|
||||
// are not thread safe, the appropriate re-threading must be done.
|
||||
VsyncCallback vsync_callback;
|
||||
} FlutterProjectArgs;
|
||||
|
||||
@@ -645,7 +647,15 @@ FlutterEngineResult FlutterEngineDispatchSemanticsAction(
|
||||
size_t data_length);
|
||||
|
||||
// Notify the engine that a vsync event occurred. A baton passed to the
|
||||
// platform via the vsync callback must be returned.
|
||||
// platform via the vsync callback must be returned. This call must be made on
|
||||
// the thread on which the call to |FlutterEngineRun| was made.
|
||||
//
|
||||
// |frame_start_time_nanos| is the point at which the vsync event occurred.
|
||||
// |frame_target_time_nanos| is the point at which the embedder anticipates the
|
||||
// next vsync to occur. This is a hint the engine uses to schedule Dart VM
|
||||
// garbage collection in periods in which the various threads are most likely to
|
||||
// be idle. For example, for a 60Hz display, embedders should add 16.6 * 1e6 to
|
||||
// the frame time field.
|
||||
FLUTTER_EXPORT
|
||||
FlutterEngineResult FlutterEngineOnVsync(FlutterEngine engine,
|
||||
intptr_t baton,
|
||||
|
||||
Reference in New Issue
Block a user