Skip to content
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,6 @@ public enum SentrySDKOverrides: String, CaseIterable {

public enum Performance: String, SentrySDKOverride {
case disableTimeToFullDisplayTracing = "--io.sentry.performance.disable-time-to-full-display-tracing"
case disableAppHangTrackingV2 = "--io.sentry.performance.disable-app-hang-tracking-v2"
case disableSessionTracking = "--io.sentry.performance.disable-automatic-session-tracking"
case disableFileIOTracing = "--io.sentry.performance.disable-file-io-tracing"
case disableUIVCTracing = "--io.sentry.performance.disable-uiviewcontroller-tracing"
Expand Down Expand Up @@ -316,7 +315,7 @@ extension SentrySDKOverrides.Other {
extension SentrySDKOverrides.Performance {
public var overrideType: OverrideType {
switch self {
case .disableTimeToFullDisplayTracing, .disableAppHangTrackingV2, .disableSessionTracking, .disableFileIOTracing, .disableUIVCTracing, .disableCoreDataTracing, .disableANRTracking, .disableWatchdogTracking, .disableUITracing, .disablePrewarmedAppStartTracing, .disablePerformanceTracing: return .boolean
case .disableTimeToFullDisplayTracing, .disableSessionTracking, .disableFileIOTracing, .disableUIVCTracing, .disableCoreDataTracing, .disableANRTracking, .disableWatchdogTracking, .disableUITracing, .disablePrewarmedAppStartTracing, .disablePerformanceTracing: return .boolean
case .sessionTrackingIntervalMillis: return .string
}
}
Expand Down Expand Up @@ -403,7 +402,7 @@ extension SentrySDKOverrides.Other {
extension SentrySDKOverrides.Performance {
public var ignoresDisableEverything: Bool {
switch self {
case .disableTimeToFullDisplayTracing, .disableAppHangTrackingV2, .disableSessionTracking, .disableFileIOTracing, .disableUIVCTracing, .disableCoreDataTracing, .disableANRTracking, .disableWatchdogTracking, .disableUITracing, .disablePrewarmedAppStartTracing, .disablePerformanceTracing: return false
case .disableTimeToFullDisplayTracing, .disableSessionTracking, .disableFileIOTracing, .disableUIVCTracing, .disableCoreDataTracing, .disableANRTracking, .disableWatchdogTracking, .disableUITracing, .disablePrewarmedAppStartTracing, .disablePerformanceTracing: return false
case .sessionTrackingIntervalMillis: return true
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,9 +112,6 @@ public struct SentrySDKWrapper {
options.screenshot.maskAllText = !SentrySDKOverrides.Screenshot.disableMaskAllText.boolValue

options.attachViewHierarchy = !SentrySDKOverrides.Other.disableAttachViewHierarchy.boolValue
#if !SDK_V9
options.enableAppHangTrackingV2 = !SentrySDKOverrides.Performance.disableAppHangTrackingV2.boolValue
#endif // SDK_V9
#endif // !os(macOS) && !os(watchOS)

// disable during benchmarks because we run CPU for 15 seconds at full throttle which can trigger ANRs
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class ViewLifecycleUITests: BaseUITest {
super.setUp()
launchApp(args: [
SentrySDKOverrides.Performance.disableTimeToFullDisplayTracing.rawValue,
SentrySDKOverrides.Performance.disableAppHangTrackingV2.rawValue
SentrySDKOverrides.Performance.disableANRTracking.rawValue
])
}

Expand Down
31 changes: 11 additions & 20 deletions Sources/Sentry/Public/SentryOptions.h
Original file line number Diff line number Diff line change
Expand Up @@ -639,18 +639,11 @@ typedef void (^SentryProfilingConfigurationBlock)(SentryProfileOptions *_Nonnull

/**
* When enabled, the SDK tracks when the application stops responding for a specific amount of
* time defined by the @c appHangsTimeoutInterval option.
* @note The default is @c YES
* @note ANR tracking is automatically disabled if a debugger is attached.
*/
@property (nonatomic, assign) BOOL enableAppHangTracking;

#if SENTRY_UIKIT_AVAILABLE

# if !SDK_V9
/**
* AppHangTrackingV2 can differentiate between fully-blocking and non-fully blocking app hangs.
* fully-blocking app hang is when the main thread is stuck completely, and the app can't render a
* time defined by the @c appHangTimeoutInterval option.
*
* On iOS, tvOS and visionOS, the SDK can differentiate between fully-blocking and non-fully
blocking app hangs.
* A fully-blocking app hang is when the main thread is stuck completely, and the app can't render a
* single frame. A non-fully-blocking app hang is when the app appears stuck to the user but can
still
* render a few frames. Fully-blocking app hangs are more actionable because the stacktrace shows
Expand All @@ -661,20 +654,18 @@ typedef void (^SentryProfilingConfigurationBlock)(SentryProfileOptions *_Nonnull
*
* You can use @c enableReportNonFullyBlockingAppHangs to ignore non-fully-blocking app hangs.
*
* @note This flag wins over enableAppHangTracking. When enabling both enableAppHangTracking and
enableAppHangTrackingV2, the SDK only enables enableAppHangTrackingV2 and disables
enableAppHangTracking.
* @note The default is @c YES
* @note App Hang tracking is automatically disabled if a debugger is attached.
*/
@property (nonatomic, assign) BOOL enableAppHangTrackingV2;
@property (nonatomic, assign) BOOL enableAppHangTracking;

# endif // !SDK_V9
#if SENTRY_UIKIT_AVAILABLE

/**
* When enabled the SDK reports non-fully-blocking app hangs. A non-fully-blocking app hang is when
* the app appears stuck to the user but can still render a few frames. For more information see @c
* enableAppHangTrackingV2.
* the app appears stuck to the user but can still render a few frames.
*
* @note The default is @c YES. This feature only works when @c enableAppHangTrackingV2 is enabled.
* @note The default is @c YES.
*/
@property (nonatomic, assign) BOOL enableReportNonFullyBlockingAppHangs;

Expand Down
61 changes: 18 additions & 43 deletions Sources/Sentry/SentryANRTrackingIntegration.m
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,8 @@ - (BOOL)installWithOptions:(SentryOptions *)options
}

#if SENTRY_HAS_UIKIT
# if SDK_V9
BOOL isV2Enabled = YES;
# else
BOOL isV2Enabled = options.enableAppHangTrackingV2;
# endif // SDK_V9
self.tracker =
[SentryDependencyContainer.sharedInstance getANRTracker:options.appHangTimeoutInterval
isV2Enabled:isV2Enabled];
[SentryDependencyContainer.sharedInstance getANRTracker:options.appHangTimeoutInterval];
#else
self.tracker =
[SentryDependencyContainer.sharedInstance getANRTracker:options.appHangTimeoutInterval];
Expand Down Expand Up @@ -157,48 +151,29 @@ - (void)anrDetectedWithType:(enum SentryANRType)type
getDebugImagesFromCacheForThreads:SENTRY_UNWRAP_NULLABLE(NSArray, event.threads)];

#if SENTRY_HAS_UIKIT
# if SDK_V9
BOOL isV2Enabled = YES;
# else
BOOL isV2Enabled = self.options.enableAppHangTrackingV2;
# endif // SDK_V9

// We only measure app hang duration for V2.
// For V1, we directly capture the app hang event.
if (isV2Enabled) {
// We only temporarily store the app hang duration info, so we can change the error message
// when either sending a normal or fatal app hang event. Otherwise, we would have to rely on
// string parsing to retrieve the app hang duration info from the error message.
mechanism.data = @{ SentryANRMechanismDataAppHangDuration : appHangDurationInfo };

// We need to apply the scope now because if the app hang turns into a fatal one,
// we would lose the scope. Furthermore, we want to know in which state the app was when the
// app hang started.
SentryScope *scope = [SentrySDKInternal currentHub].scope;
SentryOptions *options = SentrySDKInternal.options;
if (scope != nil && options != nil) {
[scope applyToEvent:event maxBreadcrumb:options.maxBreadcrumbs];
}

[self.fileManager storeAppHangEvent:event];
} else {
#endif // SENTRY_HAS_UIKIT
[SentrySDK captureEvent:event];
#if SENTRY_HAS_UIKIT
// We only temporarily store the app hang duration info, so we can change the error message
// when either sending a normal or fatal app hang event. Otherwise, we would have to rely on
// string parsing to retrieve the app hang duration info from the error message.
mechanism.data = @{ SentryANRMechanismDataAppHangDuration : appHangDurationInfo };

// We need to apply the scope now because if the app hang turns into a fatal one,
// we would lose the scope. Furthermore, we want to know in which state the app was when the
// app hang started.
SentryScope *scope = [SentrySDKInternal currentHub].scope;
SentryOptions *options = SentrySDKInternal.options;
if (scope != nil && options != nil) {
[scope applyToEvent:event maxBreadcrumb:options.maxBreadcrumbs];
}
#endif // SENTRY_UIKIT_AVAILABLE

[self.fileManager storeAppHangEvent:event];
#else
[SentrySDK captureEvent:event];
#endif
}

- (void)anrStoppedWithResult:(SentryANRStoppedResult *_Nullable)result
{
#if SENTRY_HAS_UIKIT
// We only measure app hang duration for V2, and therefore ignore V1.
# if !SDK_V9
if (!self.options.enableAppHangTrackingV2) {
return;
}
# endif // !SDK_V9

if (result == nil) {
SENTRY_LOG_WARN(@"ANR stopped for V2 but result was nil.")
return;
Expand Down
29 changes: 7 additions & 22 deletions Sources/Sentry/SentryBaseIntegration.m
Original file line number Diff line number Diff line change
Expand Up @@ -77,17 +77,10 @@ - (BOOL)shouldBeEnabledWithOptions:(SentryOptions *)options

if (integrationOptions & kIntegrationOptionEnableAppHangTracking) {
#if SENTRY_HAS_UIKIT
# if SDK_V9
if (!options.enableAppHangTracking) {
[self logWithOptionName:@"enableAppHangTracking"];
return NO;
}
# else
if (!options.enableAppHangTracking && !options.enableAppHangTrackingV2) {
[self logWithOptionName:@"enableAppHangTracking && enableAppHangTrackingV2"];
return NO;
}
# endif
#else
if (!options.enableAppHangTracking) {
[self logWithOptionName:@"enableAppHangTracking"];
Expand Down Expand Up @@ -176,26 +169,20 @@ - (BOOL)shouldBeEnabledWithOptions:(SentryOptions *)options
}
#endif

// The frames tracker runs when tracing is enabled or AppHangsV2. We have to use an extra option
// for this.
if (integrationOptions & kIntegrationOptionStartFramesTracker) {

#if SENTRY_HAS_UIKIT
BOOL performanceDisabled
= !options.enableAutoPerformanceTracing || !options.isTracingEnabled;
BOOL appHangsV2Disabled = options.isAppHangTrackingV2Disabled;
# if SDK_V9
// The V9 watchdog tracker uses the frames tracker, so frame tracking
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;
# else
// Before V9 this should have no effect so set it to YES
BOOL watchdogDisabled = YES;
# endif // SDK_V9

if (performanceDisabled && appHangsV2Disabled && watchdogDisabled) {
if (appHangsV2Disabled) {
SENTRY_LOG_DEBUG(@"Not going to enable %@ because enableAppHangTrackingV2 is "

if (performanceDisabled && appHangsDisabled && watchdogDisabled) {
if (appHangsDisabled) {
SENTRY_LOG_DEBUG(@"Not going to enable %@ because enableAppHangTracking is "
@"disabled or the appHangTimeoutInterval is 0.",
self.integrationName);
}
Expand All @@ -206,14 +193,12 @@ - (BOOL)shouldBeEnabledWithOptions:(SentryOptions *)options
self.integrationName);
}

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

return NO;
}
Expand Down
31 changes: 12 additions & 19 deletions Sources/Sentry/SentryDependencyContainer.m
Original file line number Diff line number Diff line change
Expand Up @@ -244,34 +244,27 @@ - (SentryCrashSwift *)crashReporter SENTRY_THREAD_SANITIZER_DOUBLE_CHECKED_LOCK
- (SentryANRTracker *)getANRTracker:(NSTimeInterval)timeout
SENTRY_THREAD_SANITIZER_DOUBLE_CHECKED_LOCK
{
#if SENTRY_HAS_UIKIT
SENTRY_LAZY_INIT(_anrTracker,
[[SentryANRTracker alloc]
initWithHelper:[[SentryANRTrackerV2 alloc]
initWithTimeoutInterval:timeout
crashWrapper:self.crashWrapper
dispatchQueueWrapper:self.dispatchQueueWrapper
threadWrapper:self.threadWrapper
framesTracker:self.framesTracker]]);
#else
SENTRY_LAZY_INIT(_anrTracker,
[[SentryANRTracker alloc]
initWithHelper:[[SentryANRTrackerV1 alloc]
initWithTimeoutInterval:timeout
crashWrapper:self.crashWrapper
dispatchQueueWrapper:self.dispatchQueueWrapper
threadWrapper:self.threadWrapper]]);
;
#endif
}

#if SENTRY_HAS_UIKIT
- (SentryANRTracker *)getANRTracker:(NSTimeInterval)timeout
isV2Enabled:(BOOL)isV2Enabled SENTRY_THREAD_SANITIZER_DOUBLE_CHECKED_LOCK
{
if (isV2Enabled) {
SENTRY_LAZY_INIT(_anrTracker,
[[SentryANRTracker alloc]
initWithHelper:[[SentryANRTrackerV2 alloc]
initWithTimeoutInterval:timeout
crashWrapper:self.crashWrapper
dispatchQueueWrapper:self.dispatchQueueWrapper
threadWrapper:self.threadWrapper
framesTracker:self.framesTracker]]);
} else {
return [self getANRTracker:timeout];
}
}
#endif // SENTRY_HAS_UIKIT

#if SENTRY_TARGET_REPLAY_SUPPORTED
- (nonnull SentryScreenshotSource *)screenshotSource SENTRY_THREAD_SANITIZER_DOUBLE_CHECKED_LOCK
{
Expand Down
12 changes: 2 additions & 10 deletions Sources/Sentry/SentryOptions.m
Original file line number Diff line number Diff line change
Expand Up @@ -101,9 +101,6 @@ - (instancetype)init
self.enableUserInteractionTracing = YES;
self.idleTimeout = SentryTracerDefaultTimeout;
self.enablePreWarmedAppStartTracing = NO;
# if !SDK_V9
self.enableAppHangTrackingV2 = NO;
# endif // !SDK_V9
self.enableReportNonFullyBlockingAppHangs = YES;
#endif // SENTRY_HAS_UIKIT

Expand Down Expand Up @@ -458,14 +455,9 @@ - (void)setEnableSpotlight:(BOOL)value
}

#if SENTRY_HAS_UIKIT
- (BOOL)isAppHangTrackingV2Disabled
- (BOOL)isAppHangTrackingDisabled
{
# if SDK_V9
BOOL isV2Enabled = self.enableAppHangTracking;
# else
BOOL isV2Enabled = self.enableAppHangTrackingV2;
# endif // SDK_V9
return !isV2Enabled || self.appHangTimeoutInterval <= 0;
return !self.enableAppHangTracking || self.appHangTimeoutInterval <= 0;
}
#endif // SENTRY_HAS_UIKIT

Expand Down
6 changes: 3 additions & 3 deletions Sources/Sentry/SentryProfiler.mm
Original file line number Diff line number Diff line change
Expand Up @@ -247,10 +247,10 @@ - (void)stopForReason:(SentryProfilerTruncationReason)reason

BOOL autoPerformanceTracingDisabled
= ![[[[SentrySDKInternal currentHub] getClient] options] enableAutoPerformanceTracing];
BOOL appHangsV2Disabled =
[[[[SentrySDKInternal currentHub] getClient] options] isAppHangTrackingV2Disabled];
BOOL appHangsDisabled =
[[[[SentrySDKInternal currentHub] getClient] options] isAppHangTrackingDisabled];

if (autoPerformanceTracingDisabled && appHangsV2Disabled) {
if (autoPerformanceTracingDisabled && appHangsDisabled) {
sentry_stopFramesTracker();
}
# endif // SENTRY_HAS_UIKIT
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,15 +74,8 @@ - (BOOL)installWithOptions:(SentryOptions *)options

[self.tracker start];

# if SDK_V9
BOOL isV2Enabled = YES;
# else
BOOL isV2Enabled = options.enableAppHangTrackingV2;
# endif // SDK_V9

self.anrTracker =
[SentryDependencyContainer.sharedInstance getANRTracker:options.appHangTimeoutInterval
isV2Enabled:isV2Enabled];
[SentryDependencyContainer.sharedInstance getANRTracker:options.appHangTimeoutInterval];
[self.anrTracker addListener:self];

self.appStateManager = appStateManager;
Expand Down
5 changes: 0 additions & 5 deletions Sources/Sentry/SentyOptionsInternal.m
Original file line number Diff line number Diff line change
Expand Up @@ -280,11 +280,6 @@ + (BOOL)validateOptions:(NSDictionary<NSString *, id> *)options
[self setBool:options[@"enablePreWarmedAppStartTracing"]
block:^(BOOL value) { sentryOptions.enablePreWarmedAppStartTracing = value; }];

# if !SDK_V9
[self setBool:options[@"enableAppHangTrackingV2"]
block:^(BOOL value) { sentryOptions.enableAppHangTrackingV2 = value; }];
# endif // !SDK_V9

[self setBool:options[@"enableReportNonFullyBlockingAppHangs"]
block:^(BOOL value) { sentryOptions.enableReportNonFullyBlockingAppHangs = value; }];

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,9 +107,6 @@ SENTRY_NO_INIT
@property (nonatomic, strong) SentryDebugImageProvider *debugImageProvider;

- (SentryANRTracker *)getANRTracker:(NSTimeInterval)timeout;
#if SENTRY_HAS_UIKIT
- (SentryANRTracker *)getANRTracker:(NSTimeInterval)timeout isV2Enabled:(BOOL)isV2Enabled;
#endif // SENTRY_HAS_UIKIT

- (nullable id<SentryApplication>)application;

Expand Down
2 changes: 1 addition & 1 deletion Sources/Sentry/include/SentryOptions+Private.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ FOUNDATION_EXPORT NSString *const kSentryDefaultEnvironment;
SENTRY_EXTERN BOOL sentry_isValidSampleRate(NSNumber *sampleRate);

#if SENTRY_HAS_UIKIT
- (BOOL)isAppHangTrackingV2Disabled;
- (BOOL)isAppHangTrackingDisabled;
#endif // SENTRY_HAS_UIKIT
@end

Expand Down
8 changes: 0 additions & 8 deletions Sources/Swift/Helper/SentryEnabledFeaturesBuilder.swift
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,6 @@ import Foundation
if options.swiftAsyncStacktraces {
features.append("swiftAsyncStacktraces")
}

#if os(iOS) || os(tvOS) || targetEnvironment(macCatalyst)
#if !SDK_V9
if options.enableAppHangTrackingV2 {
features.append("appHangTrackingV2")
}
#endif // !SDK_V9
#endif //os(iOS) || os(tvOS) || targetEnvironment(macCatalyst)

if options.enablePersistingTracesWhenCrashing {
features.append("persistingTracesWhenCrashing")
Expand Down
Loading
Loading