Skip to content

Commit

Permalink
Merge branch 'main' into fix/false-flush-timeout
Browse files Browse the repository at this point in the history
  • Loading branch information
philipphofmann committed Aug 8, 2024
2 parents 271a605 + 9067467 commit b454b74
Show file tree
Hide file tree
Showing 19 changed files with 102 additions and 98 deletions.
22 changes: 8 additions & 14 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ jobs:
# iOS 17
- runs-on: macos-14
platform: "iOS"
xcode: "15.2"
xcode: "15.4"
test-destination-os: "17.2"
device: "iPhone 15"

Expand All @@ -104,24 +104,21 @@ jobs:
xcode: "13.4.1"
test-destination-os: "latest"

# macOS 13
- runs-on: macos-13
platform: "macOS"
xcode: "14.3"
test-destination-os: "latest"
# We don't run the unit tests on macOS 13 cause we run them on all on GH actions available iOS versions.
# The chance of missing a bug solely on tvOS 16 that doesn't occur on iOS, macOS 12 or macOS 14 is minimal.

# macOS 14
- runs-on: macos-14
platform: "macOS"
xcode: "15.2"
xcode: "15.4"
test-destination-os: "latest"

# Catalyst. We only test the latest version, as
# the risk something breaking on Catalyst and not
# on an older iOS or macOS version is low.
- runs-on: macos-14
platform: "Catalyst"
xcode: "15.2"
xcode: "15.4"
test-destination-os: "latest"

# tvOS 15
Expand All @@ -130,16 +127,13 @@ jobs:
xcode: "13.4.1"
test-destination-os: "16.1"

# tvOS 16
- runs-on: macos-13
platform: "tvOS"
xcode: "14.3"
test-destination-os: "17.2"
# We don't run the unit tests on tvOS 16 cause we run them on all on GH actions available iOS versions.
# The chance of missing a bug solely on tvOS 16 that doesn't occur on iOS, tvOS 15 or tvOS 16 is minimal.

# tvOS 17
- runs-on: macos-14
platform: "tvOS"
xcode: "15.2"
xcode: "15.4"
test-destination-os: "17.5"

