From 021cbccbf29265f9e4353c79408dacc6a30f8f4f Mon Sep 17 00:00:00 2001 From: Alec Larson Date: Wed, 11 Sep 2019 04:52:33 -0700 Subject: [PATCH] fix: use proper timestamp in frameElapsed calculation (#26114) 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: https://github.com/facebook/react-native/pull/26114 Test Plan: None Differential Revision: D17314125 Pulled By: cpojer fbshipit-source-id: 5061a3954371df2134f0c77dc260228668abe747 --- React/Modules/RCTTiming.m | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/React/Modules/RCTTiming.m b/React/Modules/RCTTiming.m index bfc31c63f78dfc..893ecb537c8731 100644 --- a/React/Modules/RCTTiming.m +++ b/React/Modules/RCTTiming.m @@ -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"