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
6 changes: 3 additions & 3 deletions Sources/Sentry/Profiling/SentryContinuousProfiler.mm
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

#if SENTRY_TARGET_PROFILING_SUPPORTED

# import "SentryDependencyContainer.h"
# import "SentryDependencyContainerSwiftHelper.h"
# import "SentryInternalDefines.h"
# import "SentryLogC.h"
# import "SentryMetricProfiler.h"
Expand Down Expand Up @@ -83,7 +83,7 @@

// Move the serialization work to a background queue to avoid potentially
// blocking the main thread. The serialization can take several milliseconds.
sentry_dispatchAsync(SentryDependencyContainer.sharedInstance.dispatchQueueWrapper, ^{
sentry_dispatchAsync(SentryDependencyContainerSwiftHelper.dispatchQueueWrapper, ^{
NSDictionary *_Nonnull serializedMetrics
= serializeContinuousProfileMetrics(metricProfilerState);
SentryEnvelope *_Nullable envelope
Expand Down Expand Up @@ -199,7 +199,7 @@ + (nullable SentryId *)currentProfilerID
+ (void)scheduleTimer
{
sentry_dispatchAsyncOnMainIfNotMainThread(
SentryDependencyContainer.sharedInstance.dispatchQueueWrapper, ^{
SentryDependencyContainerSwiftHelper.dispatchQueueWrapper, ^{
std::lock_guard<std::mutex> l(_threadUnsafe_gContinuousProfilerLock);
if (_chunkTimer != nil) {
SENTRY_LOG_WARN(
Expand Down
4 changes: 2 additions & 2 deletions Sources/Sentry/Profiling/SentryProfilerState.mm
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#if SENTRY_TARGET_PROFILING_SUPPORTED
# import "SentryAsyncSafeLog.h"
# import "SentryBacktrace.hpp"
# import "SentryDependencyContainer.h"
# import "SentryDependencyContainerSwiftHelper.h"
# import "SentryFormatter.h"
# import "SentryInternalDefines.h"
# import "SentryProfileTimeseries.h"
Expand Down Expand Up @@ -73,7 +73,7 @@ - (instancetype)init
_mutableState = [[SentryProfilerMutableState alloc] init];
_mainThreadID = 0;
sentry_dispatchAsyncOnMainIfNotMainThread(
SentryDependencyContainer.sharedInstance.dispatchQueueWrapper,
SentryDependencyContainerSwiftHelper.dispatchQueueWrapper,
^{ [self cacheMainThreadID]; });
}
return self;
Expand Down
5 changes: 2 additions & 3 deletions Sources/Sentry/Profiling/SentryTraceProfiler.mm
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@

#if SENTRY_TARGET_PROFILING_SUPPORTED

# import "SentryDependencyContainer.h"

# import "SentryDependencyContainerSwiftHelper.h"
# import "SentryInternalDefines.h"
# import "SentryLogC.h"
# import "SentryMetricProfiler.h"
Expand Down Expand Up @@ -85,7 +84,7 @@ + (void)recordMetrics
+ (void)scheduleTimeoutTimer
{
sentry_dispatchAsyncOnMainIfNotMainThread(
SentryDependencyContainer.sharedInstance.dispatchQueueWrapper, ^{
SentryDependencyContainerSwiftHelper.dispatchQueueWrapper, ^{
std::lock_guard<std::mutex> l(_threadUnsafe_gTraceProfilerLock);
if (_sentry_threadUnsafe_traceProfileTimeoutTimer != nil) {
return;
Expand Down
16 changes: 10 additions & 6 deletions Sources/Sentry/SentryANRTrackerV1.m
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ typedef NS_ENUM(NSInteger, SentryANRTrackerState) {
kSentryANRTrackerStopping
};

@interface SentryANRTrackerV1 () <SentryANRTracker>
@interface SentryANRTrackerV1 ()

@property (nonatomic, strong) SentryCrashWrapper *crashWrapper;
@property (nonatomic, strong) SentryDispatchQueueWrapper *dispatchQueueWrapper;
Expand All @@ -28,6 +28,15 @@ @implementation SentryANRTrackerV1 {
SentryANRTrackerState state;
}

- (instancetype)initWithTimeoutInterval:(NSTimeInterval)timeoutInterval
{
return
[self initWithTimeoutInterval:timeoutInterval
crashWrapper:SentryDependencyContainer.sharedInstance.crashWrapper
dispatchQueueWrapper:SentryDependencyContainer.sharedInstance.dispatchQueueWrapper
threadWrapper:SentryDependencyContainer.sharedInstance.threadWrapper];
}

- (instancetype)initWithTimeoutInterval:(NSTimeInterval)timeoutInterval
crashWrapper:(SentryCrashWrapper *)crashWrapper
dispatchQueueWrapper:(SentryDispatchQueueWrapper *)dispatchQueueWrapper
Expand All @@ -45,11 +54,6 @@ - (instancetype)initWithTimeoutInterval:(NSTimeInterval)timeoutInterval
return self;
}

- (id<SentryANRTracker>)asProtocol
{
return self;
}

- (void)detectANRs
{
NSUUID *threadID = [NSUUID UUID];
Expand Down
17 changes: 11 additions & 6 deletions Sources/Sentry/SentryANRTrackerV2.m
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ typedef NS_ENUM(NSInteger, SentryANRTrackerState) {
kSentryANRTrackerStopping
};

@interface SentryANRTrackerV2 () <SentryANRTracker>
@interface SentryANRTrackerV2 ()

@property (nonatomic, strong) SentryCrashWrapper *crashWrapper;
@property (nonatomic, strong) SentryDispatchQueueWrapper *dispatchQueueWrapper;
Expand All @@ -33,6 +33,16 @@ @implementation SentryANRTrackerV2 {
SentryANRTrackerState state;
}

- (instancetype)initWithTimeoutInterval:(NSTimeInterval)timeoutInterval
{
return
[self initWithTimeoutInterval:timeoutInterval
crashWrapper:SentryDependencyContainer.sharedInstance.crashWrapper
dispatchQueueWrapper:SentryDependencyContainer.sharedInstance.dispatchQueueWrapper
threadWrapper:SentryDependencyContainer.sharedInstance.threadWrapper
framesTracker:SentryDependencyContainer.sharedInstance.framesTracker];
}

- (instancetype)initWithTimeoutInterval:(NSTimeInterval)timeoutInterval
crashWrapper:(SentryCrashWrapper *)crashWrapper
dispatchQueueWrapper:(SentryDispatchQueueWrapper *)dispatchQueueWrapper
Expand All @@ -52,11 +62,6 @@ - (instancetype)initWithTimeoutInterval:(NSTimeInterval)timeoutInterval
return self;
}

- (id<SentryANRTracker>)asProtocol
{
return self;
}

- (void)detectANRs
{
NSUUID *threadID = [NSUUID UUID];
Expand Down
2 changes: 1 addition & 1 deletion Sources/Sentry/SentryANRTrackingIntegration.m
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

@interface SentryANRTrackingIntegration () <SentryANRTrackerDelegate>

@property (nonatomic, strong) id<SentryANRTracker> tracker;
@property (nonatomic, strong) SentryANRTracker *tracker;
@property (nonatomic, strong) SentryOptions *options;
@property (nonatomic, strong) SentryFileManager *fileManager;
@property (nonatomic, strong) SentryDispatchQueueWrapper *dispatchQueueWrapper;
Expand Down
1 change: 1 addition & 0 deletions Sources/Sentry/SentryAutoBreadcrumbTrackingIntegration.m
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#import "SentryLogC.h"
#import "SentryOptions.h"
#import "SentrySDKInternal.h"
#import "SentrySwift.h"
#import "SentrySystemEventBreadcrumbs.h"

NS_ASSUME_NONNULL_BEGIN
Expand Down
1 change: 1 addition & 0 deletions Sources/Sentry/SentryCoreDataTrackingIntegration.m
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#import "SentryLogC.h"
#import "SentryNSDataSwizzling.h"
#import "SentryOptions.h"
#import "SentrySwift.h"

@interface SentryCoreDataTrackingIntegration ()

Expand Down
8 changes: 8 additions & 0 deletions Sources/Sentry/SentryDelayedFramesTracker.m
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#if SENTRY_HAS_UIKIT

# import "SentryDelayedFrame.h"
# import "SentryDependencyContainer.h"
# import "SentryInternalCDefines.h"
# import "SentryLogC.h"
# import "SentrySwift.h"
Expand All @@ -22,6 +23,13 @@ @interface SentryDelayedFramesTracker ()

@implementation SentryDelayedFramesTracker

- (instancetype)initWithKeepDelayedFramesDuration:(CFTimeInterval)keepDelayedFramesDuration
{
return [self
initWithKeepDelayedFramesDuration:keepDelayedFramesDuration
dateProvider:SentryDependencyContainer.sharedInstance.dateProvider];
}

- (instancetype)initWithKeepDelayedFramesDuration:(CFTimeInterval)keepDelayedFramesDuration
dateProvider:(id<SentryCurrentDateProvider>)dateProvider
{
Expand Down
36 changes: 23 additions & 13 deletions Sources/Sentry/SentryDependencyContainer.m
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@
return nil;
};

@interface SentryANRTrackerV1 () <SentryANRTrackerProtocol>
@end

@interface SentryFileManager () <SentryFileManagerProtocol>
@end

Expand All @@ -62,11 +65,14 @@ @interface SentryWatchdogTerminationScopeObserver () <SentryScopeObserver>

@interface SentryDelayedFramesTracker () <SentryDelayedFramesTrackerWrapper>
@end

@interface SentryANRTrackerV2 () <SentryANRTrackerProtocol>
@end
#endif

@interface SentryDependencyContainer ()

@property (nonatomic, strong) id<SentryANRTracker> anrTracker;
@property (nonatomic, strong) SentryANRTracker *anrTracker;

@end

Expand Down Expand Up @@ -236,27 +242,31 @@ - (SentryCrashSwift *)crashReporter SENTRY_THREAD_SANITIZER_DOUBLE_CHECKED_LOCK
[[SentryCrashSwift alloc] initWith:SentrySDKInternal.options.cacheDirectoryPath]);
}

- (id<SentryANRTracker>)getANRTracker:(NSTimeInterval)timeout
- (SentryANRTracker *)getANRTracker:(NSTimeInterval)timeout
SENTRY_THREAD_SANITIZER_DOUBLE_CHECKED_LOCK
{
SENTRY_LAZY_INIT(_anrTracker,
[[[SentryANRTrackerV1 alloc] initWithTimeoutInterval:timeout
crashWrapper:self.crashWrapper
dispatchQueueWrapper:self.dispatchQueueWrapper
threadWrapper:self.threadWrapper] asProtocol]);
[[SentryANRTracker alloc]
initWithHelper:[[SentryANRTrackerV1 alloc]
initWithTimeoutInterval:timeout
crashWrapper:self.crashWrapper
dispatchQueueWrapper:self.dispatchQueueWrapper
threadWrapper:self.threadWrapper]]);
}

#if SENTRY_HAS_UIKIT
- (id<SentryANRTracker>)getANRTracker:(NSTimeInterval)timeout
isV2Enabled:(BOOL)isV2Enabled SENTRY_THREAD_SANITIZER_DOUBLE_CHECKED_LOCK
- (SentryANRTracker *)getANRTracker:(NSTimeInterval)timeout
isV2Enabled:(BOOL)isV2Enabled SENTRY_THREAD_SANITIZER_DOUBLE_CHECKED_LOCK
{
if (isV2Enabled) {
SENTRY_LAZY_INIT(_anrTracker,
[[[SentryANRTrackerV2 alloc] initWithTimeoutInterval:timeout
crashWrapper:self.crashWrapper
dispatchQueueWrapper:self.dispatchQueueWrapper
threadWrapper:self.threadWrapper
framesTracker:self.framesTracker] asProtocol]);
[[SentryANRTracker alloc]
initWithHelper:[[SentryANRTrackerV2 alloc]
initWithTimeoutInterval:timeout
crashWrapper:self.crashWrapper
dispatchQueueWrapper:self.dispatchQueueWrapper
threadWrapper:self.threadWrapper
framesTracker:self.framesTracker]]);
} else {
return [self getANRTracker:timeout];
}
Expand Down
5 changes: 5 additions & 0 deletions Sources/Sentry/SentryDependencyContainerSwiftHelper.m
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@ @implementation SentryDependencyContainerSwiftHelper

#endif // SENTRY_HAS_UIKIT

+ (SentryDispatchQueueWrapper *)dispatchQueueWrapper
{
return SentryDependencyContainer.sharedInstance.dispatchQueueWrapper;
}

+ (void)dispatchSyncOnMainQueue:(void (^)(void))block
{
[SentryDependencyContainer.sharedInstance.dispatchQueueWrapper dispatchSyncOnMainQueue:block];
Expand Down
4 changes: 2 additions & 2 deletions Sources/Sentry/SentryProfiler.mm
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#if SENTRY_TARGET_PROFILING_SUPPORTED
# import "SentryClient+Private.h"
# import "SentryContinuousProfiler.h"
# import "SentryDependencyContainer.h"
# import "SentryDependencyContainerSwiftHelper.h"
# import "SentryFileManagerHelper.h"
# import "SentryHub+Private.h"
# import "SentryInternalDefines.h"
Expand Down Expand Up @@ -121,7 +121,7 @@

sentry_configureContinuousProfiling(options);

sentry_dispatchAsync(SentryDependencyContainer.sharedInstance.dispatchQueueWrapper, ^{
sentry_dispatchAsync(SentryDependencyContainerSwiftHelper.dispatchQueueWrapper, ^{
if (configurationFromLaunch.isProfilingThisLaunch) {
BOOL shouldStopAndTransmitLaunchProfile = YES;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,13 @@
# import <SentrySwift.h>
# import <SentryWatchdogTerminationBreadcrumbProcessor.h>
# import <SentryWatchdogTerminationLogic.h>
# import <SentryWatchdogTerminationScopeObserver.h>
# import <SentryWatchdogTerminationTracker.h>
NS_ASSUME_NONNULL_BEGIN

@interface SentryWatchdogTerminationTrackingIntegration () <SentryANRTrackerDelegate>

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@
@class SentrySessionTracker;
@class SentryGlobalEventProcessor;
@class SentryThreadInspector;
@class SentryANRTracker;
@class SentryReachability;

@protocol SentryANRTracker;
@protocol SentryRandomProtocol;
@protocol SentryCurrentDateProvider;
@protocol SentryRateLimits;
Expand Down Expand Up @@ -106,9 +106,9 @@ SENTRY_NO_INIT
@property (nonatomic, strong, nullable) SentryScopePersistentStore *scopePersistentStore;
@property (nonatomic, strong) SentryDebugImageProvider *debugImageProvider;

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

- (nullable id<SentryApplication>)application;
Expand Down
8 changes: 6 additions & 2 deletions Sources/Sentry/include/SentryANRTrackerV1.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
@class SentryCrashWrapper;
@class SentryDispatchQueueWrapper;
@class SentryThreadWrapper;
@protocol SentryANRTracker;
@protocol SentryANRTrackerDelegate;

NS_ASSUME_NONNULL_BEGIN

Expand All @@ -24,12 +24,16 @@ NS_ASSUME_NONNULL_BEGIN
@interface SentryANRTrackerV1 : NSObject
SENTRY_NO_INIT

- (instancetype)initWithTimeoutInterval:(NSTimeInterval)timeoutInterval;

- (instancetype)initWithTimeoutInterval:(NSTimeInterval)timeoutInterval
crashWrapper:(SentryCrashWrapper *)crashWrapper
dispatchQueueWrapper:(SentryDispatchQueueWrapper *)dispatchQueueWrapper
threadWrapper:(SentryThreadWrapper *)threadWrapper;

- (id<SentryANRTracker>)asProtocol;
- (void)addListener:(id<SentryANRTrackerDelegate>)listener;
- (void)removeListener:(id<SentryANRTrackerDelegate>)listener;
- (void)clear;

@end

Expand Down
8 changes: 6 additions & 2 deletions Sources/Sentry/include/SentryANRTrackerV2.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
@class SentryDispatchQueueWrapper;
@class SentryThreadWrapper;
@class SentryFramesTracker;
@protocol SentryANRTracker;
@protocol SentryANRTrackerDelegate;

NS_ASSUME_NONNULL_BEGIN

Expand All @@ -23,13 +23,17 @@ NS_ASSUME_NONNULL_BEGIN
@interface SentryANRTrackerV2 : NSObject
SENTRY_NO_INIT

- (instancetype)initWithTimeoutInterval:(NSTimeInterval)timeoutInterval;

- (instancetype)initWithTimeoutInterval:(NSTimeInterval)timeoutInterval
crashWrapper:(SentryCrashWrapper *)crashWrapper
dispatchQueueWrapper:(SentryDispatchQueueWrapper *)dispatchQueueWrapper
threadWrapper:(SentryThreadWrapper *)threadWrapper
framesTracker:(SentryFramesTracker *)framesTracker;

- (id<SentryANRTracker>)asProtocol;
- (void)addListener:(id<SentryANRTrackerDelegate>)listener;
- (void)removeListener:(id<SentryANRTrackerDelegate>)listener;
- (void)clear;

@end

Expand Down
9 changes: 9 additions & 0 deletions Sources/Sentry/include/SentryDelayedFramesTracker.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,15 @@ NS_ASSUME_NONNULL_BEGIN
@interface SentryDelayedFramesTracker : NSObject
SENTRY_NO_INIT

/**
* Initializes a @c SentryDelayedFramesTracker. This class keeps track of information on delayed
* frames. Whenever a new delayed frame is recorded, it removes recorded delayed frames older than
* the current time minus the @c keepDelayedFramesDuration.
*
* @param keepDelayedFramesDuration The maximum duration to keep delayed frames records in memory.
*/
- (instancetype)initWithKeepDelayedFramesDuration:(CFTimeInterval)keepDelayedFramesDuration;

/**
* Initializes a @c SentryDelayedFramesTracker. This class keeps track of information on delayed
* frames. Whenever a new delayed frame is recorded, it removes recorded delayed frames older than
Expand Down
Loading
Loading