From 1cf745613390e5ce87b72e09016c42784cb0566a Mon Sep 17 00:00:00 2001 From: Lorenzo Blasa Date: Fri, 11 Jun 2021 10:31:19 -0700 Subject: [PATCH] Flipper Network Plugin change timestamps source Summary: Flipper Network plugin uses timestamps for various usages e.g. start time of network requests, request duration, etc. This diff changes the origin of such timestamps. [NSDate timeIntervalSinceReferenceDate] in favour of FBMonotonicDeviceTimeGetCurrentMilliseconds(). The former uses a timestamp based on date. The latter uses the system boot time. This translates in errors when the Flipper Desktop app tries to make sense of such timestamps. This change also adds parity with the Android network plugin that uses System.currentTimeMillis(). The result is multiplied by 1000 as JavaScript expects a timestamp in millseconds. Reviewed By: fabiomassimo Differential Revision: D29029192 fbshipit-source-id: b38a4798ecf1564f5801ff3549ffeb9671fa32d6 --- .../FLEXNetworkLib/FLEXUtility.h | 3 ++- .../FLEXNetworkLib/FLEXUtility.mm | 17 +++-------------- 2 files changed, 5 insertions(+), 15 deletions(-) diff --git a/iOS/Plugins/FlipperKitNetworkPlugin/SKIOSNetworkPlugin/FLEXNetworkLib/FLEXUtility.h b/iOS/Plugins/FlipperKitNetworkPlugin/SKIOSNetworkPlugin/FLEXNetworkLib/FLEXUtility.h index 318d34de95e..3854c6168bb 100755 --- a/iOS/Plugins/FlipperKitNetworkPlugin/SKIOSNetworkPlugin/FLEXNetworkLib/FLEXUtility.h +++ b/iOS/Plugins/FlipperKitNetworkPlugin/SKIOSNetworkPlugin/FLEXNetworkLib/FLEXUtility.h @@ -19,7 +19,8 @@ @interface NSDate (SonarUtility) -+ (uint64_t)timestamp; ++ (NSTimeInterval)timestamp; + @end @interface FLEXUtility : NSObject diff --git a/iOS/Plugins/FlipperKitNetworkPlugin/SKIOSNetworkPlugin/FLEXNetworkLib/FLEXUtility.mm b/iOS/Plugins/FlipperKitNetworkPlugin/SKIOSNetworkPlugin/FLEXNetworkLib/FLEXUtility.mm index c0a714ef4a8..55dbdde3443 100755 --- a/iOS/Plugins/FlipperKitNetworkPlugin/SKIOSNetworkPlugin/FLEXNetworkLib/FLEXUtility.mm +++ b/iOS/Plugins/FlipperKitNetworkPlugin/SKIOSNetworkPlugin/FLEXNetworkLib/FLEXUtility.mm @@ -110,20 +110,9 @@ + (NSNumber*)random { @implementation NSDate (SonarUtility) -+ (uint64_t)getTimeNanoseconds { - static struct mach_timebase_info tb_info = {0}; - static dispatch_once_t onceToken; - dispatch_once(&onceToken, ^{ - __unused int ret = mach_timebase_info(&tb_info); - assert(0 == ret); - }); - - return (mach_absolute_time() * tb_info.numer) / tb_info.denom; -} - -+ (uint64_t)timestamp { - const uint64_t nowNanoSeconds = [self getTimeNanoseconds]; - return nowNanoSeconds / 1000000; ++ (NSTimeInterval)timestamp { + const NSTimeInterval timestamp = [[NSDate date] timeIntervalSince1970]; + return timestamp * 1000; } @end