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 Sep 10, 2020
1 parent d6fef50 commit 22d8635
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 @@ -258,9 +258,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 22d8635

Please sign in to comment.