Commit 12f8b25 1 parent 2047041 commit 12f8b25 Copy full SHA for 12f8b25
File tree 1 file changed +15
-1
lines changed
1 file changed +15
-1
lines changed Original file line number Diff line number Diff line change @@ -183,7 +183,21 @@ - (void)displayDidRefresh:(CADisplayLink *)displayLink
183
183
// TODO: `displayLink.frameInterval` is not available on UIKitForMac
184
184
NSTimeInterval duration = displayLink.duration ;
185
185
#else
186
- NSTimeInterval duration = displayLink.duration * displayLink.preferredFramesPerSecond ;
186
+ NSTimeInterval duration = displayLink.duration ;
187
+ if (@available (iOS 10.0 , *)) {
188
+ // Per https://developer.apple.com/documentation/quartzcore/cadisplaylink
189
+ // displayLink.duration provides the amount of time between frames at the maximumFramesPerSecond
190
+ // Thus we need to calculate true duration based on preferredFramesPerSecond
191
+ if (displayLink.preferredFramesPerSecond != 0 ) {
192
+ double maxFrameRate = 60.0 ; // default to 60 fps
193
+ if (@available (iOS 10.3 , tvOS 10.3 , *)) {
194
+ maxFrameRate = self.window .screen .maximumFramesPerSecond ;
195
+ }
196
+ duration = duration * displayLink.preferredFramesPerSecond / maxFrameRate;
197
+ } // else respect maximumFramesPerSecond
198
+ } else { // version < (ios 10)
199
+ duration = duration * displayLink.frameInterval ;
200
+ }
187
201
#endif
188
202
NSUInteger totalFrameCount = self.totalFrameCount ;
189
203
NSUInteger currentFrameIndex = self.currentFrameIndex ;
You can’t perform that action at this time.
0 commit comments