-
-
Notifications
You must be signed in to change notification settings - Fork 360
Expand file tree
/
Copy pathSentryScreenFramesWrapper.m
More file actions
74 lines (58 loc) · 2.17 KB
/
SentryScreenFramesWrapper.m
File metadata and controls
74 lines (58 loc) · 2.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#import "SentryScreenFramesWrapper.h"
@import Sentry;
#if TARGET_OS_IPHONE || TARGET_OS_MACCATALYST
@implementation SentryScreenFramesWrapper
+ (BOOL)canTrackFrames
{
return PrivateSentrySDKOnly.currentScreenFrames != nil;
}
+ (NSNumber *)totalFrames
{
if (![self canTrackFrames]) {
return nil;
}
return [NSNumber numberWithLong:PrivateSentrySDKOnly.currentScreenFrames.total];
}
+ (NSNumber *)frozenFrames
{
if (![self canTrackFrames]) {
return nil;
}
return [NSNumber numberWithLong:PrivateSentrySDKOnly.currentScreenFrames.frozen];
}
+ (NSNumber *)slowFrames
{
if (![self canTrackFrames]) {
return nil;
}
return [NSNumber numberWithLong:PrivateSentrySDKOnly.currentScreenFrames.slow];
}
+ (NSNumber *)framesDelayForStartTimestamp:(double)startTimestampSeconds
endTimestamp:(double)endTimestampSeconds
{
SentryFramesTracker *framesTracker = [[SentryDependencyContainer sharedInstance] framesTracker];
if (!framesTracker.isRunning) {
return nil;
}
id<SentryCurrentDateProvider> dateProvider =
[SentryDependencyContainer sharedInstance].dateProvider;
uint64_t currentSystemTime = [dateProvider systemTime];
NSTimeInterval currentWallClock = [[dateProvider date] timeIntervalSince1970];
double startOffsetSeconds = currentWallClock - startTimestampSeconds;
double endOffsetSeconds = currentWallClock - endTimestampSeconds;
if (startOffsetSeconds < 0 || endOffsetSeconds < 0
|| (uint64_t)(startOffsetSeconds * 1e9) > currentSystemTime
|| (uint64_t)(endOffsetSeconds * 1e9) > currentSystemTime) {
return nil;
}
uint64_t startSystemTime = currentSystemTime - (uint64_t)(startOffsetSeconds * 1e9);
uint64_t endSystemTime = currentSystemTime - (uint64_t)(endOffsetSeconds * 1e9);
SentryFramesDelayResultSPI *result = [framesTracker getFramesDelaySPI:startSystemTime
endSystemTimestamp:endSystemTime];
if (result != nil && result.delayDuration >= 0) {
return @(result.delayDuration);
}
return nil;
}
@end
#endif // TARGET_OS_IPHONE || TARGET_OS_MACCATALYST