View in English

  • Apple Developer
    • Get Started

    Explore Get Started

    • Overview
    • Learn
    • Apple Developer Program

    Stay Updated

    • Latest News
    • Hello Developer
    • Platforms

    Explore Platforms

    • Apple Platforms
    • iOS
    • iPadOS
    • macOS
    • tvOS
    • visionOS
    • watchOS
    • App Store

    Featured

    • Design
    • Distribution
    • Games
    • Accessories
    • Web
    • Home
    • CarPlay
    • Technologies

    Explore Technologies

    • Overview
    • Xcode
    • Swift
    • SwiftUI

    Featured

    • Accessibility
    • App Intents
    • Apple Intelligence
    • Games
    • Machine Learning & AI
    • Security
    • Xcode Cloud
    • Community

    Explore Community

    • Overview
    • Meet with Apple events
    • Community-driven events
    • Developer Forums
    • Open Source

    Featured

    • WWDC
    • Swift Student Challenge
    • Developer Stories
    • App Store Awards
    • Apple Design Awards
    • Apple Developer Centers
    • Documentation

    Explore Documentation

    • Documentation Library
    • Technology Overviews
    • Sample Code
    • Human Interface Guidelines
    • Videos

    Release Notes

    • Featured Updates
    • iOS
    • iPadOS
    • macOS
    • watchOS
    • visionOS
    • tvOS
    • Xcode
    • Downloads

    Explore Downloads

    • All Downloads
    • Operating Systems
    • Applications
    • Design Resources

    Featured

    • Xcode
    • TestFlight
    • Fonts
    • SF Symbols
    • Icon Composer
    • Support

    Explore Support

    • Overview
    • Help Guides
    • Developer Forums
    • Feedback Assistant
    • Contact Us

    Featured

    • Account Help
    • App Review Guidelines
    • App Store Connect Help
    • Upcoming Requirements
    • Agreements and Guidelines
    • System Status
  • Quick Links

    • Events
    • News
    • Forums
    • Sample Code
    • Videos
 

Vidéos

Ouvrir le menu Fermer le menu
  • Collections
  • Toutes les vidéos
  • À propos

