facebook / react-native

A framework for building native applications using React
https://reactnative.dev
MIT License
119.28k stars 24.35k forks source link

React native does not support screen refresh rate #29333

Open tdekoning opened 4 years ago

tdekoning commented 4 years ago

Please provide all the information requested. Issues that do not follow this format are likely to stall.

Description

When running a react native app on a device that has a refresh rate other than 60, react native apps still run at 60 fps. This means that if you have a device like a Samsung Galaxy S20, which runs at 120 fps, every react native app will feel sluggish, slow and underperforming.

React native should honor the screen's refresh rate and use that for rendering.

React Native version:

Run react-native info in your terminal and copy the results here.

System:
    OS: macOS 10.15.5
    CPU: (8) x64 Intel(R) Core(TM) i7-7820HQ CPU @ 2.90GHz
    Memory: 791.56 MB / 16.00 GB
    Shell: 3.2.57 - /bin/bash
  Binaries:
    Node: 12.16.1 - ~/.nvm/versions/node/v12.16.1/bin/node
    Yarn: 1.19.1 - ~/.yarn/bin/yarn
    npm: 6.13.4 - ~/.nvm/versions/node/v12.16.1/bin/npm
    Watchman: 4.9.0 - /usr/local/bin/watchman
  Managers:
    CocoaPods: 1.9.1 - /usr/local/bin/pod
  SDKs:
    iOS SDK:
      Platforms: iOS 13.5, DriverKit 19.0, macOS 10.15, tvOS 13.4, watchOS 6.2
    Android SDK:
      API Levels: 21, 22, 23, 24, 25, 26, 27, 28, 29
      Build Tools: 25.0.0, 26.0.1, 26.0.2, 27.0.2, 27.0.3, 28.0.2, 28.0.3, 29.0.0, 29.0.2
      System Images: android-16 | Google APIs Intel x86 Atom, android-19 | Google APIs Intel x86 Atom, android-21 | Google APIs Intel x86 Atom_64, android-22 | Google APIs Intel x86 Atom, android-23 | Google APIs Intel x86 Atom, android-23 | Google APIs Intel x86 Atom_64, android-24 | Google Play Intel x86 Atom, android-25 | Google APIs Intel x86 Atom, android-25 | Google Play Intel x86 Atom, android-26 | Google Play Intel x86 Atom, android-29 | Google APIs Intel x86 Atom, android-29 | Google Play Intel x86 Atom, android-P | Google Play Intel x86 Atom, android-Q | Google APIs Intel x86 Atom
      Android NDK: 21.0.6113669
  IDEs:
    Android Studio: Not Found
    Xcode: 11.5/11E608c - /usr/bin/xcodebuild
  Languages:
    Java: 1.8.0_152 - /usr/bin/javac
    Python: 2.7.16 - /usr/bin/python
  npmPackages:
    @react-native-community/cli: Not Found
    react: 16.11.0 => 16.11.0 
    react-native: 0.62.2 => 0.62.2 
  npmGlobalPackages:
    *react-native*: Not Found

Steps To Reproduce

Provide a detailed list of steps that reproduce the issue.

  1. Use a phone with a higher refresh rate than 60 (e.g. Samsung Galaxy S20, Oneplus 7T (or higher))
  2. Start any react native app
  3. See that the app is slower than every app on the phone

Expected Results

I expect that the app runs smooth on all refresh rates above 60.

Snack, code example, screenshot, or link to a repository:

Guuz commented 4 years ago

This is very visible with apps that use something like React Navigation that has screen transitions.

stale[bot] commented 4 years ago

Hey there, it looks like there has been no activity on this issue recently. Has the issue been fixed, or does it still require the community's attention? This issue may be closed if no further activity occurs. You may also label this issue as a "Discussion" or add it to the "Backlog" and I will leave it open. Thank you for your contributions.

Guuz commented 4 years ago

I believe it still requires attention!

tdekoning commented 4 years ago

Sadly, it still isn't supported :(

enahum commented 3 years ago

Anything new that address this in 0.64?

juliendeveloper commented 3 years ago

Is there anything new? In my opinion it's a recommend feature

Jojr commented 3 years ago

On Android, the frame rate settings are available from API level 30 or higher. Currently, React Native 0.64 is using API level 29. It will be available only on further versions of RN, I guess.

https://developer.android.com/guide/topics/media/frame-rate

juliendeveloper commented 3 years ago

Anything new here?!?!

Jojr commented 3 years ago

Anything new here?!?!

Not yet. The RN 0.65 has launched with API level 29 (the same as the 0.64).

