Flutter iOS Embedder
flutter::VsyncWaiterIOS Class Referencefinal

#import <vsync_waiter_ios.h>

Inheritance diagram for flutter::VsyncWaiterIOS:

Instance Methods

() - VsyncWaiterIOS
 
() - ~VsyncWaiterIOS
 
(double) - GetRefreshRate
 
(fml::scoped_nsobject< VSyncClient >) - GetVsyncClient
 
(void) - AwaitVSync
 

Detailed Description

Definition at line 67 of file vsync_waiter_ios.h.

Constructor & Destructor Documentation

◆ VsyncWaiterIOS

- VsyncWaiterIOS: (const flutter::TaskRunners &)  task_runners

Definition at line 23 of file vsync_waiter_ios.mm.

24  : VsyncWaiter(task_runners) {
25  auto callback = [this](std::unique_ptr<flutter::FrameTimingsRecorder> recorder) {
26  const fml::TimePoint start_time = recorder->GetVsyncStartTime();
27  const fml::TimePoint target_time = recorder->GetVsyncTargetTime();
28  FireCallback(start_time, target_time, true);
29  };
30  client_ =
31  fml::scoped_nsobject{[[VSyncClient alloc] initWithTaskRunner:task_runners_.GetUITaskRunner()
32  callback:callback]};
33  max_refresh_rate_ = [DisplayLinkManager displayRefreshRate];
34 }

◆ ~VsyncWaiterIOS

- VsyncWaiterIOS:

Definition at line 36 of file vsync_waiter_ios.mm.

36  {
37  // This way, we will get no more callbacks from the display link that holds a weak (non-nilling)
38  // reference to this C++ object.
39  [client_.get() invalidate];
40 }

Method Documentation

◆ AwaitVSync

- (void) VsyncWaiterIOS:

Definition at line 42 of file vsync_waiter_ios.mm.

42  {
43  double new_max_refresh_rate = [DisplayLinkManager displayRefreshRate];
44  if (fml::TaskRunnerChecker::RunsOnTheSameThread(
45  task_runners_.GetRasterTaskRunner()->GetTaskQueueId(),
46  task_runners_.GetPlatformTaskRunner()->GetTaskQueueId())) {
47  BOOL isRunningOnMac = NO;
48  if (@available(iOS 14.0, *)) {
49  isRunningOnMac = [NSProcessInfo processInfo].iOSAppOnMac;
50  }
51  if (!isRunningOnMac) {
52  // Pressure tested on iPhone 13 pro, the oldest iPhone that supports refresh rate greater than
53  // 60fps. A flutter app can handle fast scrolling on 80 fps with 6 PlatformViews in the scene
54  // at the same time.
55  new_max_refresh_rate = 80;
56  }
57  }
58  if (fabs(new_max_refresh_rate - max_refresh_rate_) > kRefreshRateDiffToIgnore) {
59  max_refresh_rate_ = new_max_refresh_rate;
60  [client_.get() setMaxRefreshRate:max_refresh_rate_];
61  }
62  [client_.get() await];
63 }

References kRefreshRateDiffToIgnore.

◆ GetRefreshRate

- (double) VsyncWaiterIOS: const

Definition at line 66 of file vsync_waiter_ios.mm.

66  {
67  return [client_.get() getRefreshRate];
68 }

◆ GetVsyncClient

- (scoped_nsobject< VSyncClient >) flutter: const

Definition at line 70 of file vsync_waiter_ios.mm.

70  {
71  return client_;
72 }

The documentation for this class was generated from the following files:
kRefreshRateDiffToIgnore
const static double kRefreshRateDiffToIgnore
Definition: vsync_waiter_ios.mm:19
VSyncClient
Definition: vsync_waiter_ios.h:38