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
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Changelog

## Unreleased

### Improvements

- The watchdog termination integration uses a runloop observer instead of fixed interval main thread work to avoid creating a busy runloop (#6237)

## 8.56.1

### Fixes
Expand Down
18 changes: 17 additions & 1 deletion Sentry.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -1110,11 +1110,15 @@
FACEED132E3179A10007B4AC /* SentyOptionsInternal.m in Sources */ = {isa = PBXBuildFile; fileRef = FACEED122E3179A10007B4AC /* SentyOptionsInternal.m */; };
FAE2DAB82E1F317900262307 /* SentryProfilingSwiftHelpers.m in Sources */ = {isa = PBXBuildFile; fileRef = FAE2DAB72E1F317900262307 /* SentryProfilingSwiftHelpers.m */; };
FAE2DABA2E1F318900262307 /* SentryProfilingSwiftHelpers.h in Headers */ = {isa = PBXBuildFile; fileRef = FAE2DAB92E1F318900262307 /* SentryProfilingSwiftHelpers.h */; };
FAE579842E7CF21800B710F9 /* SentryMigrateSessionInit.swift in Sources */ = {isa = PBXBuildFile; fileRef = FAE5797E2E7CF21300B710F9 /* SentryMigrateSessionInit.swift */; };
FAE5798D2E7D9D4C00B710F9 /* SentrySysctl.swift in Sources */ = {isa = PBXBuildFile; fileRef = FAE579872E7D9D4900B710F9 /* SentrySysctl.swift */; };
FAE579BA2E7DBE9900B710F9 /* SentryGlobalEventProcessor.swift in Sources */ = {isa = PBXBuildFile; fileRef = FAE579B42E7DBE9400B710F9 /* SentryGlobalEventProcessor.swift */; };
FAE579C22E7DDDE700B710F9 /* SentryThreadWrapper.swift in Sources */ = {isa = PBXBuildFile; fileRef = FAE579BC2E7DDDE400B710F9 /* SentryThreadWrapper.swift */; };
FAE579842E7CF21800B710F9 /* SentryMigrateSessionInit.swift in Sources */ = {isa = PBXBuildFile; fileRef = FAE5797E2E7CF21300B710F9 /* SentryMigrateSessionInit.swift */; };
FAE579CC2E7DE14900B710F9 /* SentryFrameRemover.swift in Sources */ = {isa = PBXBuildFile; fileRef = FAE579C62E7DE14400B710F9 /* SentryFrameRemover.swift */; };
FAE579D52E7F238100B710F9 /* HangTracker.swift in Sources */ = {isa = PBXBuildFile; fileRef = FAE579CF2E7F237A00B710F9 /* HangTracker.swift */; };
FAE57A3C2E81C55900B710F9 /* SentryWatchdogTerminationTrackingIntegrationSwift.swift in Sources */ = {isa = PBXBuildFile; fileRef = FAE57A362E81C54F00B710F9 /* SentryWatchdogTerminationTrackingIntegrationSwift.swift */; };
FAE57C142E831A7700B710F9 /* SentryWatchdogTerminationTrackingIntegrationSwiftTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = FAE57C0E2E831A7700B710F9 /* SentryWatchdogTerminationTrackingIntegrationSwiftTests.swift */; };
FAE57C232E832A9400B710F9 /* HangTrackerTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = FAE57C1D2E832A8F00B710F9 /* HangTrackerTests.swift */; };
FAE80C242E4695B40010A595 /* SentryEvent+Serialize.h in Headers */ = {isa = PBXBuildFile; fileRef = FAE80C232E4695AE0010A595 /* SentryEvent+Serialize.h */; };
FAEC270E2DF3526000878871 /* SentryUserFeedback.swift in Sources */ = {isa = PBXBuildFile; fileRef = FAEC270D2DF3526000878871 /* SentryUserFeedback.swift */; };
FAEC273D2DF3933A00878871 /* NSData+Unzip.m in Sources */ = {isa = PBXBuildFile; fileRef = FAEC273C2DF3933200878871 /* NSData+Unzip.m */; };
Expand Down Expand Up @@ -2459,6 +2463,10 @@
FAE579B42E7DBE9400B710F9 /* SentryGlobalEventProcessor.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SentryGlobalEventProcessor.swift; sourceTree = "<group>"; };
FAE579BC2E7DDDE400B710F9 /* SentryThreadWrapper.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SentryThreadWrapper.swift; sourceTree = "<group>"; };
FAE579C62E7DE14400B710F9 /* SentryFrameRemover.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SentryFrameRemover.swift; sourceTree = "<group>"; };
FAE579CF2E7F237A00B710F9 /* HangTracker.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HangTracker.swift; sourceTree = "<group>"; };
FAE57A362E81C54F00B710F9 /* SentryWatchdogTerminationTrackingIntegrationSwift.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SentryWatchdogTerminationTrackingIntegrationSwift.swift; sourceTree = "<group>"; };
FAE57C0E2E831A7700B710F9 /* SentryWatchdogTerminationTrackingIntegrationSwiftTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SentryWatchdogTerminationTrackingIntegrationSwiftTests.swift; sourceTree = "<group>"; };
FAE57C1D2E832A8F00B710F9 /* HangTrackerTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HangTrackerTests.swift; sourceTree = "<group>"; };
FAE80C232E4695AE0010A595 /* SentryEvent+Serialize.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = "SentryEvent+Serialize.h"; path = "include/SentryEvent+Serialize.h"; sourceTree = "<group>"; };
FAEC270D2DF3526000878871 /* SentryUserFeedback.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SentryUserFeedback.swift; sourceTree = "<group>"; };
FAEC273C2DF3933200878871 /* NSData+Unzip.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = "NSData+Unzip.m"; sourceTree = "<group>"; };
Expand Down Expand Up @@ -3355,6 +3363,7 @@
7B2A70D627D5F06C008B0D15 /* ANR */ = {
isa = PBXGroup;
children = (
FAE57C1D2E832A8F00B710F9 /* HangTrackerTests.swift */,
7B2A70D727D5F07F008B0D15 /* SentryANRTrackerV1Tests.swift */,
621D22002DBB7E09006F9C48 /* SentryANRTrackerV1IntegrationTests.swift */,
621AE74E2C626CF70012E730 /* SentryANRTrackerV2Tests.swift */,
Expand Down Expand Up @@ -3763,6 +3772,7 @@
children = (
D452FE6B2DDC873400AFF56F /* Processors */,
7BFE7A0927A1B6B000D2B66E /* SentryWatchdogTerminationTrackingIntegrationTests.swift */,
FAE57C0E2E831A7700B710F9 /* SentryWatchdogTerminationTrackingIntegrationSwiftTests.swift */,
0A2D7BB929152CBF008727AF /* SentryWatchdogTerminationScopeObserverTests.swift */,
7B98D7DF25FB73B900C5A389 /* SentryWatchdogTerminationTrackerTests.swift */,
D452FE742DDC8DC400AFF56F /* TestSentryWatchdogTerminationBreadcrumbProcessor.swift */,
Expand Down Expand Up @@ -4227,6 +4237,7 @@
D452FCBC2DDB6FA800AFF56F /* WatchdogTerminations */ = {
isa = PBXGroup;
children = (
FAE57A362E81C54F00B710F9 /* SentryWatchdogTerminationTrackingIntegrationSwift.swift */,
D452FCBD2DDB6FC200AFF56F /* Processors */,
);
path = WatchdogTerminations;
Expand Down Expand Up @@ -4324,6 +4335,7 @@
D800942328F82E8D005D3943 /* Swift */ = {
isa = PBXGroup;
children = (
FAE579CF2E7F237A00B710F9 /* HangTracker.swift */,
F4FE9E062E6248BB0014FED5 /* SentryCrash */,
FABB48B22E59310D0071397E /* Transaction */,
FAAB29F02E3D252000ACD577 /* SentrySession.swift */,
Expand Down Expand Up @@ -5865,6 +5877,7 @@
FA01BCB22E69352A00968DFA /* SentryDiscardedEvent.swift in Sources */,
7BAF3DCE243DCBFE008A5414 /* SentryTransportFactory.m in Sources */,
F4E3DCCB2E1579240093CB80 /* SentryScopePersistentStore.swift in Sources */,
FAE57A3C2E81C55900B710F9 /* SentryWatchdogTerminationTrackingIntegrationSwift.swift in Sources */,
7D65260E237F649E00113EA2 /* SentryScope.m in Sources */,
D4EDF9842D0B2A210071E7B3 /* Data+SentryTracing.swift in Sources */,
84281C472A57905700EE88F2 /* SentrySample.m in Sources */,
Expand All @@ -5888,6 +5901,7 @@
0A2D8DA9289BC905008720F6 /* SentryViewHierarchyProviderHelper.m in Sources */,
D84D2CDD2C2BF7370011AF8A /* SentryReplayEvent.swift in Sources */,
D8BC28CC2BFF78220054DA4D /* SentryRRWebTouchEvent.swift in Sources */,
FAE579D52E7F238100B710F9 /* HangTracker.swift in Sources */,
D452FC592DDB4B1700AFF56F /* SentryWatchdogTerminationBreadcrumbProcessor.m in Sources */,
FAE2DAB82E1F317900262307 /* SentryProfilingSwiftHelpers.m in Sources */,
8EA1ED0B2668F8C400E62B98 /* SentryUIViewControllerSwizzling.m in Sources */,
Expand Down Expand Up @@ -6034,6 +6048,7 @@
62278CA82E30B21A0022ABC6 /* SentryHttpTransportFlushIntegrationTests.swift in Sources */,
0A5370A128A3EC2400B2DCDE /* SentryViewHierarchyProviderTests.swift in Sources */,
D8FFE50C2703DBB400607131 /* SwizzlingCallTests.swift in Sources */,
FAE57C142E831A7700B710F9 /* SentryWatchdogTerminationTrackingIntegrationSwiftTests.swift in Sources */,
7BFAA6E7297AA16A00E7E02E /* SentryCrashMonitor_CppException_Tests.mm in Sources */,
9286059929A50BAB00F96038 /* SentryGeoTests.swift in Sources */,
621655662DB12A8900810504 /* SentryCrashMach-OTests.m in Sources */,
Expand Down Expand Up @@ -6241,6 +6256,7 @@
D884A20527C80F6300074664 /* SentryCoreDataTrackerTest.swift in Sources */,
8E70B10125CB8695002B3155 /* SentrySpanIdTests.swift in Sources */,
62E2119A2DAE99FC007D7262 /* SentryAsyncSafeLog.m in Sources */,
FAE57C232E832A9400B710F9 /* HangTrackerTests.swift in Sources */,
84EB21962BF01CEA00EDDA28 /* SentryCrashInstallationTests.swift in Sources */,
7BFE7A0A27A1B6B000D2B66E /* SentryWatchdogTerminationTrackingIntegrationTests.swift in Sources */,
FA6614FC2E4B8E1A00657755 /* TestSentryUIApplication.swift in Sources */,
Expand Down
19 changes: 1 addition & 18 deletions Sources/Sentry/SentryBaseIntegration.m
Original file line number Diff line number Diff line change
Expand Up @@ -186,16 +186,8 @@ - (BOOL)shouldBeEnabledWithOptions:(SentryOptions *)options
BOOL performanceDisabled
= !options.enableAutoPerformanceTracing || !options.isTracingEnabled;
BOOL appHangsV2Disabled = options.isAppHangTrackingV2Disabled;
# if SDK_V9
// The V9 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 (performanceDisabled && appHangsV2Disabled) {
if (appHangsV2Disabled) {
SENTRY_LOG_DEBUG(@"Not going to enable %@ because enableAppHangTrackingV2 is "
@"disabled or the appHangTimeoutInterval is 0.",
Expand All @@ -208,15 +200,6 @@ - (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;
}
#endif // SENTRY_HAS_UIKIT
Expand Down
3 changes: 3 additions & 0 deletions Sources/Sentry/SentryDependencyContainer.m
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,9 @@ - (instancetype)init
if (self = [super init]) {
isInitialializingDependencyContainer = YES;

_hangTracker = [[SentryHangTrackerObjcBridge alloc]
initWithDateProvider:SentryDependencies.dateProvider];

_dispatchQueueWrapper = SentryDependencies.dispatchQueueWrapper;
_random = [[SentryRandom alloc] init];
_threadWrapper = [[SentryThreadWrapper alloc] init];
Expand Down
29 changes: 13 additions & 16 deletions Sources/Sentry/SentryWatchdogTerminationTrackingIntegration.m
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,13 @@
# import <SentryWatchdogTerminationTracker.h>
NS_ASSUME_NONNULL_BEGIN

@interface SentryWatchdogTerminationTrackingIntegration () <SentryANRTrackerDelegate>
@interface SentryWatchdogTerminationTrackingIntegration ()

@property (nonatomic, strong) SentryWatchdogTerminationTracker *tracker;
@property (nonatomic, strong) id<SentryANRTracker> anrTracker;
@property (nullable, nonatomic, copy) NSString *testConfigurationFilePath;
@property (nonatomic, strong) SentryAppStateManager *appStateManager;
@property (nonatomic, strong) SentryWatchdogTerminationTrackingIntegrationSwift *swiftImpl;
@property (nonatomic, strong) SentryDispatchQueueWrapper *queue;

@end

Expand Down Expand Up @@ -56,6 +57,12 @@ - (BOOL)installWithOptions:(SentryOptions *)options
[[SentryDispatchQueueWrapper alloc] initWithName:"io.sentry.watchdog-termination-tracker"
attributes:attributes];

self.swiftImpl = [[SentryWatchdogTerminationTrackingIntegrationSwift alloc]
initWithHangTrackerBridge:SentryDependencyContainer.sharedInstance.hangTracker
timeoutInterval:options.appHangTimeoutInterval
hangStarted:^{ [dispatchQueueWrapper dispatchAsyncWithBlock:^{ [self hangStarted]; }]; }
hangStopped:^{ [dispatchQueueWrapper dispatchAsyncWithBlock:^{ [self hangStopped]; }]; }];

SentryFileManager *fileManager = [[[SentrySDKInternal currentHub] getClient] fileManager];
SentryAppStateManager *appStateManager =
[SentryDependencyContainer sharedInstance].appStateManager;
Expand All @@ -75,17 +82,7 @@ - (BOOL)installWithOptions:(SentryOptions *)options
scopePersistentStore:scopeStore];

[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];
[self.anrTracker addListener:self];
[self.swiftImpl start];

self.appStateManager = appStateManager;

Expand Down Expand Up @@ -125,16 +122,16 @@ - (void)uninstall
if (nil != self.tracker) {
[self.tracker stop];
}
[self.anrTracker removeListener:self];
[self.swiftImpl stop];
}

- (void)anrDetectedWithType:(enum SentryANRType)type
- (void)hangStarted
{
[self.appStateManager
updateAppState:^(SentryAppState *appState) { appState.isANROngoing = YES; }];
}

- (void)anrStoppedWithResult:(SentryANRStoppedResult *_Nullable)result
- (void)hangStopped
{
[self.appStateManager
updateAppState:^(SentryAppState *appState) { appState.isANROngoing = NO; }];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
@class SentryOptions;
@class SentrySessionTracker;
@class SentryGlobalEventProcessor;
@class SentryHangTrackerObjcBridge;

@protocol SentryANRTracker;
@protocol SentryRandomProtocol;
Expand Down Expand Up @@ -95,6 +96,7 @@ SENTRY_NO_INIT
@property (nonatomic, strong) id<SentryRateLimits> rateLimits;
@property (nonatomic, strong) id<SentryApplication> application;
@property (nonatomic, strong) SentryThreadsafeApplication *threadsafeApplication;
@property (nonatomic, strong) SentryHangTrackerObjcBridge *hangTracker;

#if SENTRY_HAS_REACHABILITY
@property (nonatomic, strong) SentryReachability *reachability;
Expand Down
1 change: 1 addition & 0 deletions Sources/Sentry/include/SentryPrivate.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@

// Headers that also import SentryDefines should be at the end of this list
// otherwise it wont compile
#import "SentryAppStateManager.h"
#import "SentryAsyncLog.h"
#import "SentryClient+Logs.h"
#import "SentryCrash.h"
Expand Down
Loading
Loading