steps:
Expand Down
25 changes: 1 addition & 24 deletions .github/workflows/ui-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -82,29 +82,6 @@ jobs:
path: |
~/Library/Logs/scan/*.log
./fastlane/test_output/**
ui-tests-address-sanitizer:
name: UI Tests with Address Sanitizer
runs-on: macos-13

steps:
- uses: actions/checkout@v4
- run: ./scripts/ci-select-xcode.sh 15.2

# GitHub Actions sometimes fail to launch the UI tests. Therefore we retry
- name: Run Fastlane
run: for i in {1..2}; do fastlane ui_tests_ios_swift device:"iPhone 14 (17.2)" address_sanitizer:true && break ; done
shell: sh

- name: Archiving Raw Test Logs
uses: actions/upload-artifact@v4
if: ${{ failure() || cancelled() }}
with:
name: raw-uitest-output-asan
path: |
~/Library/Logs/scan/*.log
./fastlane/test_output/**
ios-swift-ui-tests:
name: iOS-Swift UI Tests ${{matrix.device}}
Expand All @@ -122,7 +99,7 @@ jobs:
device: "iPhone 14 (16.4)"

- runs-on: macos-14
xcode: "15.2"
xcode: "15.4"
device: "iPhone 15 (17.2)"

steps:
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ This bug caused unhandled/crash events to have the unhandled property and mach i
- Missing mach info for crash reports (#4230)
- Crash reports not generated on visionOS (#4229)
- Don’t force cast to `NSComparisonPredicate` in TERNARY operator (#4232)
- Fix accessing UI API on bg thread in enrichScope (#4245)
- EXC_BAD_ACCESS in SentryMetricProfiler (#4242)
- Missing '#include <sys/_types/_ucontext64.h>' (#4244)
- Rare flush timeout when called in tight loop (#4257)
Expand Down
6 changes: 3 additions & 3 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ GEM
mime-types (>= 1.16, < 4.0)
netrc (~> 0.8)
retriable (3.1.2)
rexml (3.2.9)
rexml (3.3.3)
strscan
rouge (2.0.7)
ruby-macho (2.5.1)
Expand Down Expand Up @@ -292,13 +292,13 @@ GEM
uber (0.1.0)
unicode-display_width (2.5.0)
word_wrap (1.0.0)
xcodeproj (1.24.0)
xcodeproj (1.25.0)
CFPropertyList (>= 2.3.3, < 4.0)
atomos (~> 0.1.3)
claide (>= 1.0.2, < 2.0)
colored2 (~> 3.1)
nanaimo (~> 0.3.0)
rexml (~> 3.2.4)
rexml (>= 3.3.2, < 4.0)
xcpretty (0.3.0)
rouge (~> 2.0.7)
xcpretty-travis-formatter (1.0.1)
Expand Down
7 changes: 0 additions & 7 deletions Samples/iOS-Swift/iOS-Swift/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -155,8 +155,6 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
return scope
}
})

SentrySDK.metrics.increment(key: "app.start", value: 1.0, tags: ["view": "app-delegate"])

}
//swiftlint:enable function_body_length cyclomatic_complexity
Expand All @@ -173,11 +171,6 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
AppDelegate.startSentry()
}

randomDistributionTimer = Timer.scheduledTimer(withTimeInterval: 0.5, repeats: true) { _ in
let random = Double.random(in: 0..<1_000)
SentrySDK.metrics.distribution(key: "random.distribution", value: random)
}

if #available(iOS 15.0, *) {
metricKit.receiveReports()
}
Expand Down
6 changes: 0 additions & 6 deletions Samples/iOS-Swift/iOS-Swift/ErrorsViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,6 @@ class ErrorsViewController: UIViewController {
override func viewDidAppear(_ animated: Bool) {
super.viewDidAppear(animated)
SentrySDK.reportFullyDisplayed()

SentrySDK.metrics.increment(key: "load.errors.view.controller")

SentrySDK.metrics.timing(key: "timing.some.delayed") {
Thread.sleep(forTimeInterval: 0.01)
}
}

@IBAction func useAfterFree(_ sender: UIButton) {
Expand Down
8 changes: 8 additions & 0 deletions SentryTestUtils/TestDisplayLinkWrapper.swift
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ public class TestDisplayLinkWrapper: SentryDisplayLinkWrapper {
public var dateProvider: TestCurrentDateProvider
/// The smallest magnitude of time that is significant to how frames are classified as normal/slow/frozen.
public let timeEpsilon = 0.001

public var _isRunning: Bool = false

public init(dateProvider: TestCurrentDateProvider? = nil) {
self.dateProvider = dateProvider ?? TestCurrentDateProvider()
Expand All @@ -46,12 +48,17 @@ public class TestDisplayLinkWrapper: SentryDisplayLinkWrapper {
linkInvocations.record(Void())
self.target = target as AnyObject
self.selector = sel
_isRunning = true
}
}

public override var timestamp: CFTimeInterval {
return dateProvider.systemTime().toTimeInterval()
}

public override func isRunning() -> Bool {
_isRunning
}

public override var targetTimestamp: CFTimeInterval {
return dateProvider.systemTime().toTimeInterval() + currentFrameRate.tickDuration
Expand All @@ -61,6 +68,7 @@ public class TestDisplayLinkWrapper: SentryDisplayLinkWrapper {
public override func invalidate() {
target = nil
selector = nil
_isRunning = false
invalidateInvocations.record(Void())
}

Expand Down
4 changes: 3 additions & 1 deletion Sources/Sentry/SentryCrashWrapper.m
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#import "SentryCrashMonitor_AppState.h"
#import "SentryCrashMonitor_System.h"
#import "SentryScope.h"
#import "SentryUIDeviceWrapper.h"
#import <Foundation/Foundation.h>
#import <SentryCrashCachedData.h>
#import <SentryCrashDebug.h>
Expand Down Expand Up @@ -126,7 +127,8 @@ - (void)enrichScope:(SentryScope *)scope
// For MacCatalyst the UIDevice returns the current version of MacCatalyst and not the
// macOSVersion. Therefore we have to use NSProcessInfo.
#if SENTRY_HAS_UIKIT && !TARGET_OS_MACCATALYST
[osData setValue:[UIDevice currentDevice].systemVersion forKey:@"version"];
[osData setValue:[SentryDependencyContainer.sharedInstance.uiDeviceWrapper getSystemVersion]
forKey:@"version"];
#else
NSOperatingSystemVersion version = [NSProcessInfo processInfo].operatingSystemVersion;
NSString *systemVersion = [NSString stringWithFormat:@"%d.%d.%d", (int)version.majorVersion,
Expand Down
12 changes: 3 additions & 9 deletions Sources/Sentry/SentryDependencyContainer.m
Original file line number Diff line number Diff line change
Expand Up @@ -198,11 +198,10 @@ - (SentryNSNotificationCenterWrapper *)notificationCenterWrapper
}
}

#if TARGET_OS_IOS
#if SENTRY_HAS_UIKIT
- (SentryUIDeviceWrapper *)uiDeviceWrapper SENTRY_DISABLE_THREAD_SANITIZER(
"double-checked lock produce false alarms")
{
# if SENTRY_HAS_UIKIT
if (_uiDeviceWrapper == nil) {
@synchronized(sentryDependencyContainerLock) {
if (_uiDeviceWrapper == nil) {
Expand All @@ -211,14 +210,9 @@ - (SentryUIDeviceWrapper *)uiDeviceWrapper SENTRY_DISABLE_THREAD_SANITIZER(
}
}
return _uiDeviceWrapper;
# else
SENTRY_LOG_DEBUG(
@"SentryDependencyContainer.uiDeviceWrapper only works with UIKit enabled. Ensure you're "
@"using the right configuration of Sentry that links UIKit.");
return nil;
# endif // SENTRY_HAS_UIKIT
}
#endif // TARGET_OS_IOS

#endif // SENTRY_HAS_UIKIT

#if SENTRY_UIKIT_AVAILABLE
- (SentryScreenshot *)screenshot SENTRY_DISABLE_THREAD_SANITIZER(
Expand Down
21 changes: 13 additions & 8 deletions Sources/Sentry/SentrySDK.m
Original file line number Diff line number Diff line change
Expand Up @@ -218,28 +218,33 @@ + (void)startWithOptions:(SentryOptions *)options

SentryScope *scope
= options.initialScope([[SentryScope alloc] initWithMaxBreadcrumbs:options.maxBreadcrumbs]);
// The Hub needs to be initialized with a client so that closing a session
// can happen.
SentryHub *hub = [[SentryHub alloc] initWithClient:newClient andScope:scope];
[SentrySDK setCurrentHub:hub];
SENTRY_LOG_DEBUG(@"SDK initialized! Version: %@", SentryMeta.versionString);

SENTRY_LOG_DEBUG(@"Dispatching init work required to run on main thread.");
[SentryDependencyContainer.sharedInstance.dispatchQueueWrapper dispatchAsyncOnMainQueue:^{
SENTRY_LOG_DEBUG(@"SDK main thread init started...");

// The UIDeviceWrapper needs to start before the Hub, because the Hub
// enriches the scope, which calls the UIDeviceWrapper.
#if SENTRY_HAS_UIKIT
[SentryDependencyContainer.sharedInstance.uiDeviceWrapper start];
#endif // TARGET_OS_IOS && SENTRY_HAS_UIKIT

// The Hub needs to be initialized with a client so that closing a session
// can happen.
SentryHub *hub = [[SentryHub alloc] initWithClient:newClient andScope:scope];
[SentrySDK setCurrentHub:hub];

[SentryCrashWrapper.sharedInstance startBinaryImageCache];
[SentryDependencyContainer.sharedInstance.binaryImageCache start];

[SentrySDK installIntegrations];
#if TARGET_OS_IOS && SENTRY_HAS_UIKIT
[SentryDependencyContainer.sharedInstance.uiDeviceWrapper start];
#endif // TARGET_OS_IOS && SENTRY_HAS_UIKIT

#if SENTRY_TARGET_PROFILING_SUPPORTED
sentry_manageTraceProfilerOnStartSDK(options, hub);
#endif // SENTRY_TARGET_PROFILING_SUPPORTED
}];

SENTRY_LOG_DEBUG(@"SDK initialized! Version: %@", SentryMeta.versionString);
}

+ (void)startWithConfigureOptions:(void (^)(SentryOptions *options))configureOptions
Expand Down
19 changes: 17 additions & 2 deletions Sources/Sentry/SentryUIDeviceWrapper.m
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,24 @@
#import "SentryDependencyContainer.h"
#import "SentryDispatchQueueWrapper.h"

#if TARGET_OS_IOS && SENTRY_HAS_UIKIT
#if SENTRY_HAS_UIKIT

NS_ASSUME_NONNULL_BEGIN

@interface
SentryUIDeviceWrapper ()
@property (nonatomic) BOOL cleanupDeviceOrientationNotifications;
@property (nonatomic) BOOL cleanupBatteryMonitoring;
@property (nonatomic, copy) NSString *systemVersion;
@end

@implementation SentryUIDeviceWrapper

- (void)start
{
[SentryDependencyContainer.sharedInstance.dispatchQueueWrapper dispatchAsyncOnMainQueue:^{

# if TARGET_OS_IOS
if (!UIDevice.currentDevice.isGeneratingDeviceOrientationNotifications) {
self.cleanupDeviceOrientationNotifications = YES;
[UIDevice.currentDevice beginGeneratingDeviceOrientationNotifications];
Expand All @@ -27,11 +30,15 @@ - (void)start
self.cleanupBatteryMonitoring = YES;
UIDevice.currentDevice.batteryMonitoringEnabled = YES;
}
# endif

self.systemVersion = [UIDevice currentDevice].systemVersion;
}];
}

- (void)stop
{
# if TARGET_OS_IOS
BOOL needsCleanUp = self.cleanupDeviceOrientationNotifications;
BOOL needsDisablingBattery = self.cleanupBatteryMonitoring;
UIDevice *device = [UIDevice currentDevice];
Expand All @@ -43,13 +50,15 @@ - (void)stop
device.batteryMonitoringEnabled = NO;
}
}];
# endif // TARGET_OS_IOS
}

- (void)dealloc
{
[self stop];
}

# if TARGET_OS_IOS
- (UIDeviceOrientation)orientation
{
return (UIDeviceOrientation)[UIDevice currentDevice].orientation;
Expand All @@ -69,9 +78,15 @@ - (float)batteryLevel
{
return [UIDevice currentDevice].batteryLevel;
}
# endif // TARGET_OS_IOS

- (NSString *)getSystemVersion
{
return self.systemVersion;
}

@end

NS_ASSUME_NONNULL_END

#endif // TARGET_OS_IOS && SENTRY_HAS_UIKIT
#endif // SENTRY_HAS_UIKIT
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
@class SentryViewHierarchy;
#endif // SENTRY_UIKIT_AVAILABLE

#if TARGET_OS_IOS
#if SENTRY_HAS_UIKIT
@class SentryUIDeviceWrapper;
#endif // TARGET_OS_IOS

Expand Down Expand Up @@ -80,7 +80,7 @@ SENTRY_NO_INIT
@property (nonatomic, strong) SentryUIApplication *application;
#endif // SENTRY_UIKIT_AVAILABLE

#if TARGET_OS_IOS
#if SENTRY_HAS_UIKIT
@property (nonatomic, strong) SentryUIDeviceWrapper *uiDeviceWrapper;
#endif // TARGET_OS_IOS

Expand Down
2 changes: 2 additions & 0 deletions Sources/Sentry/include/SentryDisplayLinkWrapper.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ NS_ASSUME_NONNULL_BEGIN

- (void)invalidate;

- (BOOL)isRunning;

@end

NS_ASSUME_NONNULL_END
Expand Down
Loading

0 comments on commit b454b74

Please sign in to comment.