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
4 changes: 2 additions & 2 deletions Sources/Sentry/SentryAppStartTracker.m
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ @interface SentryAppStartTracker () <SentryFramesTrackerListener>

@property (nonatomic, strong, nullable) SentryAppState *previousAppState;
@property (nonatomic, strong) SentryDispatchQueueWrapper *dispatchQueue;
@property (nonatomic, strong) id<SentryAppStateManager> appStateManager;
@property (nonatomic, strong) SentryAppStateManager *appStateManager;
@property (nonatomic, strong) SentryFramesTracker *framesTracker;
@property (nonatomic, assign) BOOL wasInBackground;
@property (nonatomic, strong) NSDate *didFinishLaunchingTimestamp;
Expand All @@ -51,7 +51,7 @@ + (void)load
}

- (instancetype)initWithDispatchQueueWrapper:(SentryDispatchQueueWrapper *)dispatchQueueWrapper
appStateManager:(id<SentryAppStateManager>)appStateManager
appStateManager:(SentryAppStateManager *)appStateManager
framesTracker:(SentryFramesTracker *)framesTracker
enablePreWarmedAppStartTracing:(BOOL)enablePreWarmedAppStartTracing
{
Expand Down
2 changes: 1 addition & 1 deletion Sources/Sentry/SentryAppStartTrackingIntegration.m
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ - (BOOL)installWithOptions:(SentryOptions *)options
return NO;
}

id<SentryAppStateManager> appStateManager =
SentryAppStateManager *appStateManager =
[SentryDependencyContainer sharedInstance].appStateManager;

self.tracker = [[SentryAppStartTracker alloc]
Expand Down
2 changes: 1 addition & 1 deletion Sources/Sentry/SentryCrashIntegration.m
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ - (BOOL)installWithOptions:(nonnull SentryOptions *)options
self.options = options;

#if SENTRY_HAS_UIKIT
id<SentryAppStateManager> appStateManager =
SentryAppStateManager *appStateManager =
[SentryDependencyContainer sharedInstance].appStateManager;
SentryWatchdogTerminationLogic *logic =
[[SentryWatchdogTerminationLogic alloc] initWithOptions:options
Expand Down
83 changes: 20 additions & 63 deletions Sources/Sentry/SentryDefaultAppStateManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -12,29 +12,31 @@

@interface SentryDefaultAppStateManager ()

@property (nonatomic, strong) SentryOptions *options;
@property (nonatomic, strong) SentryCrashWrapper *crashWrapper;
@property (nonatomic, strong) SentryFileManager *fileManager;
@property (nonatomic, strong) SentryDispatchQueueWrapper *dispatchQueue;
@property (nonatomic, strong) id<SentryNSNotificationCenterWrapper> notificationCenterWrapper;
@property (nonatomic, copy) void (^storeCurrent)(void);
@property (nonatomic, copy) void (^updateTerminated)(void);
@property (nonatomic, copy) void (^updateSDKNotRunning)(void);
@property (nonatomic, copy) void (^updateActive)(BOOL);
@property (nonatomic) NSInteger startCount;

@end

@implementation SentryDefaultAppStateManager

- (instancetype)initWithOptions:(SentryOptions *_Nullable)options
crashWrapper:(SentryCrashWrapper *)crashWrapper
fileManager:(SentryFileManager *_Nullable)fileManager
dispatchQueueWrapper:(SentryDispatchQueueWrapper *)dispatchQueueWrapper
notificationCenterWrapper:(id<SentryNSNotificationCenterWrapper>)notificationCenterWrapper
- (instancetype)initWithStoreCurrent:(void (^)(void))storeCurrent
updateTerminated:(void (^)(void))updateTerminated
updateSDKNotRunning:(void (^)(void))updateSDKNotRunning
updateActive:(void (^)(BOOL))updateActive
{
if (self = [super init]) {
self.options = options;
self.crashWrapper = crashWrapper;
self.fileManager = fileManager;
self.dispatchQueue = dispatchQueueWrapper;
self.notificationCenterWrapper = notificationCenterWrapper;
self.dispatchQueue = SentryDependencyContainer.sharedInstance.dispatchQueueWrapper;
self.notificationCenterWrapper
= SentryDependencyContainer.sharedInstance.notificationCenterWrapper;
self.storeCurrent = storeCurrent;
self.updateTerminated = updateTerminated;
self.updateSDKNotRunning = updateSDKNotRunning;
self.updateActive = updateActive;
self.startCount = 0;
}
return self;
Expand Down Expand Up @@ -65,7 +67,7 @@ - (void)start
name:SentryWillTerminateNotification
object:nil];

[self storeCurrentAppState];
self.storeCurrent();
}

self.startCount += 1;
Expand All @@ -84,8 +86,7 @@ - (void)stopWithForce:(BOOL)forceStop
}