matapo commented 3 years ago

On Android, the frame rate settings are available from API level 30 or higher. Currently, React Native 0.64 is using API level 29. It will be available only on further versions of RN, I guess.

https://developer.android.com/guide/topics/media/frame-rate

what about ios?

andresribeiro commented 3 years ago

On Android, the frame rate settings are available from API level 30 or higher. Currently, React Native 0.64 is using API level 29. It will be available only on further versions of RN, I guess. https://developer.android.com/guide/topics/media/frame-rate

what about ios?

I think that iPhone 12 only supports 60 Hz

matapo commented 3 years ago

iPad Pro has 120Hz. There are rumors that iPhone 13 will have 120Hz as well, which we'll see in a few weeks.

https://developer.apple.com/library/archive/documentation/DeviceInformation/Reference/iOSDeviceCompatibility/Displays/Displays.html

UPDATE: iPhone 13 has 120Hz

alexfoxy commented 3 years ago

This would be really great to get this uncapped. Perhaps it will be on a system level on iOS?

zachgibson commented 3 years ago

I think this will work on iOS already without RN core changing anything.

zachgibson commented 3 years ago

According to the WWDC talk “Optimize for variable refresh rate displays”:

“Most apps will work (with ProMotion) without any changes, but if your app performs frame-by-frame custom drawing then you will need to pay attention to these frame rate changes…”.

swrobel commented 3 years ago

Apple's docs for enabling ProMotion on iPhone 13 Pro & iPad Pro. It seems it's as simple as adding this plist entry, although I don't have such a device to test whether or not it works with an RN app:

<key>CADisableMinimumFrameDurationOnPhone</key><true/>
tastafur commented 3 years ago

Apart from all this, there are a few places where 60 frames are hardcoded.

https://github.com/facebook/react-native/blob/1465c8f3874cdee8c325ab4a4916fda0b3e43bdb/Libraries/Animated/animations/TimingAnimation.js#L81

https://github.com/facebook/react-native/blob/1465c8f3874cdee8c325ab4a4916fda0b3e43bdb/packages/rn-tester/RNTesterUnitTests/RCTNativeAnimatedNodesManagerTests.m#L286

https://github.com/facebook/react-native/blob/1465c8f3874cdee8c325ab4a4916fda0b3e43bdb/Libraries/NativeAnimation/Drivers/RCTAnimationDriver.h#L13

this? https://github.com/facebook/react-native/blob/1465c8f3874cdee8c325ab4a4916fda0b3e43bdb/ReactAndroid/src/main/java/com/facebook/react/uimanager/FabricViewStateManager.java#L65

https://github.com/facebook/react-native/blob/657c48c21de496734716ed33c9e55d8baae3494f/ReactAndroid/src/main/java/com/facebook/react/modules/core/JavaTimerManager.java#L38

https://github.com/facebook/react-native/blob/8d0a2e79212b77cafcc9af73e92c0f2b23f782e8/React/Fabric/Mounting/ComponentViews/ScrollView/RCTScrollViewComponentView.mm#L217

https://github.com/facebook/react-native/blob/1465c8f3874cdee8c325ab4a4916fda0b3e43bdb/Libraries/Animated/__tests__/Easing-test.js#L84

https://github.com/facebook/react-native/blob/feae814153783a0d03d0a332917991f139c36e9f/React/Base/RCTMultipartStreamReader.m#L73

https://github.com/facebook/react-native/blob/1465c8f3874cdee8c325ab4a4916fda0b3e43bdb/ReactAndroid/src/main/java/com/facebook/react/animated/SpringAnimation.java#L19

https://github.com/facebook/react-native/blob/1465c8f3874cdee8c325ab4a4916fda0b3e43bdb/ReactAndroid/src/test/java/com/facebook/react/animated/NativeAnimatedNodeTraversalTest.java#L460

andresribeiro commented 3 years ago

so... any news? an app that runs at 60fps for someone who uses a 120fps smartphone is a little strange

Pajn commented 3 years ago

With adaptive frame rate, issues with not syncing with vsync are even more pronounced. On my S21 when "flicking" a list so that it continues scrolling after the finger is lifted the list starts to "jelly scroll" after lifting the finger, with content basically taking 2 steps forward 1 step back until the list completely stops. Locking the refresh-rate to 60Hz gets rid of that.

MANTENN commented 2 years ago

Apple's docs for enabling ProMotion on iPhone 13 Pro & iPad Pro. It seems it's as simple as adding this plist entry, although I don't have such a device to test whether or not it works with an RN app:

