Skip to content

Commit

Permalink
fix: use proper timestamp in frameElapsed calculation (#26114)
Browse files Browse the repository at this point in the history
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
Pull Request resolved: #26114

Test Plan: None

Differential Revision: D17314125

Pulled By: cpojer

fbshipit-source-id: 5061a3954371df2134f0c77dc260228668abe747
  • Loading branch information
aleclarson authored and facebook-github-bot committed Sep 11, 2019
1 parent 9bc803f commit 021cbcc
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions React/Modules/RCTTiming.m
Expand Up @@ -268,9 +268,9 @@ - (void)didUpdateFrame:(RCTFrameUpdate *)update
}

if (_sendIdleEvents) {
NSTimeInterval frameElapsed = (CACurrentMediaTime() - update.timestamp);
NSTimeInterval currentTimestamp = [[NSDate date] timeIntervalSince1970];
NSTimeInterval frameElapsed = currentTimestamp - update.timestamp;
if (kFrameDuration - frameElapsed >= kIdleCallbackFrameDeadline) {
NSTimeInterval currentTimestamp = [[NSDate date] timeIntervalSince1970];
NSNumber *absoluteFrameStartMS = @((currentTimestamp - frameElapsed) * 1000);
[_bridge enqueueJSCall:@"JSTimers"
method:@"callIdleCallbacks"
Expand Down

0 comments on commit 021cbcc

Please sign in to comment.