Skip to content

Commit

Permalink
Merge branch 'main' into fix/app-start-duration
Browse files Browse the repository at this point in the history
  • Loading branch information
philipphofmann committed Jan 3, 2024
2 parents 6d4738f + 1a4da1b commit 794fe78
Show file tree
Hide file tree
Showing 17 changed files with 92 additions and 90 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/benchmarking.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ jobs:
run: |
sentry-cli --auth-token ${{ secrets.SENTRY_AUTH_TOKEN }} upload-dif --org sentry-sdks --project sentry-cocoa DerivedData/Build/Products/Debug-iphoneos/iOS-Swift.app.dSYM
- name: Archiving DerivedData
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: DerivedData-Xcode
path: |
Expand All @@ -87,7 +87,7 @@ jobs:
suite: ['High-end device', 'Mid-range device', 'Low-end device']
steps:
- uses: actions/checkout@v4
- uses: actions/download-artifact@v3
- uses: actions/download-artifact@v4
with:
name: DerivedData-Xcode
- run: npm install -g saucectl@0.107.2
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -94,15 +94,15 @@ jobs:
shell: sh

- name: Archiving XCFramework.zip
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: ${{ github.sha }}
if-no-files-found: error
path: |
${{ github.workspace }}/*.zip
- name: Archive build log if failed
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
if: ${{ failure() || cancelled() }}
with:
name: raw-build-output-build-xcframework
Expand All @@ -115,7 +115,7 @@ jobs:
needs: build-xcframework
steps:
- uses: actions/checkout@v4
- uses: actions/download-artifact@v3
- uses: actions/download-artifact@v4
with:
name: ${{ github.sha }}
- run: ./scripts/ci-select-xcode.sh 15.0.1
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/saucelabs-UI-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ jobs:
run: |
sentry-cli --auth-token ${{ secrets.SENTRY_AUTH_TOKEN }} upload-dif --org sentry-sdks --project sentry-cocoa DerivedData/Build/Products/Test-iphoneos/iOS-Swift.app.dSYM
- name: Archiving DerivedData
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: DerivedData-Xcode-${{matrix.xcode}}
path: |
Expand Down Expand Up @@ -115,7 +115,7 @@ jobs:
steps:
- uses: actions/checkout@v4

- uses: actions/download-artifact@v3
- uses: actions/download-artifact@v4
with:
name: DerivedData-Xcode-${{ matrix.xcode }}

Expand Down
22 changes: 11 additions & 11 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,14 +55,14 @@ jobs:
run: cp $(swift build --show-bin-path -c release)/Run test-server-exec

- name: Archiving DerivedData
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: test-server
path: |
./test-server/test-server-exec
- name: Archiving Raw Test Logs
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
if: ${{ failure() || cancelled() }}
with:
name: test-server-build-log-${{matrix.platform}}-xcode-${{matrix.xcode}}-os-${{matrix.test-destination-os}}
Expand Down Expand Up @@ -148,7 +148,7 @@ jobs:

steps:
- uses: actions/checkout@v4
- uses: actions/download-artifact@v3
- uses: actions/download-artifact@v4
with:
name: test-server

Expand Down Expand Up @@ -200,23 +200,23 @@ jobs:
run: ./scripts/xcode-slowest-tests.sh

- name: Archiving DerivedData Logs
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
if: steps.build_tests.outcome == 'failure'
with:
name: derived-data-${{matrix.platform}}-xcode-${{matrix.xcode}}-os-${{matrix.test-destination-os}}
path: |
/Users/runner/Library/Developer/Xcode/DerivedData/**/Logs/**
- name: Archiving Raw Test Logs
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
if: ${{ failure() || cancelled() }}
with:
name: raw-test-output-${{matrix.platform}}-xcode-${{matrix.xcode}}-os-${{matrix.test-destination-os}}
path: |
raw-test-output.log
- name: Archiving Crash Logs
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
if: ${{ failure() || cancelled() }}
with:
name: crash-logs-${{matrix.platform}}-xcode-${{matrix.xcode}}-os-${{matrix.test-destination-os}}
Expand Down Expand Up @@ -263,7 +263,7 @@ jobs:
steps:
- uses: actions/checkout@v4

- uses: actions/download-artifact@v3
- uses: actions/download-artifact@v4
with:
name: test-server

Expand All @@ -278,7 +278,7 @@ jobs:
run: ./scripts/tests-with-thread-sanitizer.sh

- name: Archiving Test Logs
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
if: ${{ failure() || cancelled() }}
with:
name: thread-sanitizer
Expand All @@ -301,7 +301,7 @@ jobs:
shell: sh

- name: Archiving Raw Test Logs
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
if: ${{ failure() || cancelled() }}
with:
name: raw-uitest-output-${{matrix.target}}
Expand Down Expand Up @@ -335,7 +335,7 @@ jobs:
shell: sh

- name: Archiving Raw Test Logs
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
if: ${{ failure() || cancelled() }}
with:
name: raw-swiftui-test-output-${{matrix.platform}}-xcode-${{matrix.xcode}}-os-${{matrix.test-destination-os}}
Expand All @@ -357,7 +357,7 @@ jobs:
shell: sh

- name: Archiving Raw Test Logs
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
if: ${{ failure() || cancelled() }}
with:
name: raw-uitest-output-asan
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/testflight.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ jobs:
bundle exec fastlane ios_swift_to_testflight
- name: Archiving
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: dSYMs
path: |
Expand Down
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,10 @@

- TTFD waits for next drawn frame (#3505)
- Fix TTID/TTFD for app start transactions (#3512): TTID/TTFD spans and measurements for app start transaction now include the app start duration.
- Crash when adding a crumb for a timezone change (#3524)
- Fix a race condition in SentryTracer (#3523)
- App start ends when first frame is drawn when performanceV2 is enabled (#3530)
- Missing transactions when not calling `reportFullyDisplayed` (#3477)

## 8.17.2

Expand Down
14 changes: 9 additions & 5 deletions Sources/Sentry/SentrySystemEventBreadcrumbs.m
Original file line number Diff line number Diff line change
Expand Up @@ -240,11 +240,15 @@ - (void)timezoneEventTriggered:(NSNumber *)storedTimezoneOffset
NSInteger offset = SentryDependencyContainer.sharedInstance.dateProvider.timezoneOffset;

crumb.type = @"system";
crumb.data = @{
@"action" : @"TIMEZONE_CHANGE",
@"previous_seconds_from_gmt" : storedTimezoneOffset,
@"current_seconds_from_gmt" : @(offset)
};

NSMutableDictionary *dataDict =
[@{ @"action" : @"TIMEZONE_CHANGE", @"current_seconds_from_gmt" : @(offset) } mutableCopy];

if (storedTimezoneOffset != nil) {
dataDict[@"previous_seconds_from_gmt"] = storedTimezoneOffset;
}

crumb.data = dataDict;
[_delegate addBreadcrumb:crumb];

[self updateStoredTimezone];
Expand Down
22 changes: 13 additions & 9 deletions Sources/Sentry/SentryTracer.m
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@
@property (nonatomic) BOOL wasFinishCalled;
@property (nonatomic, nullable, strong) NSTimer *deadlineTimer;
@property (nonnull, strong) SentryTracerConfiguration *configuration;
@property (nonatomic, strong) SentryDispatchQueueWrapper *dispatchQueue;

#if SENTRY_TARGET_PROFILING_SUPPORTED
@property (nonatomic) BOOL isProfiling;
Expand Down Expand Up @@ -132,6 +133,7 @@ - (instancetype)initWithTransactionContext:(SentryTransactionContext *)transacti

_startSystemTime = SentryDependencyContainer.sharedInstance.dateProvider.systemTime;
_configuration = configuration;
_dispatchQueue = SentryDependencyContainer.sharedInstance.dispatchQueueWrapper;

self.transactionContext = transactionContext;
_children = [[NSMutableArray alloc] init];
Expand Down Expand Up @@ -197,10 +199,10 @@ - (void)dispatchIdleTimeout
{
@synchronized(_idleTimeoutLock) {
if (_idleTimeoutBlock != NULL) {
[_configuration.dispatchQueueWrapper dispatchCancel:_idleTimeoutBlock];
[_dispatchQueue dispatchCancel:_idleTimeoutBlock];
}
__weak SentryTracer *weakSelf = self;
_idleTimeoutBlock = [_configuration.dispatchQueueWrapper createDispatchBlock:^{
_idleTimeoutBlock = [_dispatchQueue createDispatchBlock:^{
if (weakSelf == nil) {
SENTRY_LOG_DEBUG(@"WeakSelf is nil. Not doing anything.");
return;
Expand All @@ -214,15 +216,14 @@ - (void)dispatchIdleTimeout
// If the transaction has no children, the SDK will discard it.
[self finishInternal];
} else {
[_configuration.dispatchQueueWrapper dispatchAfter:_configuration.idleTimeout
block:_idleTimeoutBlock];
[_dispatchQueue dispatchAfter:_configuration.idleTimeout block:_idleTimeoutBlock];
}
}
}

- (BOOL)hasIdleTimeout
{
return _configuration.idleTimeout > 0 && _configuration.dispatchQueueWrapper != nil;
return _configuration.idleTimeout > 0;
}

- (BOOL)isAutoGeneratedTransaction
Expand All @@ -234,15 +235,16 @@ - (void)cancelIdleTimeout
{
@synchronized(_idleTimeoutLock) {
if ([self hasIdleTimeout]) {
[_configuration.dispatchQueueWrapper dispatchCancel:_idleTimeoutBlock];
[SentryDependencyContainer.sharedInstance.dispatchQueueWrapper
dispatchCancel:_idleTimeoutBlock];
}
}
}

- (void)startDeadlineTimer
{
__weak SentryTracer *weakSelf = self;
[_configuration.dispatchQueueWrapper dispatchOnMainQueue:^{
[_dispatchQueue dispatchOnMainQueue:^{
weakSelf.deadlineTimer = [weakSelf.configuration.timerFactory
scheduledTimerWithTimeInterval:SENTRY_AUTO_TRANSACTION_DEADLINE
repeats:NO
Expand Down Expand Up @@ -284,7 +286,7 @@ - (void)cancelDeadlineTimer

// The timer must be invalidated from the thread on which the timer was installed, see
// https://developer.apple.com/documentation/foundation/nstimer/1415405-invalidate#1770468
[_configuration.dispatchQueueWrapper dispatchOnMainQueue:^{
[_dispatchQueue dispatchOnMainQueue:^{
if (weakSelf == nil) {
SENTRY_LOG_DEBUG(@"WeakSelf is nil. Not invalidating deadlineTimer.");
return;
Expand Down Expand Up @@ -453,7 +455,9 @@ - (void)canBeFinished
}

if (!self.wasFinishCalled || hasUnfinishedChildSpansToWaitFor) {
SENTRY_LOG_DEBUG(@"Span with id %@ has children but isn't waiting for them right now.",
SENTRY_LOG_DEBUG(
@"Span with id %@ has children but hasn't finished yet so isn't waiting "
@"for them right now.",
self.spanId.sentrySpanIdString);
return;
}
Expand Down
6 changes: 1 addition & 5 deletions Sources/Sentry/SentryUIEventTrackerTransactionMode.m
Original file line number Diff line number Diff line change
Expand Up @@ -19,19 +19,16 @@
@interface
SentryUIEventTrackerTransactionMode ()

@property (nonatomic, strong) SentryDispatchQueueWrapper *dispatchQueueWrapper;
@property (nonatomic, assign) NSTimeInterval idleTimeout;
@property (nullable, nonatomic, strong) NSMutableArray<SentryTracer *> *activeTransactions;

@end

@implementation SentryUIEventTrackerTransactionMode

- (instancetype)initWithDispatchQueueWrapper:(SentryDispatchQueueWrapper *)dispatchQueueWrapper
idleTimeout:(NSTimeInterval)idleTimeout
- (instancetype)initWithIdleTimeout:(NSTimeInterval)idleTimeout
{
if (self = [super init]) {
self.dispatchQueueWrapper = dispatchQueueWrapper;
self.idleTimeout = idleTimeout;
self.activeTransactions = [NSMutableArray new];
}
Expand Down Expand Up @@ -91,7 +88,6 @@ - (void)handleUIEvent:(NSString *)action
SentryTracerConfiguration *config) {
config.idleTimeout = self.idleTimeout;
config.waitForChildren = YES;
config.dispatchQueueWrapper = self.dispatchQueueWrapper;
}]];

SENTRY_LOG_DEBUG(@"Automatically started a new transaction with name: "
Expand Down
7 changes: 2 additions & 5 deletions Sources/Sentry/SentryUIEventTrackingIntegration.m
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

#if SENTRY_HAS_UIKIT

# import <SentryDependencyContainer.h>
# import <SentryLog.h>
# import <SentryNSDataSwizzling.h>
# import <SentryOptions+Private.h>
Expand All @@ -25,10 +24,8 @@ - (BOOL)installWithOptions:(SentryOptions *)options
return NO;
}

SentryDependencyContainer *dependencies = [SentryDependencyContainer sharedInstance];
SentryUIEventTrackerTransactionMode *mode = [[SentryUIEventTrackerTransactionMode alloc]
initWithDispatchQueueWrapper:dependencies.dispatchQueueWrapper
idleTimeout:options.idleTimeout];
SentryUIEventTrackerTransactionMode *mode =
[[SentryUIEventTrackerTransactionMode alloc] initWithIdleTimeout:options.idleTimeout];

self.uiEventTracker = [[SentryUIEventTracker alloc] initWithMode:mode];

Expand Down
5 changes: 0 additions & 5 deletions Sources/Sentry/include/SentryTracerConfiguration.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,6 @@ NS_ASSUME_NONNULL_BEGIN
*/
@property (nonatomic) BOOL waitForChildren;

