Skip to content

Commit

Permalink
Revert the changes to idle timers made in facebook#26114
Browse files Browse the repository at this point in the history
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
  • Loading branch information
matt-oakes committed Jan 3, 2022
1 parent c68c47d commit 89e4666
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions React/CoreModules/RCTTiming.mm
Original file line number Diff line number Diff line change
Expand Up @@ -256,9 +256,9 @@ - (void)didUpdateFrame:(RCTFrameUpdate *)update
}

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

0 comments on commit 89e4666

Please sign in to comment.