Skip to content

Commit 04ff3ec

Browse files
authored
feat(v9): Remove app hang v2 option from SDK v9 (#5615)
1 parent 0da9466 commit 04ff3ec

File tree

7 files changed

+45
-4
lines changed

7 files changed

+45
-4
lines changed

CHANGELOG-v9.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,4 @@ Removes unused SentryLogLevel (#5591)
1313
Removes deprecated getStoreEndpoint (#5591)
1414
Removes deprecated useSpan function (#5591)
1515
Removes deprecated SentryDebugImageProvider class (#5598)
16+
Makes app hang tracking V2 the default and removes the option to enable/disable it (#5615)

Sources/Sentry/Public/SentryOptions.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -639,6 +639,7 @@ typedef void (^SentryProfilingConfigurationBlock)(SentryProfileOptions *_Nonnull
639639

640640
#if SENTRY_UIKIT_AVAILABLE
641641

642+
# if !SDK_V9
642643
/**
643644
* AppHangTrackingV2 can differentiate between fully-blocking and non-fully blocking app hangs.
644645
* fully-blocking app hang is when the main thread is stuck completely, and the app can't render a
@@ -658,6 +659,8 @@ typedef void (^SentryProfilingConfigurationBlock)(SentryProfileOptions *_Nonnull
658659
*/
659660
@property (nonatomic, assign) BOOL enableAppHangTrackingV2;
660661

662+
# endif // !SDK_V9
663+
661664
/**
662665
* When enabled the SDK reports non-fully-blocking app hangs. A non-fully-blocking app hang is when
663666
* the app appears stuck to the user but can still render a few frames. For more information see @c

Sources/Sentry/SentryANRTrackingIntegration.m

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,14 @@ - (BOOL)installWithOptions:(SentryOptions *)options
5151
}
5252

5353
#if SENTRY_HAS_UIKIT
54+
# if SDK_V9
55+
BOOL isV2Enabled = YES;
56+
# else
57+
BOOL isV2Enabled = options.enableAppHangTrackingV2;
58+
# endif // SDK_V9
5459
self.tracker =
5560
[SentryDependencyContainer.sharedInstance getANRTracker:options.appHangTimeoutInterval
56-
isV2Enabled:options.enableAppHangTrackingV2];
61+
isV2Enabled:isV2Enabled];
5762
#else
5863
self.tracker =
5964
[SentryDependencyContainer.sharedInstance getANRTracker:options.appHangTimeoutInterval];
@@ -157,9 +162,15 @@ - (void)anrDetectedWithType:(enum SentryANRType)type
157162
event.debugMeta = [self.debugImageProvider getDebugImagesFromCacheForThreads:event.threads];
158163

159164
#if SENTRY_HAS_UIKIT
165+
# if SDK_V9
166+
BOOL isV2Enabled = YES;
167+
# else
168+
BOOL isV2Enabled = self.options.enableAppHangTrackingV2;
169+
# endif // SDK_V9
170+
160171
// We only measure app hang duration for V2.
161172
// For V1, we directly capture the app hang event.
162-
if (self.options.enableAppHangTrackingV2) {
173+
if (isV2Enabled) {
163174
// We only temporarily store the app hang duration info, so we can change the error message
164175
// when either sending a normal or fatal app hang event. Otherwise, we would have to rely on
165176
// string parsing to retrieve the app hang duration info from the error message.
@@ -187,9 +198,11 @@ - (void)anrStoppedWithResult:(SentryANRStoppedResult *_Nullable)result
187198
{
188199
#if SENTRY_HAS_UIKIT
189200
// We only measure app hang duration for V2, and therefore ignore V1.
201+
# if !SDK_V9
190202
if (!self.options.enableAppHangTrackingV2) {
191203
return;
192204
}
205+
# endif // !SDK_V9
193206

194207
if (result == nil) {
195208
SENTRY_LOG_WARN(@"ANR stopped for V2 but result was nil.")

Sources/Sentry/SentryBaseIntegration.m

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,10 +78,17 @@ - (BOOL)shouldBeEnabledWithOptions:(SentryOptions *)options
7878

7979
if (integrationOptions & kIntegrationOptionEnableAppHangTracking) {
8080
#if SENTRY_HAS_UIKIT
81+
# if SDK_V9
82+
if (!options.enableAppHangTracking) {
83+
[self logWithOptionName:@"enableAppHangTracking"];
84+
return NO;
85+
}
86+
# else
8187
if (!options.enableAppHangTracking && !options.enableAppHangTrackingV2) {
8288
[self logWithOptionName:@"enableAppHangTracking && enableAppHangTrackingV2"];
8389
return NO;
8490
}
91+
# endif
8592
#else
8693
if (!options.enableAppHangTracking) {
8794
[self logWithOptionName:@"enableAppHangTracking"];

Sources/Sentry/SentryOptions.m

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,9 @@ - (instancetype)init
136136
self.enableUserInteractionTracing = YES;
137137
self.idleTimeout = SentryTracerDefaultTimeout;
138138
self.enablePreWarmedAppStartTracing = NO;
139+
# if !SDK_V9
139140
self.enableAppHangTrackingV2 = NO;
141+
# endif // !SDK_V9
140142
self.enableReportNonFullyBlockingAppHangs = YES;
141143
#endif // SENTRY_HAS_UIKIT
142144

@@ -468,8 +470,10 @@ - (BOOL)validateOptions:(NSDictionary<NSString *, id> *)options
468470
[self setBool:options[@"enablePreWarmedAppStartTracing"]
469471
block:^(BOOL value) { self->_enablePreWarmedAppStartTracing = value; }];
470472

473+
# if !SDK_V9
471474
[self setBool:options[@"enableAppHangTrackingV2"]
472475
block:^(BOOL value) { self->_enableAppHangTrackingV2 = value; }];
476+
# endif // !SDK_V9
473477

474478
[self setBool:options[@"enableReportNonFullyBlockingAppHangs"]
475479
block:^(BOOL value) { self->_enableReportNonFullyBlockingAppHangs = value; }];
@@ -843,7 +847,12 @@ - (void)setEnableSpotlight:(BOOL)value
843847
#if SENTRY_HAS_UIKIT
844848
- (BOOL)isAppHangTrackingV2Disabled
845849
{
846-
return !self.enableAppHangTrackingV2 || self.appHangTimeoutInterval <= 0;
850+
# if SDK_V9
851+
BOOL isV2Enabled = self.enableAppHangTracking;
852+
# else
853+
BOOL isV2Enabled = self.enableAppHangTrackingV2;
854+
# endif // SDK_V9
855+
return !isV2Enabled || self.appHangTimeoutInterval <= 0;
847856
}
848857
#endif // SENTRY_HAS_UIKIT
849858

Sources/Sentry/SentryWatchdogTerminationTrackingIntegration.m

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,9 +79,15 @@ - (BOOL)installWithOptions:(SentryOptions *)options
7979

8080
[self.tracker start];
8181

82+
# if SDK_V9
83+
BOOL isV2Enabled = YES;
84+
# else
85+
BOOL isV2Enabled = options.enableAppHangTrackingV2;
86+
# endif // SDK_V9
87+
8288
self.anrTracker =
8389
[SentryDependencyContainer.sharedInstance getANRTracker:options.appHangTimeoutInterval
84-
isV2Enabled:options.enableAppHangTrackingV2];
90+
isV2Enabled:isV2Enabled];
8591
[self.anrTracker addListener:self];
8692

8793
self.appStateManager = appStateManager;

Sources/Swift/Helper/SentryEnabledFeaturesBuilder.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,11 @@ import Foundation
4141
}
4242

4343
#if os(iOS) || os(tvOS) || targetEnvironment(macCatalyst)
44+
#if !SDK_V9
4445
if options.enableAppHangTrackingV2 {
4546
features.append("appHangTrackingV2")
4647
}
48+
#endif // !SDK_V9
4749
#endif //os(iOS) || os(tvOS) || targetEnvironment(macCatalyst)
4850

4951
if options.enablePersistingTracesWhenCrashing {

0 commit comments

Comments
 (0)