From 22d8635518b96b6d22b244bab1cc96d7e2121554 Mon Sep 17 00:00:00 2001 From: Matt Oakes Date: Tue, 8 Sep 2020 17:46:31 +0100 Subject: [PATCH] Revert the changes to idle timers made in #26114 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 #28602 --- React/CoreModules/RCTTiming.mm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/React/CoreModules/RCTTiming.mm b/React/CoreModules/RCTTiming.mm index 7517771008649f..e72177216f5f29 100644 --- a/React/CoreModules/RCTTiming.mm +++ b/React/CoreModules/RCTTiming.mm @@ -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];