Plus de vidéos

  • À propos
  • Code
  • Optimize for variable refresh rate displays

    Discover how to achieve smooth screen updates on all Apple platforms that support dynamic display timing. Learn techniques for pacing full-screen game updates on Adaptive Sync displays in macOS, and find out how Low Power Mode and other system states affect frame rate availability on ProMotion displays. We'll also share best practices for driving custom drawing using display link APIs.

    Ressources

    • Metal Feature Set Tables
    • Metal
      • Vidéo HD
      • Vidéo SD

    Vidéos connexes

    WWDC22

    • Power down: Improve battery consumption

    WWDC19

    • Delivering Optimized Metal Apps and Games
  • Rechercher dans cette vidéo…
    • 5:51 - Is Adaptive-Sync scheduling enabled

      // Detecting an Adaptive-Sync display
      
      - (BOOL) isAdaptiveSyncSupported:(NSScreen *)screen {
          NSTimeInterval minInterval = screen.minimumRefreshInterval;  
          NSTimeInterval maxInterval = screen.maximumRefreshInterval;  
          return minInterval != maxInterval;
      }
      
      // Detecting full-screen
      
      - (BOOL) isWindowFullscreen:(NSWindow *)window {
          return ([window styleMask] &= NSFullScreenWindowMask) == NSFullScreenWindowMask;
      }
      
      // Tying it all together
      
      - (BOOL) isAdaptiveSyncSchedulingEnabled:(NSScreen *)window {
          NSScreen* windowScreen = [window screen];
          return [self isWindowFullscreen:window] && [self isAdaptiveSyncSupported:windowScreen];
      }
    • 6:49 - Leverage Drawable present calls

      // Drawable present APIs with frame-pacing
      
      [commandBuffer presentDrawable:drawable afterMinimumDuration:interval];
      [commandBuffer presentDrawable:drawable atTime:t];
      
      // Drawable present API without frame-pacing
      
      [commandBuffer presentDrawable:drawable];
    • 7:11 - A simple example

      id<CAMetalDrawable> currentDrawable = [metalLayer nextDrawable];
      
      // Your encoder and command buffers here
      
      [commandBuffer presentDrawable:currentDrawable];
    • 7:55 - Adaptive-Sync in your app 1

      id<CAMetalDrawable> currentDrawable = [metalLayer nextDrawable];
      
      NSTimeInterval userFramerateCap = 78.0;
      NSTimeInterval userInterval     =  1.0 / userFramerateCap;
      
      // Your encoders and command buffers are still here
      [commandBuffer presentDrawable:currentDrawable afterMinimumDuration:userInterval];
    • 8:43 - Adaptive-Sync in your app 2

      id<CAMetalDrawable> currentDrawable = [metalLayer nextDrawable];
      
      // Your encoders and command buffers are still available!
      
      NSTimeInterval averageGPUTime = screen.minimumRefreshInterval;
      
      [commandBuffer presentDrawable:currentDrawable afterMinimumDuration:averageGPUTime];
      
      [commandBuffer addCompletedHandler:^(id<MTLCommandBuffer> buffer) {
        const NSTimeInterval GPUTime = buffer.GPUEndTime - buffer.GPUStartTime;
      
        // Use an exponential moving average
        const double alpha = .25;
      
        averageGPUTime = (GPUTime * alpha) + (averageGPUTime * (1.0 - alpha));
      }];
    • 15:36 - Query the display refresh rate at runtime

      // Maximum frame rate from UIKit
      
      NSInteger maxRate = [[UIScreen mainScreen] maximumFramesPerSecond];
      
      // Current maximum frame rate from CoreAnimation
      
      NSInteger currentMaxRate = round(1 / link.duration);
    • 17:06 - Use the actual frame rate of the CADisplayLink

      CADisplayLink *link = [CADisplayLink displayLinkWithTarget:self 
                                                        selector:@selector(displayLinkCallback:)];
      
      [link setPreferredFramesPerSecond:40];
      [link addToRunLoop:[NSRunLoop currentRunLoop] forMode:NSDefaultRunLoopMode];
      
      - (void)displayLinkCallback:(CADisplayLink *)link {
          CFTimeInterval interval = link.targetTimestamp - link.timestamp;
      
          //...
      }
    • 21:47 - Dynamically compute the time delta 1

      - (void)displayLinkCallback:(CADisplayLink *)link {
          progress += link.targetTimestamp - link.timestamp;
          [self renderAnimationWithProgress:progress];
      }
    • 21:57 - Dynamically compute the time delta 2

      - (void)displayLinkCallback:(CADisplayLink *)link {
          progress += link.targetTimestamp - previousTargetTimestamp;
          previousTargetTimestamp = link.targetTimestamp;
      
          [self renderAnimationWithProgress:progress];
      }
    • 22:08 - Dynamically compute the time delta 3

      - (void)displayLinkCallback:(CADisplayLink *)link {
          progress += link.targetTimestamp - previousTargetTimestamp;
          previousTargetTimestamp = link.targetTimestamp;
      
          [self renderAnimationWithProgress:progress withDeadline:link.targetTimestamp];
      }

Developer Footer

  • Vidéos
  • WWDC21
  • Optimize for variable refresh rate displays
  • Open Menu Close Menu
    • iOS
    • iPadOS
    • macOS
    • tvOS
    • visionOS
    • watchOS
    • App Store
    Open Menu Close Menu
    • Swift
    • SwiftUI
    • Swift Playground
    • TestFlight
    • Xcode
    • Xcode Cloud
    • Icon Composer
    • SF Symbols
    Open Menu Close Menu
    • Accessibility
    • Accessories
    • Apple Intelligence
    • Audio & Video
    • Augmented Reality
    • Business
    • Design
    • Distribution
    • Education
    • Games
    • Health & Fitness
    • In-App Purchase
    • Localization
    • Maps & Location
    • Machine Learning & AI
    • Security
    • Safari & Web
    Open Menu Close Menu
    • Documentation
    • Downloads
    • Sample Code
    • Videos
    Open Menu Close Menu
    • Help Guides & Articles
    • Contact Us
    • Forums
    • Feedback & Bug Reporting
    • System Status
    Open Menu Close Menu
    • Apple Developer
    • App Store Connect
    • Certificates, IDs, & Profiles
    • Feedback Assistant
    Open Menu Close Menu
    • Apple Developer Program
    • Apple Developer Enterprise Program
    • App Store Small Business Program
    • MFi Program
    • Mini Apps Partner Program
    • News Partner Program
    • Video Partner Program
    • Security Bounty Program
    • Security Research Device Program
    Open Menu Close Menu
    • Meet with Apple
    • Apple Developer Centers
    • App Store Awards
    • Apple Design Awards
    • Apple Developer Academies
    • WWDC
    Read the latest news.
    Get the Apple Developer app.
    Copyright © 2026 Apple Inc. All rights reserved.
    Terms of Use Privacy Policy Agreements and Guidelines