<key>CADisableMinimumFrameDurationOnPhone</key><true/>

I tried that and it doesn't work; I'm using react navigation and the transitions are choppy and don't appear smooth.

MANTENN commented 2 years ago

Apple's docs for enabling ProMotion on iPhone 13 Pro & iPad Pro. It seems it's as simple as adding this plist entry, although I don't have such a device to test whether or not it works with an RN app:

<key>CADisableMinimumFrameDurationOnPhone</key><true/>

I tried that and it doesn't work; I'm using react navigation and the transitions are choppy and don't appear smooth.

I'm also using react native reanimated and they aren't 120fps.

leejunhui commented 2 years ago

Now 14th March 2022, does react native support high refresh rate now?

billnbell commented 2 years ago

what is the latest status on CADisableMinimumFrameDurationOnPhone ?

mittallakshayy commented 2 years ago

Is there an update on this issue ?

okalil commented 2 years ago

Is there some fork that implements a solution?

kylegillen commented 2 years ago

Bump

Developeranees commented 2 years ago

BUMP

MrSimmmons commented 2 years ago

Discord just transitioned their android app over to react native, and this issue has absolutely ruined the app for all devices with high refresh rate screens. All animations within the app now just look awful and stutter so much. high refresh rate screens have been in phones for almost half a decade and are pretty main steam now days (its even in apple products now which is when you know the tech has matured enough to be truly main steam) so I'm surprised that this is not much higher in the TODO list for future versions. It really does make that much of a difference.

Developeranees commented 2 years ago

BUMP

mittallakshayy commented 2 years ago

BUMP

juliendeveloper commented 2 years ago

BUMP

SimpleCreations commented 2 years ago

I don't think spamming "bump" here is a good idea. Usually when there is a lot of spam in an issue, the maintainers close and lock it.

matapo commented 2 years ago

It seems that you can have 120fps with reanimated 2

https://github.com/software-mansion/react-native-reanimated/pull/2636

milksense commented 2 years ago

bump

djendacott commented 2 years ago

Is there any official comment on 120fps support?

It is now over 12 months since iOS implemented promotion, and our react native animations stutter and feel juttery and low quality in comparison to every native app.

Has react native hit a wall?

billnbell commented 2 years ago

Did you try it. It works

Get Outlook for iOShttps://aka.ms/o0ukef


From: djendacott @.> Sent: Thursday, October 13, 2022 6:03:16 PM To: facebook/react-native @.> Cc: William Bell @.>; Comment @.> Subject: Re: [facebook/react-native] React native does not support screen refresh rate (#29333)

Is there any official comment on 120fps support?

It is now over 12 months since iOS implemented promotion, and our react native animations stutter and feel juttery and low quality in comparison to every native app.

Has react native hit a wall?

— Reply to this email directly, view it on GitHubhttps://github.com/facebook/react-native/issues/29333#issuecomment-1278299430, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AGBTSQLO2LMUV6GPEFYFBL3WDCPMJANCNFSM4OWSXROA. You are receiving this because you commented.Message ID: @.***>

djendacott commented 2 years ago

What version of RN are you running?

Are you talking about Reanimated or are you saying that the built-in Animated library works for you at 120fps?

Norcy commented 1 year ago

bump

julientietkem commented 1 year ago

Any update?

wmonecke commented 1 year ago

meow

wmonecke commented 1 year ago

I am using Reanimated v3 but my app still runs at max 60fps with RN 0.72.2.

Has anyone been able to run RN at over 60fps?

darioarias commented 1 year ago

Still no updates?

atultiwaree commented 1 year ago

I tried running my app, in my device it runs on 120hz, while in some other devices it runs in default 60hz

devGuerra commented 10 months ago

some updates or plans to build it ?

fabOnReact commented 9 months ago

I can build it, but the issue is from 3 years ago. Somebody still interested in this issue?

https://github.com/facebook/react-native/issues/29333#issuecomment-931405279

michelle-chiang commented 9 months ago

Still very interested in this issue!

coder-xiaomo commented 8 months ago

It does not seem to be optimized on Android until the current version of 0.73.5.

I tried to create a new React Native project and run it on a real device, again up to 60 fps.

Anything new that can address this in the recent version?

By the way, I found that the Xiaohongshu(小红书) App in China can reach 120 fps, does anyone know how they did it?

lindboe commented 8 months ago

@fabOnReact if you're looking to work on this but need input, I believe the way forward would be to submit an RFC at https://github.com/react-native-community/discussions-and-proposals/, in case that's helpful.

muelsyse-az commented 4 months ago

Any status update on this?