From 89e4666ee652e542d08af5684ad711f2e3265f71 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 13d0d57296bbba..6065006b8eb281 100644 --- a/React/CoreModules/RCTTiming.mm +++ b/React/CoreModules/RCTTiming.mm @@ -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];