if (forceStop) {
[self
updateAppStateInBackground:^(SentryAppState *appState) { appState.isSDKRunning = NO; }];
[self.dispatchQueue dispatchAsyncWithBlock:^{ self.updateSDKNotRunning(); }];

self.startCount = 0;
} else {
Expand Down Expand Up @@ -130,7 +131,7 @@ - (void)dealloc
*/
- (void)didBecomeActive
{
[self updateAppStateInBackground:^(SentryAppState *appState) { appState.isActive = YES; }];
[self.dispatchQueue dispatchAsyncWithBlock:^{ self.updateActive(YES); }];
}

/**
Expand All @@ -139,59 +140,15 @@ - (void)didBecomeActive
*/
- (void)willResignActive
{
[self updateAppStateInBackground:^(SentryAppState *appState) { appState.isActive = NO; }];
[self.dispatchQueue dispatchAsyncWithBlock:^{ self.updateActive(NO); }];
}

- (void)willTerminate
{
// The app is terminating so it is fine to do this on the main thread.
// Furthermore, so users can manually post UIApplicationWillTerminateNotification and then call
// exit(0), to avoid getting false watchdog terminations when using exit(0), see GH-1252.
[self updateAppState:^(SentryAppState *appState) { appState.wasTerminated = YES; }];
}

- (void)updateAppStateInBackground:(void (^)(SentryAppState *))block
{
// We accept the tradeoff that the app state might not be 100% up to date over blocking the main
// thread.
[self.dispatchQueue dispatchAsyncWithBlock:^{ [self updateAppState:block]; }];
}

- (void)updateAppState:(void (^)(SentryAppState *))block
{
@synchronized(self) {
SentryAppState *appState = [self.fileManager readAppState];
if (appState != nil) {
block(appState);
[self.fileManager storeAppState:appState];
}
}
}

- (SentryAppState *)buildCurrentAppState
{
// Is the current process being traced or not? If it is a debugger is attached.
bool isDebugging = self.crashWrapper.isBeingTraced;

UIDevice *device = [UIDevice currentDevice];
NSString *vendorId = [device.identifierForVendor UUIDString];

return [[SentryAppState alloc] initWithReleaseName:self.options.releaseName
osVersion:device.systemVersion
vendorId:vendorId
isDebugging:isDebugging
systemBootTimestamp:SentryDependencyContainer.sharedInstance
.sysctlWrapper.systemBootTimestamp];
}

- (nullable SentryAppState *)loadPreviousAppState
{
return [self.fileManager readPreviousAppState];
}

- (void)storeCurrentAppState
{
[self.fileManager storeAppState:[self buildCurrentAppState]];
self.updateTerminated();
}

#endif
Expand Down
15 changes: 5 additions & 10 deletions Sources/Sentry/SentryDependencyContainer.m
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
#import "SentrySwift.h"
#import "SentrySystemWrapper.h"
#import <SentryDebugImageProvider+HybridSDKs.h>
#import <SentryDefaultAppStateManager.h>
#import <SentryDefaultUIViewControllerPerformanceTracker.h>
#import <SentryDependencyContainer.h>
#import <SentryPerformanceTracker.h>
Expand Down Expand Up @@ -58,9 +57,6 @@
@interface SentryFileManager () <SentryFileManagerProtocol>
@end

@interface SentryDefaultAppStateManager () <SentryAppStateManager>
@end

#if SENTRY_HAS_UIKIT
@interface SentryWatchdogTerminationScopeObserver () <SentryScopeObserver>
@end
Expand Down Expand Up @@ -218,14 +214,13 @@ - (nullable SentryFileManager *)fileManager SENTRY_THREAD_SANITIZER_DOUBLE_CHECK
}));
}

