From fabfb41f6c3e3fcac594c2f4c54a792f1d4a9e4a Mon Sep 17 00:00:00 2001 From: ColdPaleLight <31977171+ColdPaleLight@users.noreply.github.com> Date: Wed, 13 Oct 2021 05:22:29 +0800 Subject: [PATCH] Calculate the frame target time based on targetTimestamp in VsyncWaiterIOS (flutter/engine#29131) --- .../darwin/ios/framework/Source/vsync_waiter_ios.mm | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/engine/src/flutter/shell/platform/darwin/ios/framework/Source/vsync_waiter_ios.mm b/engine/src/flutter/shell/platform/darwin/ios/framework/Source/vsync_waiter_ios.mm index b00b1cf864..cb4858d0f8 100644 --- a/engine/src/flutter/shell/platform/darwin/ios/framework/Source/vsync_waiter_ios.mm +++ b/engine/src/flutter/shell/platform/darwin/ios/framework/Source/vsync_waiter_ios.mm @@ -76,7 +76,14 @@ void VsyncWaiterIOS::AwaitVSync() { CFTimeInterval delay = CACurrentMediaTime() - link.timestamp; fml::TimePoint frame_start_time = fml::TimePoint::Now() - fml::TimeDelta::FromSecondsF(delay); - fml::TimePoint frame_target_time = frame_start_time + fml::TimeDelta::FromSecondsF(link.duration); + + CFTimeInterval duration; + if (@available(iOS 10.0, *)) { + duration = link.targetTimestamp - link.timestamp; + } else { + duration = link.duration; + } + fml::TimePoint frame_target_time = frame_start_time + fml::TimeDelta::FromSecondsF(duration); std::unique_ptr recorder = std::make_unique();