/**
* A dispatch queue wrapper to intermediate between the tracer and dispatch calls.
*/
@property (nonatomic, strong, nullable) SentryDispatchQueueWrapper *dispatchQueueWrapper;

#if SENTRY_TARGET_PROFILING_SUPPORTED
/**
* Whether to sample a profile corresponding to this transaction
Expand Down
5 changes: 1 addition & 4 deletions Sources/Sentry/include/SentryUIEventTrackerTransactionMode.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,12 @@

#if SENTRY_HAS_UIKIT

@class SentryDispatchQueueWrapper;

NS_ASSUME_NONNULL_BEGIN

@interface SentryUIEventTrackerTransactionMode : NSObject <SentryUIEventTrackerMode>
SENTRY_NO_INIT

- (instancetype)initWithDispatchQueueWrapper:(SentryDispatchQueueWrapper *)dispatchQueueWrapper
idleTimeout:(NSTimeInterval)idleTimeout;
- (instancetype)initWithIdleTimeout:(NSTimeInterval)idleTimeout;

@end

Expand Down
2 changes: 1 addition & 1 deletion Tests/SentryProfilerTests/SentryProfilerSwiftTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ class SentryProfilerSwiftTests: XCTestCase {
}
SentryDependencyContainer.sharedInstance().dispatchFactory = dispatchFactory
SentryDependencyContainer.sharedInstance().timerFactory = timeoutTimerFactory
SentryDependencyContainer.sharedInstance().dispatchQueueWrapper = dispatchQueueWrapper

systemWrapper.overrides.cpuUsage = NSNumber(value: mockCPUUsage)
systemWrapper.overrides.memoryFootprintBytes = mockMemoryFootprint
Expand All @@ -76,7 +77,6 @@ class SentryProfilerSwiftTests: XCTestCase {
if let idleTimeout = idleTimeout {
$0.idleTimeout = idleTimeout
}
$0.dispatchQueueWrapper = self.dispatchQueueWrapper
$0.waitForChildren = true
$0.timerFactory = self.timeoutTimerFactory
}))
Expand Down
Loading

0 comments on commit 794fe78

Please sign in to comment.