-
Notifications
You must be signed in to change notification settings - Fork 25.2k
feat: support 120fps for Animated #51775
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -441,6 +441,7 @@ - (void)startAnimationLoopIfNeeded | |
| { | ||
| if (!_displayLink && _activeAnimations.count > 0) { | ||
| _displayLink = [CADisplayLink displayLinkWithTarget:self selector:@selector(stepAnimations:)]; | ||
| _displayLink.preferredFramesPerSecond = [UIScreen mainScreen].maximumFramesPerSecond; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This needs the same feature flag gating |
||
| [_displayLink addToRunLoop:[NSRunLoop mainRunLoop] forMode:NSRunLoopCommonModes]; | ||
| } | ||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -100,7 +100,8 @@ - (void)onTick:(NSTimeInterval)timestamp | |
| }); | ||
|
|
||
| CGFloat previousScale = _scale; | ||
| CGFloat targetFps = MAX(_maxFPS, 60.0); | ||
| CGFloat screenRefreshRate = [UIScreen mainScreen].maximumFramesPerSecond; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This should be the current refresh rate, otherwise we. may be giving a wrong signal
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This should be a separate PR |
||
| CGFloat targetFps = MAX(_maxFPS, screenRefreshRate); | ||
| _scale = targetFps / (CGFloat)_height; | ||
| for (NSUInteger i = 0; i < _length - 1; i++) { | ||
| // Move each Frame back one position and adjust to new scale (if there is a new scale) | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -10,6 +10,20 @@ package com.facebook.react.animated | |
| import com.facebook.react.bridge.Callback | ||
| import com.facebook.react.bridge.JSApplicationCausedNativeException | ||
| import com.facebook.react.bridge.ReadableMap | ||
| import com.facebook.react.internal.featureflags.ReactNativeFeatureFlags | ||
| import android.content.Context | ||
| import android.view.WindowManager | ||
|
|
||
| public fun getSingleFrameInterval(context: Context): Double { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Let's do Android in a separate PR |
||
| if (ReactNativeFeatureFlags.disableHighRefreshRateAnimations()) { | ||
| return 60.0 | ||
| } | ||
|
|
||
| val windowManager = context.getSystemService(Context.WINDOW_SERVICE) as WindowManager | ||
|
|
||
| val refreshRate = windowManager.defaultDisplay.supportedRefreshRates.maxOrNull() | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
| return refreshRate?.toDouble() ?: 60.0 | ||
| } | ||
|
|
||
| /** | ||
| * Base class for different types of animation drivers. Can be used to implement simple time-based | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@cortinico @cipolleschi Can you help me understand why are there two turbo modules for animated? I found one is working only for iOS and one only for Android.. Not sure which one I should use
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's use NativeAnimatedHelper for this.