- (id<SentryAppStateManager>)appStateManager SENTRY_THREAD_SANITIZER_DOUBLE_CHECKED_LOCK
- (SentryAppStateManager *)appStateManager SENTRY_THREAD_SANITIZER_DOUBLE_CHECKED_LOCK
{
SENTRY_LAZY_INIT(_appStateManager,
[[SentryDefaultAppStateManager alloc] initWithOptions:SentrySDKInternal.options
crashWrapper:self.crashWrapper
fileManager:self.fileManager
dispatchQueueWrapper:self.dispatchQueueWrapper
notificationCenterWrapper:self.notificationCenterWrapper]);
[[SentryAppStateManager alloc] initWithOptions:SentrySDKInternal.options
crashWrapper:self.crashWrapper
fileManager:self.fileManager
sysctlWrapper:self.sysctlWrapper]);
}
- (SentryThreadInspector *)threadInspector
{
Expand Down
4 changes: 2 additions & 2 deletions Sources/Sentry/SentryWatchdogTerminationLogic.m
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@

@property (nonatomic, strong) SentryOptions *options;
@property (nonatomic, strong) SentryCrashWrapper *crashAdapter;
@property (nonatomic, strong) id<SentryAppStateManager> appStateManager;
@property (nonatomic, strong) SentryAppStateManager *appStateManager;

@end

@implementation SentryWatchdogTerminationLogic

- (instancetype)initWithOptions:(SentryOptions *)options
crashAdapter:(SentryCrashWrapper *)crashAdapter
appStateManager:(id<SentryAppStateManager>)appStateManager
appStateManager:(SentryAppStateManager *)appStateManager
{
if (self = [super init]) {
self.options = options;
Expand Down Expand Up @@ -67,7 +67,7 @@

// This value can change when installing test builds using Xcode or when installing an app
// on a device using ad-hoc distribution.
if (![currentAppState.vendorId isEqualToString:previousAppState.vendorId]) {

Check warning on line 70 in Sources/Sentry/SentryWatchdogTerminationLogic.m

View workflow job for this annotation

GitHub Actions / Check compiling Async Safe Logs

implicit conversion from nullable pointer 'NSString * _Nullable' to non-nullable pointer type 'NSString * _Nonnull' [-Wnullable-to-nonnull-conversion]

Check warning on line 70 in Sources/Sentry/SentryWatchdogTerminationLogic.m

View workflow job for this annotation

GitHub Actions / Check UIKit linkage (Debug)

implicit conversion from nullable pointer 'NSString * _Nullable' to non-nullable pointer type 'NSString * _Nonnull' [-Wnullable-to-nonnull-conversion]

Check warning on line 70 in Sources/Sentry/SentryWatchdogTerminationLogic.m

View workflow job for this annotation

GitHub Actions / Check UIKit linkage (Release)

implicit conversion from nullable pointer 'NSString * _Nullable' to non-nullable pointer type 'NSString * _Nonnull' [-Wnullable-to-nonnull-conversion]

Check warning on line 70 in Sources/Sentry/SentryWatchdogTerminationLogic.m

View workflow job for this annotation

GitHub Actions / Build SDK v9

implicit conversion from nullable pointer 'NSString * _Nullable' to non-nullable pointer type 'NSString * _Nonnull' [-Wnullable-to-nonnull-conversion]

Check warning on line 70 in Sources/Sentry/SentryWatchdogTerminationLogic.m

View workflow job for this annotation

GitHub Actions / Sample visionOS-Swift DebugV9

implicit conversion from nullable pointer 'NSString * _Nullable' to non-nullable pointer type 'NSString * _Nonnull' [-Wnullable-to-nonnull-conversion]

Check warning on line 70 in Sources/Sentry/SentryWatchdogTerminationLogic.m

View workflow job for this annotation

GitHub Actions / Sample SessionReplay-CameraTest Debug

implicit conversion from nullable pointer 'NSString * _Nullable' to non-nullable pointer type 'NSString * _Nonnull' [-Wnullable-to-nonnull-conversion]

Check warning on line 70 in Sources/Sentry/SentryWatchdogTerminationLogic.m

View workflow job for this annotation

GitHub Actions / Build XCFramework Slices (Sentry, staticlib, sentry-static) / xros

implicit conversion from nullable pointer 'NSString * _Nullable' to non-nullable pointer type 'NSString * _Nonnull' [-Wnullable-to-nonnull-conversion]

Check warning on line 70 in Sources/Sentry/SentryWatchdogTerminationLogic.m

View workflow job for this annotation

GitHub Actions / Sample iOS-Swift DebugV9

implicit conversion from nullable pointer 'NSString * _Nullable' to non-nullable pointer type 'NSString * _Nonnull' [-Wnullable-to-nonnull-conversion]

Check warning on line 70 in Sources/Sentry/SentryWatchdogTerminationLogic.m

View workflow job for this annotation

GitHub Actions / Sample iOS-SwiftUI DebugV9

implicit conversion from nullable pointer 'NSString * _Nullable' to non-nullable pointer type 'NSString * _Nonnull' [-Wnullable-to-nonnull-conversion]

Check warning on line 70 in Sources/Sentry/SentryWatchdogTerminationLogic.m

View workflow job for this annotation

GitHub Actions / Check API Stability ()

implicit conversion from nullable pointer 'NSString * _Nullable' to non-nullable pointer type 'NSString * _Nonnull' [-Wnullable-to-nonnull-conversion]

Check warning on line 70 in Sources/Sentry/SentryWatchdogTerminationLogic.m

View workflow job for this annotation

GitHub Actions / Build XCFramework Slices (SentrySwiftUI, mh_dylib, sentry-swiftui) / iphonesimulator

implicit conversion from nullable pointer 'NSString * _Nullable' to non-nullable pointer type 'NSString * _Nonnull' [-Wnullable-to-nonnull-conversion]

Check warning on line 70 in Sources/Sentry/SentryWatchdogTerminationLogic.m

View workflow job for this annotation

GitHub Actions / Build XCFramework Slices (Sentry, staticlib, sentry-static) / iphoneos

implicit conversion from nullable pointer 'NSString * _Nullable' to non-nullable pointer type 'NSString * _Nonnull' [-Wnullable-to-nonnull-conversion]

Check warning on line 70 in Sources/Sentry/SentryWatchdogTerminationLogic.m

View workflow job for this annotation

GitHub Actions / Build XCFramework Slices (Sentry, staticlib, sentry-static) / iphonesimulator

implicit conversion from nullable pointer 'NSString * _Nullable' to non-nullable pointer type 'NSString * _Nonnull' [-Wnullable-to-nonnull-conversion]

Check warning on line 70 in Sources/Sentry/SentryWatchdogTerminationLogic.m

View workflow job for this annotation

GitHub Actions / Build XCFramework Slices (Sentry, mh_dylib, -Dynamic, sentry-dynamic) / iphonesimulator

implicit conversion from nullable pointer 'NSString * _Nullable' to non-nullable pointer type 'NSString * _Nonnull' [-Wnullable-to-nonnull-conversion]

Check warning on line 70 in Sources/Sentry/SentryWatchdogTerminationLogic.m

View workflow job for this annotation

GitHub Actions / Sample iOS-ObjectiveC DebugV9

implicit conversion from nullable pointer 'NSString * _Nullable' to non-nullable pointer type 'NSString * _Nonnull' [-Wnullable-to-nonnull-conversion]

Check warning on line 70 in Sources/Sentry/SentryWatchdogTerminationLogic.m

View workflow job for this annotation

GitHub Actions / Sample visionOS-Swift Debug

implicit conversion from nullable pointer 'NSString * _Nullable' to non-nullable pointer type 'NSString * _Nonnull' [-Wnullable-to-nonnull-conversion]

Check warning on line 70 in Sources/Sentry/SentryWatchdogTerminationLogic.m

View workflow job for this annotation

GitHub Actions / Build XCFramework Slices (Sentry, mh_dylib, -Dynamic, sentry-dynamic) / appletvos

implicit conversion from nullable pointer 'NSString * _Nullable' to non-nullable pointer type 'NSString * _Nonnull' [-Wnullable-to-nonnull-conversion]

Check warning on line 70 in Sources/Sentry/SentryWatchdogTerminationLogic.m

View workflow job for this annotation

GitHub Actions / Build XCFramework Slices (Sentry, staticlib, sentry-static) / maccatalyst

implicit conversion from nullable pointer 'NSString * _Nullable' to non-nullable pointer type 'NSString * _Nonnull' [-Wnullable-to-nonnull-conversion]

Check warning on line 70 in Sources/Sentry/SentryWatchdogTerminationLogic.m

View workflow job for this annotation

GitHub Actions / Build XCFramework Slices (SentrySwiftUI, mh_dylib, sentry-swiftui) / maccatalyst

implicit conversion from nullable pointer 'NSString * _Nullable' to non-nullable pointer type 'NSString * _Nonnull' [-Wnullable-to-nonnull-conversion]

Check warning on line 70 in Sources/Sentry/SentryWatchdogTerminationLogic.m

View workflow job for this annotation

GitHub Actions / Build XCFramework Slices (Sentry, mh_dylib, -Dynamic, sentry-dynamic) / iphoneos

implicit conversion from nullable pointer 'NSString * _Nullable' to non-nullable pointer type 'NSString * _Nonnull' [-Wnullable-to-nonnull-conversion]

Check warning on line 70 in Sources/Sentry/SentryWatchdogTerminationLogic.m

View workflow job for this annotation

GitHub Actions / Build XCFramework Slices (Sentry, mh_dylib, -Dynamic, sentry-dynamic) / maccatalyst

implicit conversion from nullable pointer 'NSString * _Nullable' to non-nullable pointer type 'NSString * _Nonnull' [-Wnullable-to-nonnull-conversion]

Check warning on line 70 in Sources/Sentry/SentryWatchdogTerminationLogic.m

View workflow job for this annotation

GitHub Actions / Build XCFramework Slices (SentrySwiftUI, mh_dylib, sentry-swiftui) / appletvos

implicit conversion from nullable pointer 'NSString * _Nullable' to non-nullable pointer type 'NSString * _Nonnull' [-Wnullable-to-nonnull-conversion]

Check warning on line 70 in Sources/Sentry/SentryWatchdogTerminationLogic.m

View workflow job for this annotation

GitHub Actions / Build XCFramework Slices (SentrySwiftUI, mh_dylib, sentry-swiftui) / xros

implicit conversion from nullable pointer 'NSString * _Nullable' to non-nullable pointer type 'NSString * _Nonnull' [-Wnullable-to-nonnull-conversion]

Check warning on line 70 in Sources/Sentry/SentryWatchdogTerminationLogic.m

View workflow job for this annotation

GitHub Actions / Sample tvOS-Swift DebugV9

implicit conversion from nullable pointer 'NSString * _Nullable' to non-nullable pointer type 'NSString * _Nonnull' [-Wnullable-to-nonnull-conversion]

Check warning on line 70 in Sources/Sentry/SentryWatchdogTerminationLogic.m

View workflow job for this annotation

GitHub Actions / Build XCFramework Slices (SentrySwiftUI, mh_dylib, sentry-swiftui) / iphoneos

implicit conversion from nullable pointer 'NSString * _Nullable' to non-nullable pointer type 'NSString * _Nonnull' [-Wnullable-to-nonnull-conversion]

Check warning on line 70 in Sources/Sentry/SentryWatchdogTerminationLogic.m

View workflow job for this annotation

GitHub Actions / Build XCFramework Slices (Sentry, staticlib, sentry-static) / appletvos

implicit conversion from nullable pointer 'NSString * _Nullable' to non-nullable pointer type 'NSString * _Nonnull' [-Wnullable-to-nonnull-conversion]

Check warning on line 70 in Sources/Sentry/SentryWatchdogTerminationLogic.m

View workflow job for this annotation

GitHub Actions / Build XCFramework Slices (Sentry, mh_dylib, -Dynamic, sentry-dynamic) / xros

implicit conversion from nullable pointer 'NSString * _Nullable' to non-nullable pointer type 'NSString * _Nonnull' [-Wnullable-to-nonnull-conversion]

Check warning on line 70 in Sources/Sentry/SentryWatchdogTerminationLogic.m

View workflow job for this annotation

GitHub Actions / Run SwiftUI Crash Test

implicit conversion from nullable pointer 'NSString * _Nullable' to non-nullable pointer type 'NSString * _Nonnull' [-Wnullable-to-nonnull-conversion]

Check warning on line 70 in Sources/Sentry/SentryWatchdogTerminationLogic.m

View workflow job for this annotation

GitHub Actions / Unit Catalyst 15 Sentry

implicit conversion from nullable pointer 'NSString * _Nullable' to non-nullable pointer type 'NSString * _Nonnull' [-Wnullable-to-nonnull-conversion]

Check warning on line 70 in Sources/Sentry/SentryWatchdogTerminationLogic.m

View workflow job for this annotation

GitHub Actions / Unit iOS 17 Sentry

implicit conversion from nullable pointer 'NSString * _Nullable' to non-nullable pointer type 'NSString * _Nonnull' [-Wnullable-to-nonnull-conversion]

Check warning on line 70 in Sources/Sentry/SentryWatchdogTerminationLogic.m

View workflow job for this annotation

GitHub Actions / Unit iOS 16 Sentry

implicit conversion from nullable pointer 'NSString * _Nullable' to non-nullable pointer type 'NSString * _Nonnull' [-Wnullable-to-nonnull-conversion]

Check warning on line 70 in Sources/Sentry/SentryWatchdogTerminationLogic.m

View workflow job for this annotation

GitHub Actions / Unit iOS 26 Sentry

implicit conversion from nullable pointer 'NSString * _Nullable' to non-nullable pointer type 'NSString * _Nonnull' [-Wnullable-to-nonnull-conversion]
return NO;
}

Expand Down
4 changes: 2 additions & 2 deletions Sources/Sentry/SentryWatchdogTerminationTracker.m
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ @interface SentryWatchdogTerminationTracker ()
@property (nonatomic, strong) SentryOptions *options;
@property (nonatomic, strong) SentryWatchdogTerminationLogic *watchdogTerminationLogic;
@property (nonatomic, strong) SentryDispatchQueueWrapper *dispatchQueue;
@property (nonatomic, strong) id<SentryAppStateManager> appStateManager;
@property (nonatomic, strong) SentryAppStateManager *appStateManager;
@property (nonatomic, strong) SentryFileManager *fileManager;
@property (nonatomic, strong) SentryScopePersistentStore *scopePersistentStore;

Expand All @@ -27,7 +27,7 @@ @implementation SentryWatchdogTerminationTracker

- (instancetype)initWithOptions:(SentryOptions *)options
watchdogTerminationLogic:(SentryWatchdogTerminationLogic *)watchdogTerminationLogic
appStateManager:(id<SentryAppStateManager>)appStateManager
appStateManager:(SentryAppStateManager *)appStateManager
dispatchQueueWrapper:(SentryDispatchQueueWrapper *)dispatchQueueWrapper
fileManager:(SentryFileManager *)fileManager
scopePersistentStore:(SentryScopePersistentStore *)scopePersistentStore
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ @interface SentryWatchdogTerminationTrackingIntegration () <SentryANRTrackerDele
@property (nonatomic, strong) SentryWatchdogTerminationTracker *tracker;
@property (nonatomic, strong) id<SentryANRTracker> anrTracker;
@property (nullable, nonatomic, copy) NSString *testConfigurationFilePath;
@property (nonatomic, strong) id<SentryAppStateManager> appStateManager;
@property (nonatomic, strong) SentryAppStateManager *appStateManager;

@end

Expand Down Expand Up @@ -56,7 +56,7 @@ - (BOOL)installWithOptions:(SentryOptions *)options
attributes:attributes];

SentryFileManager *fileManager = [[[SentrySDKInternal currentHub] getClient] fileManager];
id<SentryAppStateManager> appStateManager =
SentryAppStateManager *appStateManager =
[SentryDependencyContainer sharedInstance].appStateManager;
SentryCrashWrapper *crashWrapper = [SentryDependencyContainer sharedInstance].crashWrapper;
SentryWatchdogTerminationLogic *logic =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@
@class SentryFileIOTracker;
@class SentryScopePersistentStore;
@class SentryOptions;
@class SentryAppStateManager;
@class SentrySessionTracker;
@class SentryGlobalEventProcessor;
@class SentryThreadInspector;
@class SentryReachability;

@protocol SentryAppStateManager;
@protocol SentryANRTracker;
@protocol SentryRandomProtocol;
@protocol SentryCurrentDateProvider;
Expand Down Expand Up @@ -99,7 +99,7 @@ SENTRY_NO_INIT
#pragma mark - Lazy Dependencies

@property (nonatomic, strong, nullable) SentryFileManager *fileManager;
@property (nonatomic, strong) id<SentryAppStateManager> appStateManager;
@property (nonatomic, strong) SentryAppStateManager *appStateManager;
@property (nonatomic, strong, readonly) SentryThreadInspector *threadInspector;
@property (nonatomic, strong, readonly) SentryFileIOTracker *fileIOTracker;
@property (nonatomic, strong) SentryCrashSwift *crashReporter;
Expand Down
4 changes: 2 additions & 2 deletions Sources/Sentry/include/SentryAppStartTracker.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#if SENTRY_HAS_UIKIT

@class SentryDispatchQueueWrapper;
@protocol SentryAppStateManager;
@class SentryAppStateManager;
@class SentryFramesTracker;

NS_ASSUME_NONNULL_BEGIN
Expand All @@ -20,7 +20,7 @@ SENTRY_NO_INIT
@property (nonatomic) BOOL isRunning;

- (instancetype)initWithDispatchQueueWrapper:(SentryDispatchQueueWrapper *)dispatchQueueWrapper
appStateManager:(id<SentryAppStateManager>)appStateManager
appStateManager:(SentryAppStateManager *)appStateManager
framesTracker:(SentryFramesTracker *)framesTracker
enablePreWarmedAppStartTracing:(BOOL)enablePreWarmedAppStartTracing;

Expand Down
24 changes: 4 additions & 20 deletions Sources/Sentry/include/SentryDefaultAppStateManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,33 +15,17 @@ SENTRY_NO_INIT

@property (nonatomic, readonly) NSInteger startCount;

- (instancetype)initWithOptions:(SentryOptions *_Nullable)options
crashWrapper:(SentryCrashWrapper *)crashWrapper
fileManager:(SentryFileManager *_Nullable)fileManager
dispatchQueueWrapper:(SentryDispatchQueueWrapper *)dispatchQueueWrapper
notificationCenterWrapper:(id<SentryNSNotificationCenterWrapper>)notificationCenterWrapper;
- (instancetype)initWithStoreCurrent:(void (^)(void))storeCurrent
updateTerminated:(void (^)(void))updateTerminated
updateSDKNotRunning:(void (^)(void))updateSDKNotRunning
updateActive:(void (^)(BOOL))updateActive;

#if SENTRY_HAS_UIKIT

- (void)start;
- (void)stop;
- (void)stopWithForce:(BOOL)forceStop;

/**
* Builds the current app state.
* @discussion The systemBootTimestamp is calculated by taking the current time and subtracting
* @c NSProcesInfo.systemUptime . @c NSProcesInfo.systemUptime returns the amount of time the system
* has been awake since the last time it was restarted. This means This is a good enough
* approximation about the timestamp the system booted.
*/
- (SentryAppState *)buildCurrentAppState;

- (nullable SentryAppState *)loadPreviousAppState;

- (void)storeCurrentAppState;

- (void)updateAppState:(void (^)(SentryAppState *))block;

#endif

@end
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 @@ -29,6 +29,7 @@
#import "SentryCrashMonitor_AppState.h"
#import "SentryCrashMonitor_System.h"
#import "SentryDateUtils.h"
#import "SentryDefaultAppStateManager.h"
#import "SentryDefaultThreadInspector.h"
#import "SentryDependencyContainerSwiftHelper.h"
#import "SentryDeviceContextKeys.h"
Expand Down
4 changes: 2 additions & 2 deletions Sources/Sentry/include/SentryWatchdogTerminationLogic.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#if SENTRY_HAS_UIKIT

@class SentryAppState;
@protocol SentryAppStateManager;
@class SentryAppStateManager;
@class SentryCrashWrapper;
@class SentryFileManager;
@class SentryOptions;
Expand All @@ -15,7 +15,7 @@ SENTRY_NO_INIT

- (instancetype)initWithOptions:(SentryOptions *)options
crashAdapter:(SentryCrashWrapper *)crashAdapter
appStateManager:(id<SentryAppStateManager>)appStateManager;
appStateManager:(SentryAppStateManager *)appStateManager;

- (BOOL)isWatchdogTermination;

Expand Down
4 changes: 2 additions & 2 deletions Sources/Sentry/include/SentryWatchdogTerminationTracker.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#import "SentryDefines.h"

@protocol SentryAppStateManager;
@class SentryAppStateManager;
@class SentryDispatchQueueWrapper;
@class SentryFileManager;
@class SentryOptions;
Expand All @@ -25,7 +25,7 @@ SENTRY_NO_INIT

- (instancetype)initWithOptions:(SentryOptions *)options
watchdogTerminationLogic:(SentryWatchdogTerminationLogic *)watchdogTerminationLogic
appStateManager:(id<SentryAppStateManager>)appStateManager
appStateManager:(SentryAppStateManager *)appStateManager
dispatchQueueWrapper:(SentryDispatchQueueWrapper *)dispatchQueueWrapper
fileManager:(SentryFileManager *)fileManager
scopePersistentStore:(SentryScopePersistentStore *)scopeStore;
Expand Down
Loading
Loading