Skip to content

iOS: run native-driven animations above 60 fps on ProMotion screens - #60384

Closed
chrfalch-bot wants to merge 1 commit into
react:mainfrom
chrfalch-bot:ios-high-refresh-rate
Closed

chrfalch-bot wants to merge 1 commit into
react:mainfrom
chrfalch-bot:ios-high-refresh-rate

Conversation

@chrfalch-bot

Copy link
Copy Markdown

Summary

On 120 Hz iPhones (ProMotion), animations that use the native driver run at only 60 fps. None of the display links that drive them ask iOS for a higher frame rate, and the repo's apps do not opt in to rates above 60 Hz.

This change makes those display links ask for up to the screen's top rate. When frames take too long, they step down to 60, 30 or 24 fps, the same steps Reanimated uses. Screens at 60 Hz or below are not affected. RNTester and HelloWorld opt in with Apple's CADisableMinimumFrameDurationOnPhone Info.plist key. There is no feature flag.

How to check: run RNTesterUnitTests. All 22 RCTAdaptiveFrameRateTests should pass.

This PR does not depend on any other PR.

Details

New helper: React/Base/RCTAdaptiveFrameRate.{h,m}

  • RCTAdaptiveFrameRate keeps the work times of the last 4 frames. It picks the highest step whose frame budget is larger than their average. The steps request these ranges: (60, max, max), (30, 60, 60), (24, 30, 30) and (10, 24, 24), where max is the screen's maximum fps, as in Reanimated's AnimationFrameQueue.mm. It moves back up when the work gets cheaper. A maximum below 60 is treated as 60. +adaptiveFrameRateForMaximumFramesPerSecond: returns nil at 60 Hz or below.
  • RCTAdaptiveFrameRateController records each tick's work time and sets preferredFrameRateRange only when the step changes. It is used only on the display-link tick, on the main thread, so nothing on the stop or invalidate paths touches it. It starts over when the display link changes (tracked through a weak reference) or when more than 250 ms pass between ticks, which covers pause and resume. UIScreen is read on the main thread only, on the first tick.

Call sites

  • RCTNativeAnimatedNodesManager.mm: the old native driver.
  • RCTAnimatedModuleProvider.mm: the C++ animated driver, iOS branch only.
  • RCTScheduler.mm: the display link of RCTAnimationChoreographer.

Deliberately unchanged

  • RCTDisplayLink (JS requestAnimationFrame) stays at 60 fps. Its JS work runs after the tick, so the tick cannot measure it, and Reanimated leaves it alone too.
  • No @available check. The minimum is iOS 15.1, and preferredFrameRateRange exists since iOS 15.0.

Follow-up

  • The app template lives outside this repo and still needs the Info.plist key.

Changelog:

[IOS] [CHANGED] - Native-driven animations can run above 60 fps on ProMotion displays. Apps opt in with CADisableMinimumFrameDurationOnPhone.

Test Plan:

  • Unit tests: xcodebuild test -workspace packages/rn-tester/RNTesterPods.xcworkspace -scheme RNTester -only-testing:RNTesterUnitTests on the iPhone 18 Pro simulator.
    • 211 tests ran.
    • RCTAdaptiveFrameRateTests: 22 of 22 passed. They cover step choice and its boundaries, the 4-frame average, moving back up, skipping screens at 60 Hz or below, writing only on a change, the below-60 limit, and the controller starting over on a new display link and after a pause.
    • The only failure is RCTBundleURLProviderTests testBundleURL, which needs Metro, and Metro was not running.
    • The tests were first run against stub versions of the helper and seen failing.
  • clang-format on the changed native files: clean.
  • Not run: a check on a real ProMotion device. No device was available. To check it, run an Animated loop with useNativeDriver: true in RNTester on a 120 Hz iPhone and watch the frame rate in Instruments or the performance HUD.

On 120 Hz iPhones, native-driven animations ran at 60 fps because no
CADisplayLink driving them set preferredFrameRateRange.

Add RCTAdaptiveFrameRate and RCTAdaptiveFrameRateController. On screens
faster than 60 Hz they request the screen maximum and step down to 60,
30 or 24 fps when the average work time of the last four frames exceeds
the frame budget, the same tiers Reanimated uses. The range is written
only when the tier changes. Apply it to the display links of the old
native driver, the C++ animated driver and RCTAnimationChoreographer.
Screens at 60 Hz or below are untouched. The JS requestAnimationFrame
display link is unchanged.

RNTester and HelloWorld set CADisableMinimumFrameDurationOnPhone, which
iPhone apps need to go above 60 fps.
@meta-cla

meta-cla Bot commented Nov 29, 2026

Copy link
Copy Markdown

Hi @chrfalch-bot!

Thank you for your pull request and welcome to our community.

Action Required

In order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you.

Process

In order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA.

Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with CLA signed. The tagging process may take up to 1 hour after signing. Please give it that time before contacting us about it.

If you have received this in error or have any questions, please contact us at cla@meta.com. Thanks!

@github-actions github-actions Bot added the Meta Review Required This PR is considered risky and requires Meta to import it to do more testing before merging. label Nov 29, 2026
@chrfalch chrfalch closed this Nov 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Meta Review Required This PR is considered risky and requires Meta to import it to do more testing before merging. p: Expo Partner: Expo Partner

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants