File tree Expand file tree Collapse file tree 1 file changed +15
-1
lines changed
Expand file tree Collapse file tree 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
183183 // TODO: `displayLink.frameInterval` is not available on UIKitForMac
184184 NSTimeInterval duration = displayLink.duration ;
185185#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+ }
187201#endif
188202 NSUInteger totalFrameCount = self.totalFrameCount ;
189203 NSUInteger currentFrameIndex = self.currentFrameIndex ;
You can’t perform that action at this time.
0 commit comments