Skip to content

Commit afaa522

Browse files
authored
Convert SentryScreenFrames to Swift (#6094)
* Convert `SentryScreenFrames` to Swift * Fix build on watchOS * Import SentryDefines * Fix build error on `iOS-Swift` * Add @_spi(Private) to `SentryFrameInfoTimeSeries` * Fix build on Xcode 14 * Fix Typo * Use fixed branch * Fix `SentryScreenFrames` copy method * PR comment foxes * Bump size to 955KB
1 parent 705b962 commit afaa522

File tree

21 files changed

+640
-193
lines changed

21 files changed

+640
-193
lines changed

.github/workflows/test-cross-platform.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ jobs:
5555
with:
5656
repository: getsentry/sentry-react-native
5757
path: sentry-react-native
58+
ref: itay/fix_sentreyscreenframes
5859

5960
- name: Enable Corepack
6061
working-directory: sentry-react-native

Samples/iOS-Swift/iOS-Swift/ExtraViewController.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import AuthenticationServices
33
import Foundation
44
import SafariServices
5-
import Sentry
5+
@_spi(Private) import Sentry
66
import SentrySampleShared
77
import UIKit
88

Sentry.xcodeproj/project.pbxproj

Lines changed: 24 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -425,8 +425,6 @@
425425
7B72D23A28D074BC0014798A /* TestExtensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7B72D23928D074BC0014798A /* TestExtensions.swift */; };
426426
7B77BE3527EC8445003C9020 /* SentryDiscardReasonMapper.h in Headers */ = {isa = PBXBuildFile; fileRef = 7B77BE3427EC8445003C9020 /* SentryDiscardReasonMapper.h */; };
427427
7B77BE3727EC8460003C9020 /* SentryDiscardReasonMapper.m in Sources */ = {isa = PBXBuildFile; fileRef = 7B77BE3627EC8460003C9020 /* SentryDiscardReasonMapper.m */; };
428-
7B7A599526B692540060A676 /* SentryScreenFrames.h in Headers */ = {isa = PBXBuildFile; fileRef = 7B7A599426B692540060A676 /* SentryScreenFrames.h */; settings = {ATTRIBUTES = (Private, ); }; };
429-
7B7A599726B692F00060A676 /* SentryScreenFrames.m in Sources */ = {isa = PBXBuildFile; fileRef = 7B7A599626B692F00060A676 /* SentryScreenFrames.m */; };
430428
7B7D872C2486480B00D2ECFF /* SentryStacktraceBuilder.h in Headers */ = {isa = PBXBuildFile; fileRef = 7B7D872B2486480B00D2ECFF /* SentryStacktraceBuilder.h */; };
431429
7B7D872E2486482600D2ECFF /* SentryStacktraceBuilder.m in Sources */ = {isa = PBXBuildFile; fileRef = 7B7D872D2486482600D2ECFF /* SentryStacktraceBuilder.m */; };
432430
7B7D8730248648AD00D2ECFF /* SentryStacktraceBuilderTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7B7D872F248648AD00D2ECFF /* SentryStacktraceBuilderTests.swift */; };
@@ -981,6 +979,10 @@
981979
F429D3AA2E8562EF00DBF387 /* RateLimitParser.swift in Sources */ = {isa = PBXBuildFile; fileRef = F429D3A82E8562EF00DBF387 /* RateLimitParser.swift */; };
982980
F443DB272E09BE8C009A9045 /* LoadValidatorTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = F443DB262E09BE8C009A9045 /* LoadValidatorTests.swift */; };
983981
F44858132E03579D0013E63B /* SentryCrashDynamicLinker+Test.h in Headers */ = {isa = PBXBuildFile; fileRef = F44858122E0357940013E63B /* SentryCrashDynamicLinker+Test.h */; };
982+
F44D2B592E6B779E00FF31FA /* SentryScreenFrames.swift in Sources */ = {isa = PBXBuildFile; fileRef = F44D2B582E6B779E00FF31FA /* SentryScreenFrames.swift */; };
983+
F44D2B5C2E6B7E8700FF31FA /* SentryProfilingScreenFramesHelper.h in Headers */ = {isa = PBXBuildFile; fileRef = F44D2B5A2E6B7E8700FF31FA /* SentryProfilingScreenFramesHelper.h */; };
984+
F44D2B5D2E6B7E8700FF31FA /* SentryProfilingScreenFramesHelper.m in Sources */ = {isa = PBXBuildFile; fileRef = F44D2B5B2E6B7E8700FF31FA /* SentryProfilingScreenFramesHelper.m */; };
985+
F44D2B602E6B829F00FF31FA /* SentryScreenFramesTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = F44D2B5F2E6B829F00FF31FA /* SentryScreenFramesTests.swift */; };
984986
F451FAA62E0B304E0050ACF2 /* LoadValidator.swift in Sources */ = {isa = PBXBuildFile; fileRef = F451FAA52E0B304E0050ACF2 /* LoadValidator.swift */; };
985987
F452437E2DE60B71003E8F50 /* SentryUseNSExceptionCallstackWrapper.m in Sources */ = {isa = PBXBuildFile; fileRef = F452437D2DE60B71003E8F50 /* SentryUseNSExceptionCallstackWrapper.m */; };
986988
F45243882DE65968003E8F50 /* ExceptionCatcher.m in Sources */ = {isa = PBXBuildFile; fileRef = F45243872DE65968003E8F50 /* ExceptionCatcher.m */; };
@@ -1683,8 +1685,6 @@
16831685
7B77BE3427EC8445003C9020 /* SentryDiscardReasonMapper.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = SentryDiscardReasonMapper.h; path = include/SentryDiscardReasonMapper.h; sourceTree = "<group>"; };
16841686
7B77BE3627EC8460003C9020 /* SentryDiscardReasonMapper.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = SentryDiscardReasonMapper.m; sourceTree = "<group>"; };
16851687
7B7A30C924B48523005A4C6E /* SentryHub+Test.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "SentryHub+Test.h"; sourceTree = "<group>"; };
1686-
7B7A599426B692540060A676 /* SentryScreenFrames.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = SentryScreenFrames.h; path = include/HybridPublic/SentryScreenFrames.h; sourceTree = "<group>"; };
1687-
7B7A599626B692F00060A676 /* SentryScreenFrames.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = SentryScreenFrames.m; sourceTree = "<group>"; };
16881688
7B7D872B2486480B00D2ECFF /* SentryStacktraceBuilder.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = SentryStacktraceBuilder.h; path = include/SentryStacktraceBuilder.h; sourceTree = "<group>"; };
16891689
7B7D872D2486482600D2ECFF /* SentryStacktraceBuilder.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = SentryStacktraceBuilder.m; sourceTree = "<group>"; };
16901690
7B7D872F248648AD00D2ECFF /* SentryStacktraceBuilderTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SentryStacktraceBuilderTests.swift; sourceTree = "<group>"; };
@@ -2319,6 +2319,10 @@
23192319
F429D3A82E8562EF00DBF387 /* RateLimitParser.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RateLimitParser.swift; sourceTree = "<group>"; };
23202320
F443DB262E09BE8C009A9045 /* LoadValidatorTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LoadValidatorTests.swift; sourceTree = "<group>"; };
23212321
F44858122E0357940013E63B /* SentryCrashDynamicLinker+Test.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "SentryCrashDynamicLinker+Test.h"; sourceTree = "<group>"; };
2322+
F44D2B582E6B779E00FF31FA /* SentryScreenFrames.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SentryScreenFrames.swift; sourceTree = "<group>"; };
2323+
F44D2B5A2E6B7E8700FF31FA /* SentryProfilingScreenFramesHelper.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SentryProfilingScreenFramesHelper.h; sourceTree = "<group>"; };
2324+
F44D2B5B2E6B7E8700FF31FA /* SentryProfilingScreenFramesHelper.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = SentryProfilingScreenFramesHelper.m; sourceTree = "<group>"; };
2325+
F44D2B5F2E6B829F00FF31FA /* SentryScreenFramesTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SentryScreenFramesTests.swift; sourceTree = "<group>"; };
23222326
F451FAA52E0B304E0050ACF2 /* LoadValidator.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LoadValidator.swift; sourceTree = "<group>"; };
23232327
F452437D2DE60B71003E8F50 /* SentryUseNSExceptionCallstackWrapper.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = SentryUseNSExceptionCallstackWrapper.m; sourceTree = "<group>"; };
23242328
F45243862DE65968003E8F50 /* ExceptionCatcher.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ExceptionCatcher.h; sourceTree = "<group>"; };
@@ -2620,6 +2624,7 @@
26202624
62872B602BA1B84400A4FA7D /* Swift */ = {
26212625
isa = PBXGroup;
26222626
children = (
2627+
F44D2B612E6B82A800FF31FA /* Profiling */,
26232628
F443DB242E09BE61009A9045 /* Core */,
26242629
62872B612BA1B84C00A4FA7D /* Extensions */,
26252630
);
@@ -3661,8 +3666,6 @@
36613666
7B6C5EDB264E8DA80010D138 /* SentryFramesTrackingIntegration.m */,
36623667
7B6C5EDF264E8E050010D138 /* SentryFramesTracker.h */,
36633668
7B6C5EDD264E8DF00010D138 /* SentryFramesTracker.m */,
3664-
7B7A599426B692540060A676 /* SentryScreenFrames.h */,
3665-
7B7A599626B692F00060A676 /* SentryScreenFrames.m */,
36663669
62862B1B2B1DDBC8009B16E3 /* SentryDelayedFrame.h */,
36673670
62862B1D2B1DDC35009B16E3 /* SentryDelayedFrame.m */,
36683671
62C316802B1F2E93000D7031 /* SentryDelayedFramesTracker.h */,
@@ -3899,6 +3902,8 @@
38993902
8459FCC12BD73EEF0038E9C9 /* SentryProfilerSerialization+Test.h */,
39003903
84AF45A429A7FFA500FBB177 /* SentryProfiledTracerConcurrency.h */,
39013904
84AF45A529A7FFA500FBB177 /* SentryProfiledTracerConcurrency.mm */,
3905+
F44D2B5A2E6B7E8700FF31FA /* SentryProfilingScreenFramesHelper.h */,
3906+
F44D2B5B2E6B7E8700FF31FA /* SentryProfilingScreenFramesHelper.m */,
39023907
840B7EF22BBF83DF008B8120 /* SentryProfiler+Private.h */,
39033908
84A898522E163072009A551E /* SentryProfileConfiguration.h */,
39043909
84A898532E163072009A551E /* SentryProfileConfiguration.m */,
@@ -4724,6 +4729,14 @@
47244729
path = Tools;
47254730
sourceTree = "<group>";
47264731
};
4732+
F44D2B612E6B82A800FF31FA /* Profiling */ = {
4733+
isa = PBXGroup;
4734+
children = (
4735+
F44D2B5F2E6B829F00FF31FA /* SentryScreenFramesTests.swift */,
4736+
);
4737+
path = Profiling;
4738+
sourceTree = "<group>";
4739+
};
47274740
F474CB872E2EC5040001DF41 /* Recovered References */ = {
47284741
isa = PBXGroup;
47294742
children = (
@@ -4788,6 +4801,7 @@
47884801
FA67DCD22DDBD4EA00896B02 /* FramesTracking */ = {
47894802
isa = PBXGroup;
47904803
children = (
4804+
F44D2B582E6B779E00FF31FA /* SentryScreenFrames.swift */,
47914805
FA67DCD12DDBD4EA00896B02 /* SentryFramesDelayResult.swift */,
47924806
);
47934807
path = FramesTracking;
@@ -5041,6 +5055,7 @@
50415055
6383953623ABA42C000C1594 /* SentryHttpTransport.h in Headers */,
50425056
84A8891C28DBD28900C51DFD /* SentryDevice.h in Headers */,
50435057
8E564AEF267AF24400FE117D /* SentryNetworkTracker.h in Headers */,
5058+
F44D2B5C2E6B7E8700FF31FA /* SentryProfilingScreenFramesHelper.h in Headers */,
50445059
63FE715120DA4C1100CDBAE8 /* SentryCrashDebug.h in Headers */,
50455060
63FE70F520DA4C1000CDBAE8 /* SentryCrashMonitor_System.h in Headers */,
50465061
FAB359982E05D7E90083D5E3 /* SentryEventSwiftHelper.h in Headers */,
@@ -5141,7 +5156,6 @@
51415156
7BA61CAB247BA98100C130A8 /* SentryDebugImageProvider.h in Headers */,
51425157
7BC63F0828081242009D9E37 /* SentrySwizzleWrapper.h in Headers */,
51435158
638DC9A01EBC6B6400A66E41 /* SentryRequestOperation.h in Headers */,
5144-
7B7A599526B692540060A676 /* SentryScreenFrames.h in Headers */,
51455159
6344DDB01EC308E400D9160D /* SentryCrashInstallationReporter.h in Headers */,
51465160
7B5CAF7527F5A67C00ED0DB6 /* SentryNSURLRequestBuilder.h in Headers */,
51475161
63FE70ED20DA4C1000CDBAE8 /* SentryCrashMonitor_NSException.h in Headers */,
@@ -5558,7 +5572,6 @@
55585572
D84D2CDF2C2BF9370011AF8A /* SentryReplayType.swift in Sources */,
55595573
63FE717B20DA4C1100CDBAE8 /* SentryCrashReport.c in Sources */,
55605574
D8F67B222BEAB6CC00C9197B /* SentryRRWebEvent.swift in Sources */,
5561-
7B7A599726B692F00060A676 /* SentryScreenFrames.m in Sources */,
55625575
84A903712D39F66F00690CE4 /* SentryUserFeedbackFormViewModel.swift in Sources */,
55635576
7B3398652459C15200BD9C96 /* SentryEnvelopeRateLimit.m in Sources */,
55645577
D81988C92BEC19200020E36C /* SentryRRWebBreadcrumbEvent.swift in Sources */,
@@ -5698,6 +5711,7 @@
56985711
627C77892D50B6840055E966 /* SentryBreadcrumbCodable.swift in Sources */,
56995712
63FE70D720DA4C1000CDBAE8 /* SentryCrashMonitor_MachException.c in Sources */,
57005713
7B96572226830D2400C66E25 /* SentryScopeSyncC.c in Sources */,
5714+
F44D2B5D2E6B7E8700FF31FA /* SentryProfilingScreenFramesHelper.m in Sources */,
57015715
0A9BF4E228A114940068D266 /* SentryViewHierarchyIntegration.m in Sources */,
57025716
D8AFC03D2BDA79BF00118BE1 /* SentryReplayVideoMaker.swift in Sources */,
57035717
840A11122B61E27500650D02 /* SentrySamplerDecision.m in Sources */,
@@ -5792,6 +5806,7 @@
57925806
A8F17B2E2901765900990B25 /* SentryRequest.m in Sources */,
57935807
FABE8E172E307A7F0040809A /* Dependencies.swift in Sources */,
57945808
D4ECA4012E3CBEDE00C757EA /* SentryDummyPublicEmptyClass.m in Sources */,
5809+
F44D2B592E6B779E00FF31FA /* SentryScreenFrames.swift in Sources */,
57955810
D4ECA4022E3CBEDE00C757EA /* SentryDummyPrivateEmptyClass.m in Sources */,
57965811
D80299502BA83A88000F0081 /* SentryPixelBuffer.swift in Sources */,
57975812
15E0A8F22411A45A00F044E3 /* SentrySessionInternal.m in Sources */,
@@ -6229,6 +6244,7 @@
62296244
D884A20527C80F6300074664 /* SentryCoreDataTrackerTest.swift in Sources */,
62306245
8E70B10125CB8695002B3155 /* SentrySpanIdTests.swift in Sources */,
62316246
62E2119A2DAE99FC007D7262 /* SentryAsyncSafeLog.m in Sources */,
6247+
F44D2B602E6B829F00FF31FA /* SentryScreenFramesTests.swift in Sources */,
62326248
84EB21962BF01CEA00EDDA28 /* SentryCrashInstallationTests.swift in Sources */,
62336249
7BFE7A0A27A1B6B000D2B66E /* SentryWatchdogTerminationTrackingIntegrationTests.swift in Sources */,
62346250
D8292D7D2A39A027009872F7 /* UrlSanitizedTests.swift in Sources */,

SentryTestUtils/TestFramesTracker.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
import Sentry
1+
@_spi(Private) @testable import Sentry
22

33
#if os(iOS) || os(tvOS) || targetEnvironment(macCatalyst)
44
public class TestFramesTracker: SentryFramesTracker {
5-
public var expectedFrames: SentryScreenFrames?
5+
@_spi(Private) public var expectedFrames: SentryScreenFrames?
66

7-
public override func currentFrames() -> SentryScreenFrames {
7+
@_spi(Private) public override func currentFrames() -> SentryScreenFrames {
88
expectedFrames ?? super.currentFrames()
99
}
1010
}

Sources/Resources/Sentry.modulemap

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ framework module Sentry {
1515
header "SentryFormatter.h"
1616
header "SentryFramesTracker.h"
1717
header "SentryOptionsInternal.h"
18-
header "SentryScreenFrames.h"
1918
header "SentrySwizzle.h"
2019
header "SentryUser+Private.h"
2120

Sources/Sentry/Profiling/SentryContinuousProfiler.mm

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,14 @@
99
# import "SentryProfiler+Private.h"
1010
# import "SentryProfilerSerialization.h"
1111
# import "SentryProfilerState.h"
12+
# import "SentryProfilingScreenFramesHelper.h"
1213
# import "SentryProfilingSwiftHelpers.h"
1314
# import "SentrySDK+Private.h"
1415
# import "SentrySample.h"
1516
# include <mutex>
1617

1718
# if SENTRY_HAS_UIKIT
1819
# import "SentryFramesTracker.h"
19-
# import "SentryScreenFrames.h"
2020
# import <UIKit/UIKit.h>
2121
# endif // SENTRY_HAS_UIKIT
2222

@@ -72,7 +72,8 @@
7272

7373
# if SENTRY_HAS_UIKIT
7474
const auto framesTracker = SentryDependencyContainer.sharedInstance.framesTracker;
75-
SentryScreenFrames *screenFrameData = [framesTracker.currentFrames copy];
75+
SentryScreenFrames *screenFrameData =
76+
[SentryProfilingScreenFramesHelper copyScreenFrames:framesTracker.currentFrames];
7677
[framesTracker resetProfilingTimestamps];
7778
# endif // SENTRY_HAS_UIKIT
7879

Sources/Sentry/Profiling/SentryProfiledTracerConcurrency.mm

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
# if SENTRY_HAS_UIKIT
3131
# import "SentryAppStartMeasurement.h"
3232
# import "SentryFramesTracker.h"
33-
# import "SentryScreenFrames.h"
33+
# import "SentryProfilingScreenFramesHelper.h"
3434
# endif // SENTRY_HAS_UIKIT
3535

3636
/**
@@ -237,8 +237,8 @@
237237
_unsafe_cleanUpTraceProfiler(profiler, tracerKey);
238238

239239
# if SENTRY_HAS_UIKIT
240-
profiler.screenFrameData =
241-
[SentryDependencyContainer.sharedInstance.framesTracker.currentFrames copy];
240+
profiler.screenFrameData = [SentryProfilingScreenFramesHelper
241+
copyScreenFrames:SentryDependencyContainer.sharedInstance.framesTracker.currentFrames];
242242
SENTRY_LOG_DEBUG(
243243
@"Grabbing copy of frames tracker screen frames data to attach to profiler: %@.",
244244
profiler.screenFrameData);
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#import "SentryDefines.h"
2+
#import <Foundation/Foundation.h>
3+
4+
#if SENTRY_HAS_UIKIT
5+
6+
NS_ASSUME_NONNULL_BEGIN
7+
8+
@class SentryScreenFrames;
9+
10+
// Helper to use SentryScreenFrames without importing Swift on ObjC++ files.
11+
// Right now we don't have Clang modules enabled, so we cannot use `@import Sentry;`
12+
// and then no Swift class is visible to Objective C++.
13+
@interface SentryProfilingScreenFramesHelper : NSObject
14+
+ (SentryScreenFrames *)copyScreenFrames:(SentryScreenFrames *)screenFrames;
15+
@end
16+
17+
NS_ASSUME_NONNULL_END
18+
19+
#endif // SENTRY_HAS_UIKIT
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#import "SentryProfilingScreenFramesHelper.h"
2+
#import "SentrySwift.h"
3+
4+
#if SENTRY_HAS_UIKIT
5+
6+
@implementation SentryProfilingScreenFramesHelper
7+
8+
+ (SentryScreenFrames *)copyScreenFrames:(SentryScreenFrames *)screenFrames
9+
{
10+
return [screenFrames copy];
11+
}
12+
13+
@end
14+
15+
#endif // SENTRY_HAS_UIKIT

Sources/Sentry/SentryFramesTracker.m

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
# import "SentrySwift.h"
1313
# import "SentryTime.h"
1414
# import "SentryTracer.h"
15-
# import <SentryScreenFrames.h>
1615
# include <stdatomic.h>
1716

1817
# if SENTRY_TARGET_PROFILING_SUPPORTED

0 commit comments

Comments
 (0)