Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 12 additions & 8 deletions Sentry.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -387,8 +387,6 @@
7B68D93625FF5F1A0082D139 /* SentryAppState+Equality.m in Sources */ = {isa = PBXBuildFile; fileRef = 7B68D93525FF5F1A0082D139 /* SentryAppState+Equality.m */; };
7B6ADFCF26A02CAE0076C206 /* SentryCrashReportTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7B6ADFCE26A02CAE0076C206 /* SentryCrashReportTests.swift */; };
7B6C5ED6264E62CA0010D138 /* SentryTransactionTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7B6C5ED5264E62CA0010D138 /* SentryTransactionTests.swift */; };
7B6C5EDA264E8D860010D138 /* SentryFramesTrackingIntegration.h in Headers */ = {isa = PBXBuildFile; fileRef = 7B6C5ED9264E8D860010D138 /* SentryFramesTrackingIntegration.h */; };
7B6C5EDC264E8DA80010D138 /* SentryFramesTrackingIntegration.m in Sources */ = {isa = PBXBuildFile; fileRef = 7B6C5EDB264E8DA80010D138 /* SentryFramesTrackingIntegration.m */; };
7B6C5F8126034354007F7DFF /* SentryWatchdogTerminationLogic.h in Headers */ = {isa = PBXBuildFile; fileRef = 7B6C5F8026034354007F7DFF /* SentryWatchdogTerminationLogic.h */; };
7B6C5F8726034395007F7DFF /* SentryWatchdogTerminationLogic.m in Sources */ = {isa = PBXBuildFile; fileRef = 7B6C5F8626034395007F7DFF /* SentryWatchdogTerminationLogic.m */; };
7B6CC50224EE5A42001816D7 /* SentryHubTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7B6CC50124EE5A42001816D7 /* SentryHubTests.swift */; };
Expand Down Expand Up @@ -1017,6 +1015,7 @@
F4EF69232E95ABE800B6B46A /* SentryCrashMachineContextTests.m in Sources */ = {isa = PBXBuildFile; fileRef = F4EF69222E95ABE800B6B46A /* SentryCrashMachineContextTests.m */; };
F4FE86BD2EECAC31003D845F /* SentryScreenshotOptions.swift in Sources */ = {isa = PBXBuildFile; fileRef = F4FE86BB2EECAC31003D845F /* SentryScreenshotOptions.swift */; };
F4FE86BE2EECAC31003D845F /* SentryScreenshotIntegration.swift in Sources */ = {isa = PBXBuildFile; fileRef = F4FE86BA2EECAC31003D845F /* SentryScreenshotIntegration.swift */; };
F4FE86C72EECBEBA003D845F /* SentryFramesTrackingIntegration.swift in Sources */ = {isa = PBXBuildFile; fileRef = F4FE86C52EECBEBA003D845F /* SentryFramesTrackingIntegration.swift */; };
F4FE9DBD2E621F100014FED5 /* SentryRandom.swift in Sources */ = {isa = PBXBuildFile; fileRef = F4FE9DBC2E621F100014FED5 /* SentryRandom.swift */; };
F4FE9DFD2E622CD70014FED5 /* SentryDefaultObjCRuntimeWrapper.swift in Sources */ = {isa = PBXBuildFile; fileRef = F4FE9DFB2E622CD70014FED5 /* SentryDefaultObjCRuntimeWrapper.swift */; };
F4FE9DFE2E622CD70014FED5 /* SentryObjCRuntimeWrapper.swift in Sources */ = {isa = PBXBuildFile; fileRef = F4FE9DFC2E622CD70014FED5 /* SentryObjCRuntimeWrapper.swift */; };
Expand Down Expand Up @@ -1701,8 +1700,6 @@
7B68D93525FF5F1A0082D139 /* SentryAppState+Equality.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = "SentryAppState+Equality.m"; sourceTree = "<group>"; };
7B6ADFCE26A02CAE0076C206 /* SentryCrashReportTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SentryCrashReportTests.swift; sourceTree = "<group>"; };
7B6C5ED5264E62CA0010D138 /* SentryTransactionTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SentryTransactionTests.swift; sourceTree = "<group>"; };
7B6C5ED9264E8D860010D138 /* SentryFramesTrackingIntegration.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = SentryFramesTrackingIntegration.h; path = include/SentryFramesTrackingIntegration.h; sourceTree = "<group>"; };
7B6C5EDB264E8DA80010D138 /* SentryFramesTrackingIntegration.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = SentryFramesTrackingIntegration.m; sourceTree = "<group>"; };
7B6C5F8026034354007F7DFF /* SentryWatchdogTerminationLogic.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = SentryWatchdogTerminationLogic.h; path = include/SentryWatchdogTerminationLogic.h; sourceTree = "<group>"; };
7B6C5F8626034395007F7DFF /* SentryWatchdogTerminationLogic.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = SentryWatchdogTerminationLogic.m; sourceTree = "<group>"; };
7B6CC50124EE5A42001816D7 /* SentryHubTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SentryHubTests.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -2404,6 +2401,7 @@
F4EF69222E95ABE800B6B46A /* SentryCrashMachineContextTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = SentryCrashMachineContextTests.m; sourceTree = "<group>"; };
F4FE86BA2EECAC31003D845F /* SentryScreenshotIntegration.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SentryScreenshotIntegration.swift; sourceTree = "<group>"; };
F4FE86BB2EECAC31003D845F /* SentryScreenshotOptions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SentryScreenshotOptions.swift; sourceTree = "<group>"; };
F4FE86C52EECBEBA003D845F /* SentryFramesTrackingIntegration.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SentryFramesTrackingIntegration.swift; sourceTree = "<group>"; };
F4FE9DBC2E621F100014FED5 /* SentryRandom.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SentryRandom.swift; sourceTree = "<group>"; };
F4FE9DFB2E622CD70014FED5 /* SentryDefaultObjCRuntimeWrapper.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SentryDefaultObjCRuntimeWrapper.swift; sourceTree = "<group>"; };
F4FE9DFC2E622CD70014FED5 /* SentryObjCRuntimeWrapper.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SentryObjCRuntimeWrapper.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -3729,8 +3727,6 @@
7BE0DC38272AE874004FA8B7 /* FramesTracking */ = {
isa = PBXGroup;
children = (
7B6C5ED9264E8D860010D138 /* SentryFramesTrackingIntegration.h */,
7B6C5EDB264E8DA80010D138 /* SentryFramesTrackingIntegration.m */,
62862B1B2B1DDBC8009B16E3 /* SentryDelayedFrame.h */,
62862B1D2B1DDC35009B16E3 /* SentryDelayedFrame.m */,
62C316802B1F2E93000D7031 /* SentryDelayedFramesTracker.h */,
Expand Down Expand Up @@ -4708,6 +4704,7 @@
D8739CF72BECFF92007D2F66 /* Performance */ = {
isa = PBXGroup;
children = (
F4FE86C62EECBEBA003D845F /* FramesTracking */,
FAB007302E9EF8CB001C806A /* SentryUIViewControllerPerformanceTracker.swift */,
FAE57BF12E83049900B710F9 /* SentryDisplayLinkWrapper.swift */,
D468C0602D36699700964230 /* IO */,
Expand Down Expand Up @@ -4951,6 +4948,14 @@
path = Screenshot;
sourceTree = "<group>";
};
F4FE86C62EECBEBA003D845F /* FramesTracking */ = {
isa = PBXGroup;
children = (
F4FE86C52EECBEBA003D845F /* SentryFramesTrackingIntegration.swift */,
);
path = FramesTracking;
sourceTree = "<group>";
};
F4FE9E062E6248BB0014FED5 /* SentryCrash */ = {
isa = PBXGroup;
children = (
Expand Down Expand Up @@ -5339,7 +5344,6 @@
D865892F29D6ECA7000BE151 /* SentryCrashBinaryImageCache.h in Headers */,
6344DDB41EC309E000D9160D /* SentryCrashReportSink.h in Headers */,
D867063F27C3BC2400048851 /* SentryCoreDataTracker.h in Headers */,
7B6C5EDA264E8D860010D138 /* SentryFramesTrackingIntegration.h in Headers */,
7B0DC72F288698F70039995F /* NSMutableDictionary+Sentry.h in Headers */,
63FE713920DA4C1100CDBAE8 /* SentryCrashMach.h in Headers */,
7BD86EC5264A63F6005439DB /* SentrySysctlObjC.h in Headers */,
Expand Down Expand Up @@ -5966,9 +5970,9 @@
63FE70D520DA4C1000CDBAE8 /* SentryCrashMonitor_NSException.m in Sources */,
62F70E952D423BCD00634054 /* SentryMechanismCodable.swift in Sources */,
6283085F2D50AA8C00EAEF77 /* SentryMessage.swift in Sources */,
F4FE86C72EECBEBA003D845F /* SentryFramesTrackingIntegration.swift in Sources */,
7BC63F0A28081288009D9E37 /* SentrySwizzleWrapperHelper.m in Sources */,
6276350C2D59FACC00F7CEF6 /* SentryEventDecoder.swift in Sources */,
7B6C5EDC264E8DA80010D138 /* SentryFramesTrackingIntegration.m in Sources */,
F4FE9E082E6248E40014FED5 /* SentryCrashWrapper.swift in Sources */,
FA914E592ECF968500C54BDD /* UserFeedbackIntegration.swift in Sources */,
849B8F9A2C6E906900148E1F /* SentryUserFeedbackConfiguration.swift in Sources */,
Expand Down
36 changes: 0 additions & 36 deletions Sources/Sentry/SentryBaseIntegration.m
Original file line number Diff line number Diff line change
Expand Up @@ -154,42 +154,6 @@ - (BOOL)shouldBeEnabledWithOptions:(SentryOptions *)options
}
#endif

if (integrationOptions & kIntegrationOptionStartFramesTracker) {

#if SENTRY_HAS_UIKIT
BOOL performanceDisabled
= !options.enableAutoPerformanceTracing || !options.isTracingEnabled;
BOOL appHangsDisabled = options.isAppHangTrackingDisabled;

// The watchdog tracker uses the frames tracker, so frame tracking
// must be enabled if watchdog tracking is enabled.
BOOL watchdogDisabled = !options.enableWatchdogTerminationTracking;

if (performanceDisabled && appHangsDisabled && watchdogDisabled) {
if (appHangsDisabled) {
SENTRY_LOG_DEBUG(@"Not going to enable %@ because enableAppHangTracking is "
@"disabled or the appHangTimeoutInterval is 0.",
self.integrationName);
}

if (performanceDisabled) {
SENTRY_LOG_DEBUG(@"Not going to enable %@ because enableAutoPerformanceTracing and "
@"isTracingEnabled are disabled.",
self.integrationName);
}

if (watchdogDisabled) {
SENTRY_LOG_DEBUG(
@"Not going to enable %@ because enableWatchdogTerminationTracking "
@"is disabled.",
self.integrationName);
}

return NO;
}
#endif // SENTRY_HAS_UIKIT
}

return YES;
}

Expand Down
47 changes: 0 additions & 47 deletions Sources/Sentry/SentryFramesTrackingIntegration.m

This file was deleted.

6 changes: 2 additions & 4 deletions Sources/Sentry/SentrySDKInternal.m
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@

#if SENTRY_HAS_UIKIT
# import "SentryAppStartTrackingIntegration.h"
# import "SentryFramesTrackingIntegration.h"
# import "SentryPerformanceTrackingIntegration.h"
# import "SentryUIEventTrackingIntegration.h"
# import "SentryViewHierarchyIntegration.h"
Expand Down Expand Up @@ -512,9 +511,8 @@ + (void)endSession
#endif // SENTRY_TARGET_REPLAY_SUPPORTED
[SentryCrashIntegration class],
#if SENTRY_HAS_UIKIT
[SentryAppStartTrackingIntegration class], [SentryFramesTrackingIntegration class],
[SentryPerformanceTrackingIntegration class], [SentryUIEventTrackingIntegration class],
[SentryViewHierarchyIntegration class],
[SentryAppStartTrackingIntegration class], [SentryPerformanceTrackingIntegration class],
[SentryUIEventTrackingIntegration class], [SentryViewHierarchyIntegration class],
[SentryWatchdogTerminationTrackingIntegration class],
#endif // SENTRY_HAS_UIKIT
[SentryAutoBreadcrumbTrackingIntegration class], [SentryCoreDataTrackingIntegration class],
Expand Down
1 change: 0 additions & 1 deletion Sources/Sentry/include/SentryBaseIntegration.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ typedef NS_OPTIONS(NSUInteger, SentryIntegrationOption) {
kIntegrationOptionEnableCrashHandler = 1 << 16,
kIntegrationOptionEnableMetricKit = 1 << 17,
kIntegrationOptionEnableReplay = 1 << 18,
kIntegrationOptionStartFramesTracker = 1 << 19,
};

@class SentryOptions;
Expand Down
15 changes: 0 additions & 15 deletions Sources/Sentry/include/SentryFramesTrackingIntegration.h

This file was deleted.

6 changes: 5 additions & 1 deletion Sources/Swift/Core/Integrations/Integrations.swift
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,11 @@ private struct AnyIntegration {
.init(SentryAutoSessionTrackingIntegration.self),
.init(SentryHangTrackerIntegrationObjC.self)
]


#if (os(iOS) || os(tvOS) || targetEnvironment(macCatalyst) || os(visionOS)) && !SENTRY_NO_UIKIT
integrations.append(.init(SentryFramesTrackingIntegration<SentryDependencyContainer>.self))
#endif
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Integration order change breaks frames tracker dependency

The conversion moves SentryFramesTrackingIntegration from ObjC integrations to Swift integrations, which changes when it's installed. Previously it was installed early, before SentryWatchdogTerminationTrackingIntegration. Now Swift integrations are installed after all ObjC integrations, so the frames tracker starts after the watchdog termination integration. Since SentryANRTrackerV2 (used by watchdog tracking) depends on the frames tracker to compute frame delays, calling getFramesDelaySPI returns -1 when isRunning is false, causing ANR detection to skip frames-based analysis until the Swift integrations complete installation. The comment in the old code states "the watchdog tracker uses the frames tracker, so frame tracking must be enabled if watchdog tracking is enabled."

Additional Locations (1)

Fix in Cursor Fix in Web

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interesting, worth checking out


#if os(iOS) && !SENTRY_NO_UIKIT
integrations.append(.init(UserFeedbackIntegration.self))
#endif
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
@_implementationOnly import _SentryPrivate

#if (os(iOS) || os(tvOS) || os(visionOS)) && !SENTRY_NO_UIKIT

final class SentryFramesTrackingIntegration<Dependencies: FramesTrackingProvider>: NSObject, SwiftIntegration {
let tracker: SentryFramesTracker

init?(with options: Options, dependencies: Dependencies) {
// Check hybrid SDK mode first - if enabled, always start frames tracking
if !PrivateSentrySDKOnly.framesTrackingMeasurementHybridSDKMode {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

h: I don't understand where all of this logic comes from, can you please elaborate why the Swift version has much more logic here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like I forgot to remove the old code.
But this is the code in SentryBaseIntegration: https://github.com/getsentry/sentry-cocoa/blob/main/Sources/Sentry/SentryBaseIntegration.m#L157
This is what determines if the integration is enabled or not


// Check if frames tracking should be enabled based on options
let performanceDisabled = !options.enableAutoPerformanceTracing || !options.isTracingEnabled
let appHangsDisabled = options.isAppHangTrackingDisabled()
let watchdogDisabled = !options.enableWatchdogTerminationTracking

// The watchdog tracker uses the frames tracker, so frame tracking
// must be enabled if watchdog tracking is enabled.
if performanceDisabled && appHangsDisabled && watchdogDisabled {
if appHangsDisabled {
SentrySDKLog.debug("Not going to enable \(Self.name) because enableAppHangTracking is disabled or the appHangTimeoutInterval is 0.")
}

if performanceDisabled {
SentrySDKLog.debug("Not going to enable \(Self.name) because enableAutoPerformanceTracing and isTracingEnabled are disabled.")
}

if watchdogDisabled {
SentrySDKLog.debug("Not going to enable \(Self.name) because enableWatchdogTerminationTracking is disabled.")
}

return nil
}
}

tracker = dependencies.framesTracker
tracker.start()
}

func uninstall() {
tracker.stop()
}

static var name: String {
"SentryFramesTrackingIntegration"
}
}

#endif
8 changes: 8 additions & 0 deletions Sources/Swift/SentryDependencyContainer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,14 @@ extension SentryDependencyContainer: ScreenshotSourceProvider { }

extension SentryDependencyContainer: AutoSessionTrackingProvider { }

#if (os(iOS) || os(tvOS) || os(visionOS)) && !SENTRY_NO_UIKIT
protocol FramesTrackingProvider {
var framesTracker: SentryFramesTracker { get }
}

extension SentryDependencyContainer: FramesTrackingProvider { }
#endif

#if ((os(iOS) || os(tvOS) || os(visionOS)) && !SENTRY_NO_UIKIT) || os(macOS)
extension SentryDependencyContainer: NotificationCenterProvider { }
#endif
Expand Down
Loading
Loading