Skip to content
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

fix: use proper timestamp in frameElapsed calculation #26114

Closed
wants to merge 1 commit into from

Conversation

aleclarson
Copy link
Contributor

Summary

Fix a bug where CACurrentMediaTime was being used to calculate the elapsed frame time, even though it's not comparable to NSDate.timeIntervalSince1970 time.

Changelog

[iOS] [Fixed] - callIdleCallbacks deadline calculation

Test Plan

None

@facebook-github-bot facebook-github-bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Aug 19, 2019
@react-native-bot react-native-bot added Bug Platform: iOS iOS applications. labels Aug 19, 2019
Copy link
Contributor

@cpojer cpojer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

Copy link
Contributor

@cpojer cpojer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

Copy link
Contributor

@facebook-github-bot facebook-github-bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@cpojer is landing this pull request. If you are a Facebook employee, you can view this diff on Phabricator.

@react-native-bot
Copy link
Collaborator

This pull request was successfully merged by @aleclarson in 021cbcc.

When will my fix make it into a release? | Upcoming Releases

@react-native-bot react-native-bot added the Merged This PR has been merged. label Sep 11, 2019
matt-oakes added a commit to matt-oakes/react-native that referenced this pull request Sep 10, 2020
This was causing issues with the window.requestIdleCallback timers as the timer code was expecting this "timestamp" property to be a unix timestamp in seconds which was causing the calculations to be done incorrectly and for the callbacks to never be called.

Fixes facebook#28602
matt-oakes added a commit to matt-oakes/react-native that referenced this pull request Jan 3, 2022
This was causing issues with the window.requestIdleCallback timers as the timer code was expecting this "timestamp" property to be a unix timestamp in seconds which was causing the calculations to be done incorrectly and for the callbacks to never be called.

Fixes facebook#28602
facebook-github-bot pushed a commit that referenced this pull request Jul 12, 2023
Summary:
Fixes #28602

When creating a `RCTFrameUpdate`, ensure it is created with the correct unix timestamp in seconds. This is needed to match the `NSTimeInterval` type defined in the header.

Previously, it was using the `CADisplayLink`'s `timestamp` property, which is not an `NSTimeInterval` but is instead a `CFTimeInterval` (note the different class prefix). This is the host time converted to seconds, which is the number of seconds since the device was turned on and therefore not a unix timestamp as expected.

This was causing issues with the `window.requestIdleCallback` timers as the timer code was expecting this `timestamp` property to be a unix timestamp in seconds which was causing the calculations to be done incorrectly and for the callbacks to never be called. The code does this calculation is here:

https://github.com/facebook/react-native/blob/4d920fe7c991eaec61d229a71df30b0f6c446d38/React/CoreModules/RCTTiming.mm#L262

As one of these is a valid unix timestamp and the other is a much smaller number (number of seconds since device turn on), the `if` statement following this calculation never passes and the callbacks are never called.

This regression seems to have been introduced with this pull request: #26114

## Changelog

<!-- Help reviewers and the release process by writing your own changelog entry. For an example, see:
https://github.com/facebook/react-native/wiki/Changelog
-->

[iOS] [Fixed] - Fixed window.requestIdleCallback not firing on iOS

Pull Request resolved: #29895

Test Plan: I have tested this by patching my React Native code and testing that idle callbacks are correctly called. There is a reproduction case of the issue in the linked issue.

Reviewed By: NickGerleman

Differential Revision: D47381404

Pulled By: sammy-SC

fbshipit-source-id: fd166741889b0084e1def8dedf6e4018adfd570f
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. Merged This PR has been merged. Platform: iOS iOS applications.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants