From 6177f2ddf6adfc0d15e7343689c48b80eb88476d Mon Sep 17 00:00:00 2001 From: Philipp Hofmann Date: Thu, 29 Sep 2022 14:10:21 +0200 Subject: [PATCH 01/16] ci: Fix typo in comments for tests.yml (#2241) --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 65d70f204ce..6da05b039be 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -159,7 +159,7 @@ jobs: - name: Running tests # We call a script with the platform so the destination - # passed to xcodebuild doesn't ends up in the job name, + # passed to xcodebuild doesn't end up in the job name, # because GitHub Actions don't provide an easy way of # manipulating string in expressions. run: ./scripts/xcode-test.sh ${{matrix.platform}} ${{matrix.test-destination-os}} ${{matrix.xcode}} $GITHUB_REF_NAME From 075911d74eb91917fb88910bf871cd65d834f7fd Mon Sep 17 00:00:00 2001 From: Philipp Hofmann Date: Thu, 29 Sep 2022 14:49:56 +0200 Subject: [PATCH 02/16] ci: Point to latest GH hash for VLC tests (#2237) Update VLC integration tests to the latest commit hash. --- .github/workflows/integration-tests.yml | 6 +- scripts/add-sentry-to-vlc.patch | 166 ++++++++++++++++++++---- 2 files changed, 147 insertions(+), 25 deletions(-) diff --git a/.github/workflows/integration-tests.yml b/.github/workflows/integration-tests.yml index cb3f5be08bc..056e312afd5 100644 --- a/.github/workflows/integration-tests.yml +++ b/.github/workflows/integration-tests.yml @@ -143,12 +143,12 @@ jobs: # Sentry to the app with auto performance monitoring enabled. We then run the UI tests to make sure # adding our SDK doesn't cause any major issues. vlc-tests: - runs-on: macos-11 + runs-on: macos-12 steps: - uses: actions/checkout@v3 with: repository: 'videolan/vlc-ios' - ref: 'f2d4a28031509f263255457c91703b6d2f388b65' + ref: '5d2b5505edc3387cad43deca14c0bd0b19e3f133' # Use github.event.pull_request.head.sha instead of github.sha when available as # the github.sha is the pre merge commit id for PRs. @@ -181,4 +181,4 @@ jobs: - name: Run UI Tests # Run the tests twice in case they are flaky. - run: for i in {1..2} ; do set -o pipefail && env NSUnbufferedIO=YES xcodebuild -workspace "VLC.xcworkspace" -scheme "VLC-iOS-UITests" -destination "OS=15.2,name=iPhone 13 Pro" test | xcpretty && break ; done + run: for i in {1..2} ; do set -o pipefail && env NSUnbufferedIO=YES xcodebuild -workspace "VLC.xcworkspace" -scheme "VLC-iOS-UITests" -destination "OS=15.5,name=iPhone 13 Pro" test | xcpretty && break ; done diff --git a/scripts/add-sentry-to-vlc.patch b/scripts/add-sentry-to-vlc.patch index 10811ff9f0b..4b9bb771cd8 100644 --- a/scripts/add-sentry-to-vlc.patch +++ b/scripts/add-sentry-to-vlc.patch @@ -1,40 +1,162 @@ diff --git a/Podfile b/Podfile -index efdc34e6..95a5a944 100644 +index b9205a9f..3156735b 100644 --- a/Podfile +++ b/Podfile -@@ -10,6 +10,8 @@ def shared_pods +@@ -9,6 +9,7 @@ def shared_pods + pod 'CocoaHTTPServer', :git => 'https://github.com/fkuehne/CocoaHTTPServer.git' # has our fixes + pod 'xmlrpc', :git => 'https://github.com/fkuehne/xmlrpc.git', :commit => '3f8ce3a8' #fix case-sensitive FS pod 'AFNetworking', '~>4.0' - - pod 'AppCenter', '~>4.1' + pod 'Sentry', :git => 'https://github.com/getsentry/sentry-cocoa', :commit => '__GITHUB_REVISION_PLACEHOLDER__' -+ + # debug - pod 'SwiftLint', '~> 0.25.0', :configurations => ['Debug'] - end -diff --git a/Sources/VLCAppDelegate.m b/Sources/VLCAppDelegate.m -index 45e05469..0050ffbc 100644 ---- a/Sources/VLCAppDelegate.m -+++ b/Sources/VLCAppDelegate.m -@@ -23,6 +23,7 @@ - #import - #import - #import + pod 'SwiftLint', '~> 0.47.1', :configurations => ['Debug'] +diff --git a/Sources/App/iOS/VLCAppDelegate.m b/Sources/App/iOS/VLCAppDelegate.m +index 2c1fc802..21495fd7 100644 +--- a/Sources/App/iOS/VLCAppDelegate.m ++++ b/Sources/App/iOS/VLCAppDelegate.m +@@ -19,6 +19,7 @@ + + #import "VLCAppDelegate.h" + #import "VLC-Swift.h" +#import - NSString *VLCAppCenterAppID = @"0114ca8e-2652-44ce-588d-2ebd035c3577"; + @interface VLCAppDelegate () + { +@@ -134,6 +135,16 @@ -@@ -136,6 +137,14 @@ NSString *VLCAppCenterAppID = @"0114ca8e-2652-44ce-588d-2ebd035c3577"; - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { - [MSACAppCenter start:VLCAppCenterAppID withServices:@[[MSACAnalytics class], [MSACCrashes class]]]; -+ + [SentrySDK startWithConfigureOptions:^(SentryOptions *options) { + options.dsn = @"https://a92d50327ac74b8b9aa4ea80eccfb267@o447951.ingest.sentry.io/5428557"; + options.environment = @"integration-tests"; -+ options.tracesSampleRate = @0; ++ options.tracesSampleRate = @1.0; + options.enableFileIOTracking = YES; -+ options.profilesSampleRate = @1.0; ++ options.attachScreenshot = YES; ++ options.attachViewHierarchy = YES; ++ options.enableUserInteractionTracing = YES; + }]; - ++ self.orientationLock = UIInterfaceOrientationMaskPortrait | UIInterfaceOrientationMaskLandscape; + self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; +diff --git a/VLC.xcodeproj/project.pbxproj b/VLC.xcodeproj/project.pbxproj +index 311b5c8b..b434a8b5 100644 +--- a/VLC.xcodeproj/project.pbxproj ++++ b/VLC.xcodeproj/project.pbxproj +@@ -492,7 +492,7 @@ + 4152F1611FEF19BD00F1908B /* KeychainCoordinator.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = KeychainCoordinator.swift; sourceTree = ""; }; + 41533C91211338D500EC3ABA /* VLC-iOSTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = "VLC-iOSTests.xctest"; sourceTree = BUILT_PRODUCTS_DIR; }; + 41533C9D2113392F00EC3ABA /* URLHandlerTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = URLHandlerTests.swift; sourceTree = ""; }; +- 41533CA1211343D100EC3ABA /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; name = Info.plist; path = ../../Testing/Unit/Info.plist; sourceTree = ""; }; ++ 41533CA1211343D100EC3ABA /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; name = Info.plist; path = ../../Buildsystem/Testing/Unit/Info.plist; sourceTree = ""; }; + 416443852048419E00CAC646 /* DeviceMotion.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DeviceMotion.swift; sourceTree = ""; }; + 416DACB620B6DB9A001BC75D /* PlayingExternallyView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PlayingExternallyView.swift; sourceTree = ""; }; + 4170152B209A1D3600802E44 /* MediaViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MediaViewController.swift; sourceTree = ""; }; +@@ -3644,7 +3644,7 @@ + GCC_C_LANGUAGE_STANDARD = gnu11; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; +- INFOPLIST_FILE = Testing/Screenshots/Info.plist; ++ INFOPLIST_FILE = Buildsystem/Testing/Screenshots/Info.plist; + IPHONEOS_DEPLOYMENT_TARGET = 12.2; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; + MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; +@@ -3653,7 +3653,7 @@ + PRODUCT_MODULE_NAME = VLC_iOS_Screenshots; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; +- SWIFT_OBJC_BRIDGING_HEADER = "Testing/Screenshots/VLC-iOS-Screenshots-Bridging-Header.h"; ++ SWIFT_OBJC_BRIDGING_HEADER = "Buildsystem/Testing/Screenshots/VLC-iOS-Screenshots-Bridging-Header.h"; + SWIFT_OPTIMIZATION_LEVEL = "-Onone"; + SWIFT_VERSION = 5.0; + TARGETED_DEVICE_FAMILY = "1,2"; +@@ -3682,7 +3682,7 @@ + GCC_C_LANGUAGE_STANDARD = gnu11; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; +- INFOPLIST_FILE = Testing/Screenshots/Info.plist; ++ INFOPLIST_FILE = Buildsystem/Testing/Screenshots/Info.plist; + IPHONEOS_DEPLOYMENT_TARGET = 12.2; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; + MTL_ENABLE_DEBUG_INFO = NO; +@@ -3690,7 +3690,7 @@ + PRODUCT_BUNDLE_IDENTIFIER = "com.example.VLC-iOSScreenShots"; + PRODUCT_MODULE_NAME = VLC_iOS_Screenshots; + PRODUCT_NAME = "$(TARGET_NAME)"; +- SWIFT_OBJC_BRIDGING_HEADER = "Testing/Screenshots/VLC-iOS-Screenshots-Bridging-Header.h"; ++ SWIFT_OBJC_BRIDGING_HEADER = "Buildsystem/Testing/Screenshots/VLC-iOS-Screenshots-Bridging-Header.h"; + SWIFT_VERSION = 5.0; + TARGETED_DEVICE_FAMILY = "1,2"; + TEST_TARGET_NAME = "VLC-iOS"; +@@ -3718,7 +3718,7 @@ + GCC_C_LANGUAGE_STANDARD = gnu11; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; +- INFOPLIST_FILE = Testing/Screenshots/Info.plist; ++ INFOPLIST_FILE = Buildsystem/Testing/Screenshots/Info.plist; + IPHONEOS_DEPLOYMENT_TARGET = 12.2; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; + MTL_ENABLE_DEBUG_INFO = NO; +@@ -3726,7 +3726,7 @@ + PRODUCT_BUNDLE_IDENTIFIER = "com.example.VLC-iOSScreenShots"; + PRODUCT_MODULE_NAME = VLC_iOS_Screenshots; + PRODUCT_NAME = "$(TARGET_NAME)"; +- SWIFT_OBJC_BRIDGING_HEADER = "Testing/Screenshots/VLC-iOS-Screenshots-Bridging-Header.h"; ++ SWIFT_OBJC_BRIDGING_HEADER = "Buildsystem/Testing/Screenshots/VLC-iOS-Screenshots-Bridging-Header.h"; + SWIFT_VERSION = 5.0; + TARGETED_DEVICE_FAMILY = "1,2"; + TEST_TARGET_NAME = "VLC-iOS"; +@@ -3754,7 +3754,7 @@ + GCC_C_LANGUAGE_STANDARD = gnu11; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; +- INFOPLIST_FILE = Testing/Unit/Info.plist; ++ INFOPLIST_FILE = Buildsystem/Testing/Unit/Info.plist; + IPHONEOS_DEPLOYMENT_TARGET = 11.4; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; + MTL_ENABLE_DEBUG_INFO = YES; +@@ -3793,7 +3793,7 @@ + GCC_C_LANGUAGE_STANDARD = gnu11; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; +- INFOPLIST_FILE = Testing/Unit/Info.plist; ++ INFOPLIST_FILE = Buildsystem/Testing/Unit/Info.plist; + IPHONEOS_DEPLOYMENT_TARGET = 11.4; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; + MTL_ENABLE_DEBUG_INFO = NO; +@@ -3831,7 +3831,7 @@ + GCC_C_LANGUAGE_STANDARD = gnu11; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; +- INFOPLIST_FILE = Testing/Unit/Info.plist; ++ INFOPLIST_FILE = Buildsystem/Testing/Unit/Info.plist; + IPHONEOS_DEPLOYMENT_TARGET = 11.4; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; + MTL_ENABLE_DEBUG_INFO = NO; +@@ -3881,7 +3881,7 @@ + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; +- INFOPLIST_FILE = Testing/UI/Info.plist; ++ INFOPLIST_FILE = Buildsystem/Testing/UI/Info.plist; + IPHONEOS_DEPLOYMENT_TARGET = 9.0; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; + MTL_ENABLE_DEBUG_INFO = YES; +@@ -3931,7 +3931,7 @@ + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; +- INFOPLIST_FILE = Testing/UI/Info.plist; ++ INFOPLIST_FILE = Buildsystem/Testing/UI/Info.plist; + IPHONEOS_DEPLOYMENT_TARGET = 9.0; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; + MTL_ENABLE_DEBUG_INFO = NO; +@@ -3982,7 +3982,7 @@ + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; +- INFOPLIST_FILE = Testing/UI/Info.plist; ++ INFOPLIST_FILE = Buildsystem/Testing/UI/Info.plist; + IPHONEOS_DEPLOYMENT_TARGET = 9.0; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; + MTL_ENABLE_DEBUG_INFO = NO; From 0fdf0b2d0910b507c3f1451d3534895cdd23bc35 Mon Sep 17 00:00:00 2001 From: Philipp Hofmann Date: Thu, 29 Sep 2022 15:29:20 +0200 Subject: [PATCH 03/16] meta: Changelog link start-up crashes (#2238) The feature list will show start-up crashes after merging https://github.com/getsentry/sentry-docs/pull/5579. --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b33197fc890..8a6783d653e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,7 +4,7 @@ ### Features -- Report start up crashes (#2220) +- Report [start up crashes](https://docs.sentry.io/platforms/apple/guides/ios/) (#2220) - Add segment property to user (#2234) - Support tracePropagationTargets (#2217) From 4a0c2822a7cd9f2ff56a4200af04533585b0a2cc Mon Sep 17 00:00:00 2001 From: Kevin Renskers Date: Mon, 3 Oct 2022 10:47:13 +0200 Subject: [PATCH 04/16] fix: Return SentryNoOpSpan when starting a child on a finished transaction (#2239) * fix: Starting a new span on a finished span results in a SentryNoOpSpan Closes #1624 * Add a test * Changelog * Fix test * Fix test * Move changelog (this is such an annoying manual thing to keep fixing) * Whoops * Fix tests (why does this work locally?) * Clean up * Use self.tracer.isFinished * Add testStartGrandChildOnFinishedSpan * Move logic to SentryTracer --- CHANGELOG.md | 6 +++ Sentry.xcodeproj/project.pbxproj | 4 ++ Sources/Sentry/SentrySpan.m | 1 + Sources/Sentry/SentryTracer.m | 7 ++++ Tests/SentryTests/Helper/SentryLogTests.swift | 9 ----- .../SentryBaseIntegrationTests.swift | 7 ---- .../Performance/SentryTracerObjCTests.m | 1 - .../Performance/SentryTracerTests.swift | 3 +- Tests/SentryTests/TestLogOutput.swift | 8 ++++ .../Transaction/SentrySpanTests.swift | 37 +++++++++++++++++-- 10 files changed, 62 insertions(+), 21 deletions(-) create mode 100644 Tests/SentryTests/TestLogOutput.swift diff --git a/CHANGELOG.md b/CHANGELOG.md index 8a6783d653e..0fab681a1ad 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,11 @@ # Changelog +## Unreleased + +### Fixes + +- Return SentryNoOpSpan when starting a child on a finished transaction (#2239) + ## 7.27.0 ### Features diff --git a/Sentry.xcodeproj/project.pbxproj b/Sentry.xcodeproj/project.pbxproj index 2f5b0137c77..51b3821838b 100644 --- a/Sentry.xcodeproj/project.pbxproj +++ b/Sentry.xcodeproj/project.pbxproj @@ -37,6 +37,7 @@ 03F84D3727DD4191008FE43F /* SentrySamplingProfiler.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 03F84D3027DD4191008FE43F /* SentrySamplingProfiler.cpp */; }; 03F84D3827DD4191008FE43F /* SentryBacktrace.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 03F84D3127DD4191008FE43F /* SentryBacktrace.cpp */; }; 03F9D37C2819A65C00602916 /* SentryProfilerTests.mm in Sources */ = {isa = PBXBuildFile; fileRef = 03F9D37B2819A65C00602916 /* SentryProfilerTests.mm */; }; + 0A1B497328E597DD00D7BFA3 /* TestLogOutput.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0A1B497228E597DD00D7BFA3 /* TestLogOutput.swift */; }; 0A1C3592287D7107007D01E3 /* SentryMetaTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0A1C3591287D7107007D01E3 /* SentryMetaTests.swift */; }; 0A2690B72885C2E000E4432D /* TestSentryPermissionsObserver.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0AABE2EF2885C2120057ED69 /* TestSentryPermissionsObserver.swift */; }; 0A2D8D5B289815C0008720F6 /* SentryBaseIntegration.m in Sources */ = {isa = PBXBuildFile; fileRef = 0A2D8D5A289815C0008720F6 /* SentryBaseIntegration.m */; }; @@ -743,6 +744,7 @@ 03F84D3027DD4191008FE43F /* SentrySamplingProfiler.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = SentrySamplingProfiler.cpp; path = Sources/Sentry/SentrySamplingProfiler.cpp; sourceTree = SOURCE_ROOT; }; 03F84D3127DD4191008FE43F /* SentryBacktrace.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = SentryBacktrace.cpp; path = Sources/Sentry/SentryBacktrace.cpp; sourceTree = SOURCE_ROOT; }; 03F9D37B2819A65C00602916 /* SentryProfilerTests.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = SentryProfilerTests.mm; sourceTree = ""; }; + 0A1B497228E597DD00D7BFA3 /* TestLogOutput.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TestLogOutput.swift; sourceTree = ""; }; 0A1C3591287D7107007D01E3 /* SentryMetaTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SentryMetaTests.swift; sourceTree = ""; }; 0A2D8D5A289815C0008720F6 /* SentryBaseIntegration.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = SentryBaseIntegration.m; sourceTree = ""; }; 0A2D8D5C289815EB008720F6 /* SentryBaseIntegration.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = SentryBaseIntegration.h; path = include/SentryBaseIntegration.h; sourceTree = ""; }; @@ -1885,6 +1887,7 @@ 7B6D1262265F7CC600C9BE4B /* PrivateSentrySDKOnlyTests.swift */, 8ED3D305264DFE700049393B /* SentryUIViewControllerSanitizerTests.swift */, D8918B212849FA6D00701F9A /* SentrySDKIntegrationTestsBase.swift */, + 0A1B497228E597DD00D7BFA3 /* TestLogOutput.swift */, ); path = SentryTests; sourceTree = ""; @@ -3653,6 +3656,7 @@ 7B68D93625FF5F1A0082D139 /* SentryAppState+Equality.m in Sources */, 7B5CAF7E27F5AD3500ED0DB6 /* TestNSURLRequestBuilder.m in Sources */, 8EAC7FF8265C8910005B44E5 /* SentryTracerTests.swift in Sources */, + 0A1B497328E597DD00D7BFA3 /* TestLogOutput.swift in Sources */, 7BA61CBD247BC6B900C130A8 /* TestSentryCrashBinaryImageProvider.swift in Sources */, 7BFA69F627E0840400233199 /* SentryANRTrackingIntegrationTests.swift in Sources */, 7BBD18B62451807600427C76 /* SentryDefaultRateLimitsTests.swift in Sources */, diff --git a/Sources/Sentry/SentrySpan.m b/Sources/Sentry/SentrySpan.m index 2238dd66259..2dab3697943 100644 --- a/Sources/Sentry/SentrySpan.m +++ b/Sources/Sentry/SentrySpan.m @@ -2,6 +2,7 @@ #import "NSDate+SentryExtras.h" #import "NSDictionary+SentrySanitize.h" #import "SentryCurrentDate.h" +#import "SentryLog.h" #import "SentryNoOpSpan.h" #import "SentryTraceHeader.h" #import "SentryTracer.h" diff --git a/Sources/Sentry/SentryTracer.m b/Sources/Sentry/SentryTracer.m index 97f9fcc701a..29baa07c68f 100644 --- a/Sources/Sentry/SentryTracer.m +++ b/Sources/Sentry/SentryTracer.m @@ -7,6 +7,7 @@ #import "SentryFramesTracker.h" #import "SentryHub+Private.h" #import "SentryLog.h" +#import "SentryNoOpSpan.h" #import "SentryProfiler.h" #import "SentryProfilesSampler.h" #import "SentryProfilingConditionals.h" @@ -261,6 +262,12 @@ - (void)cancelIdleTimeout { [self cancelIdleTimeout]; + if (self.isFinished) { + SENTRY_LOG_WARN( + @"Starting a child on a finished span is not supported; it won't be sent to Sentry."); + return [SentryNoOpSpan shared]; + } + SentrySpanContext *context = [[SentrySpanContext alloc] initWithTraceId:_rootSpan.context.traceId spanId:[[SentrySpanId alloc] init] diff --git a/Tests/SentryTests/Helper/SentryLogTests.swift b/Tests/SentryTests/Helper/SentryLogTests.swift index b1383a9f317..143c0f0a603 100644 --- a/Tests/SentryTests/Helper/SentryLogTests.swift +++ b/Tests/SentryTests/Helper/SentryLogTests.swift @@ -68,13 +68,4 @@ class SentryLogTests: XCTestCase { "Sentry - info:: 3", "Sentry - debug:: 4"], logOutput.loggedMessages) } - - class TestLogOutput: SentryLogOutput { - - var loggedMessages: [String] = [] - override func log(_ message: String) { - loggedMessages.append(message) - } - } - } diff --git a/Tests/SentryTests/Integrations/SentryBaseIntegrationTests.swift b/Tests/SentryTests/Integrations/SentryBaseIntegrationTests.swift index 573aebeeaab..3089f4976fd 100644 --- a/Tests/SentryTests/Integrations/SentryBaseIntegrationTests.swift +++ b/Tests/SentryTests/Integrations/SentryBaseIntegrationTests.swift @@ -48,11 +48,4 @@ class SentryBaseIntegrationTests: XCTestCase { XCTAssertFalse(result) XCTAssertEqual(["Sentry - debug:: Not going to enable SentryTests.MyTestIntegration because enableAutoSessionTracking is disabled."], logOutput.loggedMessages) } - - class TestLogOutput: SentryLogOutput { - var loggedMessages: [String] = [] - override func log(_ message: String) { - loggedMessages.append(message) - } - } } diff --git a/Tests/SentryTests/Performance/SentryTracerObjCTests.m b/Tests/SentryTests/Performance/SentryTracerObjCTests.m index d4f2f2f4538..b0d31cd6f7f 100644 --- a/Tests/SentryTests/Performance/SentryTracerObjCTests.m +++ b/Tests/SentryTests/Performance/SentryTracerObjCTests.m @@ -31,7 +31,6 @@ - (void)testSpanFinishesAfterTracerReleased_NoCrash_TracerIsNil } XCTAssertNotNil(child); - XCTAssertNil(child.tracer); [child finish]; } diff --git a/Tests/SentryTests/Performance/SentryTracerTests.swift b/Tests/SentryTests/Performance/SentryTracerTests.swift index 62d1e4b7d66..0bc3295d991 100644 --- a/Tests/SentryTests/Performance/SentryTracerTests.swift +++ b/Tests/SentryTests/Performance/SentryTracerTests.swift @@ -262,7 +262,8 @@ class SentryTracerTests: XCTestCase { child.finish() XCTAssertEqual(2, fixture.dispatchQueue.dispatchAfterInvocations.count) - + + // The grandchild is a NoOp span let grandChild = child.startChild(operation: fixture.transactionOperation) XCTAssertEqual(3, fixture.dispatchQueue.dispatchCancelInvocations.count) diff --git a/Tests/SentryTests/TestLogOutput.swift b/Tests/SentryTests/TestLogOutput.swift new file mode 100644 index 00000000000..84331fa4120 --- /dev/null +++ b/Tests/SentryTests/TestLogOutput.swift @@ -0,0 +1,8 @@ +import Foundation + +class TestLogOutput: SentryLogOutput { + var loggedMessages: [String] = [] + override func log(_ message: String) { + loggedMessages.append(message) + } +} diff --git a/Tests/SentryTests/Transaction/SentrySpanTests.swift b/Tests/SentryTests/Transaction/SentrySpanTests.swift index 6e86d33dd74..ed0b0ce1ab3 100644 --- a/Tests/SentryTests/Transaction/SentrySpanTests.swift +++ b/Tests/SentryTests/Transaction/SentrySpanTests.swift @@ -2,7 +2,9 @@ import Sentry import XCTest class SentrySpanTests: XCTestCase { - + private var logOutput: TestLogOutput! + private var fixture: Fixture! + private class Fixture { let someTransaction = "Some Transaction" let someOperation = "Some Operation" @@ -12,7 +14,7 @@ class SentrySpanTests: XCTestCase { let options: Options let currentDateProvider = TestCurrentDateProvider() let tracer = SentryTracer() - + init() { options = Options() options.tracesSampleRate = 1 @@ -32,9 +34,13 @@ class SentrySpanTests: XCTestCase { } - private var fixture: Fixture! override func setUp() { super.setUp() + + logOutput = TestLogOutput() + SentryLog.configure(true, diagnosticLevel: SentryLevel.debug) + SentryLog.setLogOutput(logOutput) + fixture = Fixture() CurrentDate.setCurrentDateProvider(fixture.currentDateProvider) } @@ -153,6 +159,31 @@ class SentrySpanTests: XCTestCase { XCTAssertEqual(childSpan.context.operation, fixture.someOperation) XCTAssertEqual(childSpan.context.spanDescription, fixture.someDescription) } + + func testStartChildOnFinishedSpan() { + let span = fixture.getSut() + span.finish() + + let childSpan = span.startChild(operation: fixture.someOperation, description: fixture.someDescription) + + XCTAssertNil(childSpan.context.parentSpanId) + XCTAssertEqual(childSpan.context.operation, "") + XCTAssertNil(childSpan.context.spanDescription) + XCTAssertTrue(logOutput.loggedMessages.contains("Sentry - warning:: Starting a child on a finished span is not supported; it won\'t be sent to Sentry.")) + } + + func testStartGrandChildOnFinishedSpan() { + let span = fixture.getSut() + let childSpan = span.startChild(operation: fixture.someOperation) + childSpan.finish() + span.finish() + + let grandChild = childSpan.startChild(operation: fixture.someOperation, description: fixture.someDescription) + XCTAssertNil(grandChild.context.parentSpanId) + XCTAssertEqual(grandChild.context.operation, "") + XCTAssertNil(grandChild.context.spanDescription) + XCTAssertTrue(logOutput.loggedMessages.contains("Sentry - warning:: Starting a child on a finished span is not supported; it won\'t be sent to Sentry.")) + } func testAddAndRemoveExtras() { let span = fixture.getSut() From e2f115049093d6447abe798d1cfa76f40e5eb6d0 Mon Sep 17 00:00:00 2001 From: Kevin Renskers Date: Mon, 3 Oct 2022 16:27:46 +0200 Subject: [PATCH 05/16] ref: Clean up unused imports (#2244) --- Sources/Sentry/PrivateSentrySDKOnly.m | 1 - Sources/Sentry/Public/PrivateSentrySDKOnly.h | 2 -- Sources/Sentry/Public/SentryClient.h | 2 -- Sources/Sentry/Public/SentryError.h | 1 - Sources/Sentry/Public/SentrySDK.h | 2 -- Sources/Sentry/Public/SentryTraceHeader.h | 1 - Sources/Sentry/SentryANRTrackingIntegration.m | 4 ---- Sources/Sentry/SentryAppState.m | 1 - Sources/Sentry/SentryDependencyContainer.m | 1 - Sources/Sentry/SentryFileContents.m | 1 - Sources/Sentry/SentryMigrateSessionInit.m | 1 - Sources/Sentry/SentryOutOfMemoryTrackingIntegration.m | 3 --- Sources/Sentry/SentrySwizzleWrapper.m | 1 - Sources/Sentry/SentrySystemEventBreadcrumbs.m | 2 -- Sources/Sentry/include/SentryClient+Private.h | 1 - Sources/Sentry/include/SentryDependencyContainer.h | 1 - Sources/Sentry/include/SentryDiscardedEvent.h | 1 - Sources/Sentry/include/SentryFileManager.h | 2 -- Sources/Sentry/include/SentryLevelMapper.h | 1 - Sources/Sentry/include/SentryLog.h | 1 - Sources/Sentry/include/SentryMigrateSessionInit.h | 1 - Sources/Sentry/include/SentryScreenshot.h | 1 - Sources/Sentry/include/SentrySerialization.h | 2 -- Sources/Sentry/include/SentrySystemEventBreadcrumbs.h | 2 +- Sources/Sentry/include/SentryTraceContext.h | 1 - Sources/Sentry/include/SentryTracesSampler.h | 1 - Sources/Sentry/include/SentryUIApplication.h | 1 - Sources/Sentry/include/SentryViewHierarchy.h | 1 - Sources/SentryCrash/Installations/SentryCrashInstallation.h | 1 - .../Recording/Monitors/SentryCrashMonitor_NSException.m | 1 - Sources/SentryCrash/Recording/SentryCrash.h | 2 -- 31 files changed, 1 insertion(+), 43 deletions(-) diff --git a/Sources/Sentry/PrivateSentrySDKOnly.m b/Sources/Sentry/PrivateSentrySDKOnly.m index 2f32ebf2532..30a62ab1a2a 100644 --- a/Sources/Sentry/PrivateSentrySDKOnly.m +++ b/Sources/Sentry/PrivateSentrySDKOnly.m @@ -6,7 +6,6 @@ #import "SentryMeta.h" #import "SentrySDK+Private.h" #import "SentrySerialization.h" -#import #import #import diff --git a/Sources/Sentry/Public/PrivateSentrySDKOnly.h b/Sources/Sentry/Public/PrivateSentrySDKOnly.h index 61d278ae2a9..5cbbe17096d 100644 --- a/Sources/Sentry/Public/PrivateSentrySDKOnly.h +++ b/Sources/Sentry/Public/PrivateSentrySDKOnly.h @@ -1,5 +1,3 @@ -#import - #import "SentryDefines.h" @class SentryEnvelope, SentryDebugMeta, SentryAppStartMeasurement, SentryScreenFrames, diff --git a/Sources/Sentry/Public/SentryClient.h b/Sources/Sentry/Public/SentryClient.h index 28935314765..405256f464b 100644 --- a/Sources/Sentry/Public/SentryClient.h +++ b/Sources/Sentry/Public/SentryClient.h @@ -1,5 +1,3 @@ -#import - #import "SentryDefines.h" @class SentryOptions, SentrySession, SentryEvent, SentryEnvelope, SentryScope, SentryFileManager, diff --git a/Sources/Sentry/Public/SentryError.h b/Sources/Sentry/Public/SentryError.h index 22b6605dda7..d1f508f276e 100644 --- a/Sources/Sentry/Public/SentryError.h +++ b/Sources/Sentry/Public/SentryError.h @@ -1,5 +1,4 @@ #import "SentryDefines.h" -#import NS_ASSUME_NONNULL_BEGIN diff --git a/Sources/Sentry/Public/SentrySDK.h b/Sources/Sentry/Public/SentrySDK.h index 41b8f0f02ce..88846ff4d3b 100644 --- a/Sources/Sentry/Public/SentrySDK.h +++ b/Sources/Sentry/Public/SentrySDK.h @@ -1,5 +1,3 @@ -#import - #import "SentryDefines.h" @protocol SentrySpan; diff --git a/Sources/Sentry/Public/SentryTraceHeader.h b/Sources/Sentry/Public/SentryTraceHeader.h index 9cd4195b6c4..92f3d200cdb 100644 --- a/Sources/Sentry/Public/SentryTraceHeader.h +++ b/Sources/Sentry/Public/SentryTraceHeader.h @@ -1,6 +1,5 @@ #import "SentryDefines.h" #import "SentrySampleDecision.h" -#import @class SentryId, SentrySpanId; diff --git a/Sources/Sentry/SentryANRTrackingIntegration.m b/Sources/Sentry/SentryANRTrackingIntegration.m index 78d32daff95..9b947eb567e 100644 --- a/Sources/Sentry/SentryANRTrackingIntegration.m +++ b/Sources/Sentry/SentryANRTrackingIntegration.m @@ -8,15 +8,11 @@ #import "SentryEvent.h" #import "SentryException.h" #import "SentryHub+Private.h" -#import "SentryLog.h" #import "SentryMechanism.h" #import "SentrySDK+Private.h" #import "SentryThread.h" #import "SentryThreadInspector.h" #import "SentryThreadWrapper.h" -#import -#import -#import #import #import diff --git a/Sources/Sentry/SentryAppState.m b/Sources/Sentry/SentryAppState.m index 7b5daa4eef1..9c339e9a3ba 100644 --- a/Sources/Sentry/SentryAppState.m +++ b/Sources/Sentry/SentryAppState.m @@ -1,4 +1,3 @@ -#import #import #import diff --git a/Sources/Sentry/SentryDependencyContainer.m b/Sources/Sentry/SentryDependencyContainer.m index d81ec2040b2..248a34cb066 100644 --- a/Sources/Sentry/SentryDependencyContainer.m +++ b/Sources/Sentry/SentryDependencyContainer.m @@ -2,7 +2,6 @@ #import "SentryDefaultCurrentDateProvider.h" #import "SentryDispatchQueueWrapper.h" #import "SentryUIApplication.h" -#import #import #import #import diff --git a/Sources/Sentry/SentryFileContents.m b/Sources/Sentry/SentryFileContents.m index f18bb61d38f..9fae5da2b13 100644 --- a/Sources/Sentry/SentryFileContents.m +++ b/Sources/Sentry/SentryFileContents.m @@ -1,5 +1,4 @@ #import "SentryFileContents.h" -#import @interface SentryFileContents () diff --git a/Sources/Sentry/SentryMigrateSessionInit.m b/Sources/Sentry/SentryMigrateSessionInit.m index e9aa074d7d7..2661cb6a283 100644 --- a/Sources/Sentry/SentryMigrateSessionInit.m +++ b/Sources/Sentry/SentryMigrateSessionInit.m @@ -4,7 +4,6 @@ #import "SentryLog.h" #import "SentrySerialization.h" #import "SentrySession+Private.h" -#import NS_ASSUME_NONNULL_BEGIN diff --git a/Sources/Sentry/SentryOutOfMemoryTrackingIntegration.m b/Sources/Sentry/SentryOutOfMemoryTrackingIntegration.m index 102c5f66c45..d83de13656d 100644 --- a/Sources/Sentry/SentryOutOfMemoryTrackingIntegration.m +++ b/Sources/Sentry/SentryOutOfMemoryTrackingIntegration.m @@ -1,14 +1,11 @@ #import "SentryDefines.h" -#import #import #import #import #import -#import #import #import #import -#import #import #import #import diff --git a/Sources/Sentry/SentrySwizzleWrapper.m b/Sources/Sentry/SentrySwizzleWrapper.m index 7d98ecc5a0c..889f01c78e1 100644 --- a/Sources/Sentry/SentrySwizzleWrapper.m +++ b/Sources/Sentry/SentrySwizzleWrapper.m @@ -1,6 +1,5 @@ #import "SentrySwizzleWrapper.h" #import "SentrySwizzle.h" -#import NS_ASSUME_NONNULL_BEGIN diff --git a/Sources/Sentry/SentrySystemEventBreadcrumbs.m b/Sources/Sentry/SentrySystemEventBreadcrumbs.m index f1ec4a6274e..6deb12d6d3c 100644 --- a/Sources/Sentry/SentrySystemEventBreadcrumbs.m +++ b/Sources/Sentry/SentrySystemEventBreadcrumbs.m @@ -1,6 +1,4 @@ #import "SentrySystemEventBreadcrumbs.h" -#import "SentryAppState.h" -#import "SentryAppStateManager.h" #import "SentryBreadcrumb.h" #import "SentryCurrentDateProvider.h" #import "SentryDependencyContainer.h" diff --git a/Sources/Sentry/include/SentryClient+Private.h b/Sources/Sentry/include/SentryClient+Private.h index c5478a2b8d3..dc71e7e3c6c 100644 --- a/Sources/Sentry/include/SentryClient+Private.h +++ b/Sources/Sentry/include/SentryClient+Private.h @@ -1,7 +1,6 @@ #import "SentryClient.h" #import "SentryDataCategory.h" #import "SentryDiscardReason.h" -#import @class SentryEnvelopeItem, SentryId, SentryAttachment, SentryThreadInspector; diff --git a/Sources/Sentry/include/SentryDependencyContainer.h b/Sources/Sentry/include/SentryDependencyContainer.h index aa8e3bd9507..140f75e3de8 100644 --- a/Sources/Sentry/include/SentryDependencyContainer.h +++ b/Sources/Sentry/include/SentryDependencyContainer.h @@ -1,7 +1,6 @@ #import "SentryDefines.h" #import "SentryFileManager.h" #import "SentryRandom.h" -#import @class SentryAppStateManager, SentryCrashWrapper, SentryThreadWrapper, SentrySwizzleWrapper, SentryDispatchQueueWrapper, SentryDebugImageProvider, SentryANRTracker, diff --git a/Sources/Sentry/include/SentryDiscardedEvent.h b/Sources/Sentry/include/SentryDiscardedEvent.h index 969469836d8..f2c0b85a4d4 100644 --- a/Sources/Sentry/include/SentryDiscardedEvent.h +++ b/Sources/Sentry/include/SentryDiscardedEvent.h @@ -1,7 +1,6 @@ #import "SentryDataCategory.h" #import "SentryDiscardReason.h" #import "SentrySerializable.h" -#import NS_ASSUME_NONNULL_BEGIN diff --git a/Sources/Sentry/include/SentryFileManager.h b/Sources/Sentry/include/SentryFileManager.h index 7542dbb5520..16164615a58 100644 --- a/Sources/Sentry/include/SentryFileManager.h +++ b/Sources/Sentry/include/SentryFileManager.h @@ -1,5 +1,3 @@ -#import - #import "SentryCurrentDateProvider.h" #import "SentryDataCategory.h" #import "SentryDefines.h" diff --git a/Sources/Sentry/include/SentryLevelMapper.h b/Sources/Sentry/include/SentryLevelMapper.h index 0ec74108f6a..5304f38491d 100644 --- a/Sources/Sentry/include/SentryLevelMapper.h +++ b/Sources/Sentry/include/SentryLevelMapper.h @@ -1,5 +1,4 @@ #import "SentryDefines.h" -#import NS_ASSUME_NONNULL_BEGIN diff --git a/Sources/Sentry/include/SentryLog.h b/Sources/Sentry/include/SentryLog.h index 237e036f4a5..310301c07dc 100644 --- a/Sources/Sentry/include/SentryLog.h +++ b/Sources/Sentry/include/SentryLog.h @@ -1,5 +1,4 @@ #import "SentryDefines.h" -#import @class SentryLogOutput; diff --git a/Sources/Sentry/include/SentryMigrateSessionInit.h b/Sources/Sentry/include/SentryMigrateSessionInit.h index e4e49eaae79..e6d2e23ae3f 100644 --- a/Sources/Sentry/include/SentryMigrateSessionInit.h +++ b/Sources/Sentry/include/SentryMigrateSessionInit.h @@ -1,5 +1,4 @@ #import "SentryDefines.h" -#import @class SentryEnvelope; diff --git a/Sources/Sentry/include/SentryScreenshot.h b/Sources/Sentry/include/SentryScreenshot.h index fe7609ee19a..84afd494836 100644 --- a/Sources/Sentry/include/SentryScreenshot.h +++ b/Sources/Sentry/include/SentryScreenshot.h @@ -1,5 +1,4 @@ #import "SentryDefines.h" -#import #if SENTRY_HAS_UIKIT diff --git a/Sources/Sentry/include/SentrySerialization.h b/Sources/Sentry/include/SentrySerialization.h index 56307731d0a..4946fadddb5 100644 --- a/Sources/Sentry/include/SentrySerialization.h +++ b/Sources/Sentry/include/SentrySerialization.h @@ -1,5 +1,3 @@ -#import - #import "SentryDefines.h" @class SentrySession, SentryEnvelope, SentryAppState; diff --git a/Sources/Sentry/include/SentrySystemEventBreadcrumbs.h b/Sources/Sentry/include/SentrySystemEventBreadcrumbs.h index be9f48f82b0..2392279359c 100644 --- a/Sources/Sentry/include/SentrySystemEventBreadcrumbs.h +++ b/Sources/Sentry/include/SentrySystemEventBreadcrumbs.h @@ -1,5 +1,5 @@ -#import "SentryAppStateManager.h" #import "SentryCurrentDateProvider.h" +#import "SentryFileManager.h" #import #if TARGET_OS_IOS diff --git a/Sources/Sentry/include/SentryTraceContext.h b/Sources/Sentry/include/SentryTraceContext.h index 818ea29c696..0958e406ac6 100644 --- a/Sources/Sentry/include/SentryTraceContext.h +++ b/Sources/Sentry/include/SentryTraceContext.h @@ -1,6 +1,5 @@ #import "SentryId.h" #import "SentrySerializable.h" -#import NS_ASSUME_NONNULL_BEGIN diff --git a/Sources/Sentry/include/SentryTracesSampler.h b/Sources/Sentry/include/SentryTracesSampler.h index 8f005170db9..5d8dfa06397 100644 --- a/Sources/Sentry/include/SentryTracesSampler.h +++ b/Sources/Sentry/include/SentryTracesSampler.h @@ -1,6 +1,5 @@ #import "SentryRandom.h" #import "SentrySampleDecision.h" -#import NS_ASSUME_NONNULL_BEGIN diff --git a/Sources/Sentry/include/SentryUIApplication.h b/Sources/Sentry/include/SentryUIApplication.h index 51013b2a7f0..2195d220243 100644 --- a/Sources/Sentry/include/SentryUIApplication.h +++ b/Sources/Sentry/include/SentryUIApplication.h @@ -1,5 +1,4 @@ #import "SentryDefines.h" -#import #if SENTRY_HAS_UIKIT # import diff --git a/Sources/Sentry/include/SentryViewHierarchy.h b/Sources/Sentry/include/SentryViewHierarchy.h index 8d597339758..cda7447d91d 100644 --- a/Sources/Sentry/include/SentryViewHierarchy.h +++ b/Sources/Sentry/include/SentryViewHierarchy.h @@ -1,5 +1,4 @@ #import "SentryDefines.h" -#import #if SENTRY_HAS_UIKIT diff --git a/Sources/SentryCrash/Installations/SentryCrashInstallation.h b/Sources/SentryCrash/Installations/SentryCrashInstallation.h index 98f786b9165..32b8bf7b098 100644 --- a/Sources/SentryCrash/Installations/SentryCrashInstallation.h +++ b/Sources/SentryCrash/Installations/SentryCrashInstallation.h @@ -26,7 +26,6 @@ #import "SentryCrashReportFilter.h" #import "SentryCrashReportWriter.h" -#import /** * Crash system installation which handles backend-specific details. diff --git a/Sources/SentryCrash/Recording/Monitors/SentryCrashMonitor_NSException.m b/Sources/SentryCrash/Recording/Monitors/SentryCrashMonitor_NSException.m index cf619c7720d..a6f6168d734 100644 --- a/Sources/SentryCrash/Recording/Monitors/SentryCrashMonitor_NSException.m +++ b/Sources/SentryCrash/Recording/Monitors/SentryCrashMonitor_NSException.m @@ -30,7 +30,6 @@ #include "SentryCrashMonitorContext.h" #import "SentryCrashStackCursor_Backtrace.h" #include "SentryCrashThread.h" -#import //#define SentryCrashLogger_LocalLevel TRACE #import "SentryCrashLogger.h" diff --git a/Sources/SentryCrash/Recording/SentryCrash.h b/Sources/SentryCrash/Recording/SentryCrash.h index 0bddb878c0a..55b022c3441 100644 --- a/Sources/SentryCrash/Recording/SentryCrash.h +++ b/Sources/SentryCrash/Recording/SentryCrash.h @@ -24,8 +24,6 @@ // THE SOFTWARE. // -#import - #import "SentryCrashMonitorType.h" #import "SentryCrashReportFilter.h" #import "SentryCrashReportWriter.h" From c929040828ec1532570f1886959f897a7e334af6 Mon Sep 17 00:00:00 2001 From: Ivan Dlugos <6349682+vaind@users.noreply.github.com> Date: Tue, 4 Oct 2022 14:01:03 +0200 Subject: [PATCH 06/16] ci: update and pin GHA to commit hash (#2249) --- .github/workflows/benchmarking.yml | 6 +- .github/workflows/build.yml | 22 ++-- .github/workflows/codeql-analysis.yml | 36 +++--- .github/workflows/format-code.yml | 8 +- .github/workflows/integration-tests.yml | 29 +++-- .github/workflows/profile-data-generator.yml | 2 +- .github/workflows/saucelabs-UI-tests.yml | 32 +++--- .github/workflows/stale.yml | 16 +-- .github/workflows/test.yml | 115 +++++++++---------- .github/workflows/testflight.yml | 5 +- 10 files changed, 131 insertions(+), 140 deletions(-) diff --git a/.github/workflows/benchmarking.yml b/.github/workflows/benchmarking.yml index e1e899ac599..e8cf0eb6c2d 100644 --- a/.github/workflows/benchmarking.yml +++ b/.github/workflows/benchmarking.yml @@ -8,10 +8,10 @@ on: pull_request: paths: - # test changes to Sentry SDK sources + # test changes to Sentry SDK sources - 'Sources/**' - # test changes to benchmarking implementation + # test changes to benchmarking implementation - 'Samples/iOS-Swift/iOS-Swift/**' - 'Samples/iOS-Swift/PerformanceBenchmarks/**' - '.github/workflows/benchmarking.yml' @@ -81,7 +81,7 @@ jobs: strategy: fail-fast: false matrix: - suite: ["High-end device", "Mid-range device", "Low-end device"] + suite: ['High-end device', 'Mid-range device', 'Low-end device'] steps: - uses: actions/checkout@v3 - uses: actions/download-artifact@v3 diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 9e82ebfa8fd..db2d2780431 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -22,7 +22,7 @@ jobs: runs-on: macos-12 steps: - uses: actions/checkout@v3 - - run: ./scripts/ci-select-xcode.sh + - run: ./scripts/ci-select-xcode.sh - name: Run Fastlane env: @@ -43,12 +43,12 @@ jobs: fail-fast: false matrix: beforeXcode: [''] + # other sample projects are built in ui-tests scheme: - macOS-Swift - iOS13-Swift - # other sample projects are built in ui-tests - # WatchOS needs Sentry as a XCFramework + # WatchOS needs Sentry as a XCFramework include: - scheme: watchOS-Swift WatchKit App beforeXcode: 'make build-for-watchos' @@ -57,7 +57,7 @@ jobs: - uses: actions/checkout@v3 - run: ./scripts/ci-select-xcode.sh - run: ${{matrix.beforeXcode}} - + # Disable code signing. We just want to make sure these compile. - run: >- env NSUnbufferedIO=YES @@ -86,7 +86,7 @@ jobs: path: | ${{ github.workspace }}/*.zip - # The framework requires Xcode 12 + # The framework requires Xcode 12 build-framework: name: Build & Validate Framework runs-on: macos-11 @@ -105,10 +105,10 @@ jobs: if-no-files-found: error path: | ${{ github.workspace }}/*.zip - -# Use github.event.pull_request.head.sha instead of github.sha when available as -# the github.sha is be the pre merge commit id for PRs. -# See https://github.community/t/github-sha-isnt-the-value-expected/17903/17906. + + # Use github.event.pull_request.head.sha instead of github.sha when available as + # the github.sha is be the pre merge commit id for PRs. + # See https://github.community/t/github-sha-isnt-the-value-expected/17903/17906. validate-spm: name: Validate Swift Package Manager runs-on: macos-12 @@ -120,7 +120,7 @@ jobs: sed -i '' 's/.branch("master")/.revision("${{ github.event.pull_request.head.sha }}")/g' Samples/macOS-SPM-CommandLine/Package.swift else sed -i '' 's/.branch("master")/.revision("${{ github.sha }}")/g' Samples/macOS-SPM-CommandLine/Package.swift - fi + fi shell: bash - run: swift build working-directory: Samples/macOS-SPM-CommandLine @@ -137,7 +137,7 @@ jobs: sed -i '' 's/.branch("master")/.revision("${{ github.event.pull_request.head.sha }}")/g' Samples/SPM-Dynamic/Package.swift else sed -i '' 's/.branch("master")/.revision("${{ github.sha }}")/g' Samples/SPM-Dynamic/Package.swift - fi + fi shell: bash - run: swift build working-directory: Samples/SPM-Dynamic diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index 442fc8f7bd2..a7184e7b826 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -1,8 +1,8 @@ -name: "CodeQL" +name: 'CodeQL' on: push: - branches: [ master ] + branches: [master] pull_request: schedule: - cron: '40 4 * * 6' @@ -15,24 +15,24 @@ jobs: strategy: fail-fast: false matrix: - language: [ 'cpp' ] + language: ['cpp'] steps: - - name: Checkout repository - uses: actions/checkout@v3 + - name: Checkout repository + uses: actions/checkout@v3 - - name: Initialize CodeQL - uses: github/codeql-action/init@v2 - with: - languages: ${{ matrix.language }} + - name: Initialize CodeQL + uses: github/codeql-action/init@e0e5ded33cabb451ae0a9768fc7b0410bad9ad44 # pin@v2 + with: + languages: ${{ matrix.language }} - - run: >- - env NSUnbufferedIO=YES - xcodebuild - -workspace Sentry.xcworkspace - -scheme Sentry - -configuration Release - -destination platform="iOS Simulator,OS=latest,name=iPhone 11 Pro" + - run: >- + env NSUnbufferedIO=YES + xcodebuild + -workspace Sentry.xcworkspace + -scheme Sentry + -configuration Release + -destination platform="iOS Simulator,OS=latest,name=iPhone 11 Pro" - - name: Perform CodeQL Analysis - uses: github/codeql-action/analyze@v2 + - name: Perform CodeQL Analysis + uses: github/codeql-action/analyze@e0e5ded33cabb451ae0a9768fc7b0410bad9ad44 # pin@v2 diff --git a/.github/workflows/format-code.yml b/.github/workflows/format-code.yml index 93d423b4d9c..ec59d10af5f 100644 --- a/.github/workflows/format-code.yml +++ b/.github/workflows/format-code.yml @@ -9,10 +9,8 @@ on: - '.github/workflows/format-code.yml' jobs: - -# Formats Swift, Objective-C, C++, and C code and commits the formatted code -# if necessary - + # Formats Swift, Objective-C, C++, and C code and commits the formatted code + # if necessary format-code: name: Format Code runs-on: macos-11 @@ -22,7 +20,7 @@ jobs: run: brew install clang-format - name: Format Code run: make format - + # actions/checkout fetches only a single commit in a detached HEAD state. Therefore # we need to pass the current branch, otherwise we can't commit the changes. # GITHUB_HEAD_REF is the name of the head branch. GitHub Actions only sets this for PRs. diff --git a/.github/workflows/integration-tests.yml b/.github/workflows/integration-tests.yml index 056e312afd5..54463668110 100644 --- a/.github/workflows/integration-tests.yml +++ b/.github/workflows/integration-tests.yml @@ -3,7 +3,7 @@ on: push: branches: - master - + pull_request: paths: - 'Sources/**' @@ -13,11 +13,10 @@ on: - 'fastlane/**' jobs: - # Ensure the swizzling of network classes doesn't break the normal functionality of web requests. # We borrow the tests of Alamofire under the MIT license: https://github.com/Alamofire/Alamofire. # The following steps checkout Alamofire and apply a github patch to the project. The patch adds - # Sentry to the tests with auto performance monitoring enabled. While the tests are running a + # Sentry to the tests with auto performance monitoring enabled. While the tests are running a # transaction is bound to the scope, so the Sentry SDK adds spans to the transaction. This doesn't # validate if the Sentry SDK adds proper spans. It only validates that the swizzling logic # doesn't break web requests. @@ -30,8 +29,8 @@ jobs: with: repository: 'Alamofire/Alamofire' ref: 'f82c23a8a7ef8dc1a49a8bfc6a96883e79121864' - - # Use github.event.pull_request.head.sha instead of github.sha when available as + + # Use github.event.pull_request.head.sha instead of github.sha when available as # the github.sha is the pre merge commit id for PRs. # See https://github.community/t/github-sha-isnt-the-value-expected/17903/17906. - name: Download Apply Patch Script @@ -41,7 +40,7 @@ jobs: else curl https://raw.githubusercontent.com/getsentry/sentry-cocoa/${{ github.sha }}/scripts/apply-patch.sh --output apply-patch.sh fi - + chmod +x apply-patch.sh shell: bash @@ -53,7 +52,7 @@ jobs: - name: Start Firewalk run: firewalk & - + - name: Validate Firewalk is running run: curl http://localhost:8080/ @@ -83,8 +82,8 @@ jobs: with: repository: 'home-assistant/iOS' ref: '6d6606aed63a778c5a2bd64f8981823433a7f2fa' - - # Use github.event.pull_request.head.sha instead of github.sha when available as + + # Use github.event.pull_request.head.sha instead of github.sha when available as # the github.sha is the pre merge commit id for PRs. # See https://github.community/t/github-sha-isnt-the-value-expected/17903/17906. - name: Download Apply Patch Script @@ -102,14 +101,14 @@ jobs: run: ./apply-patch.sh "${{ github.event.pull_request.head.sha }}" "${{ github.sha }}" add-sentry-to-homekit - uses: actions/cache@v3 - name: "Cache: Gems" + name: 'Cache: Gems' id: cache_gems with: path: vendor/bundle key: home-assistant-integration-gems-${{ runner.os }}-${{ env.ImageVersion }}-${{ env.DEVELOPER_DIR }}-${{ hashFiles('**/Gemfile.lock') }} - uses: actions/cache@v3 - name: "Cache: Pods" + name: 'Cache: Pods' id: cache_pods if: steps.cache_gems.outputs.cache-hit == 'true' with: @@ -133,7 +132,7 @@ jobs: bundle exec pod install --repo-update - name: Run tests - # Run the tests twice in case they are flaky. + # Run the tests twice in case they are flaky. run: | bundle config set --local path 'vendor/bundle' for i in {1..2}; do bundle exec fastlane test && break ; done @@ -150,7 +149,7 @@ jobs: repository: 'videolan/vlc-ios' ref: '5d2b5505edc3387cad43deca14c0bd0b19e3f133' - # Use github.event.pull_request.head.sha instead of github.sha when available as + # Use github.event.pull_request.head.sha instead of github.sha when available as # the github.sha is the pre merge commit id for PRs. # See https://github.community/t/github-sha-isnt-the-value-expected/17903/17906. - name: Download Apply Patch Script @@ -168,7 +167,7 @@ jobs: run: ./apply-patch.sh "${{ github.event.pull_request.head.sha }}" "${{ github.sha }}" add-sentry-to-vlc - uses: actions/cache@v3 - name: "Cache: Pods" + name: 'Cache: Pods' id: cache-pods with: path: Pods @@ -180,5 +179,5 @@ jobs: run: pod install - name: Run UI Tests - # Run the tests twice in case they are flaky. + # Run the tests twice in case they are flaky. run: for i in {1..2} ; do set -o pipefail && env NSUnbufferedIO=YES xcodebuild -workspace "VLC.xcworkspace" -scheme "VLC-iOS-UITests" -destination "OS=15.5,name=iPhone 13 Pro" test | xcpretty && break ; done diff --git a/.github/workflows/profile-data-generator.yml b/.github/workflows/profile-data-generator.yml index 7e292cbc9a1..92e15eb2741 100644 --- a/.github/workflows/profile-data-generator.yml +++ b/.github/workflows/profile-data-generator.yml @@ -86,7 +86,7 @@ jobs: strategy: fail-fast: false matrix: - suite: ["High-end device", "Mid-range device"] + suite: ['High-end device', 'Mid-range device'] steps: - uses: actions/checkout@v3 - uses: actions/download-artifact@v3 diff --git a/.github/workflows/saucelabs-UI-tests.yml b/.github/workflows/saucelabs-UI-tests.yml index 1a8bd4b42e9..ab6d2ed9d1d 100644 --- a/.github/workflows/saucelabs-UI-tests.yml +++ b/.github/workflows/saucelabs-UI-tests.yml @@ -22,14 +22,14 @@ jobs: build-ui-tests: name: Build UITests with Xcode ${{matrix.xcode}} runs-on: ${{matrix.runs-on}} - strategy: + strategy: matrix: include: - runs-on: macos-11 - xcode: "12.5.1" + xcode: '12.5.1' - runs-on: macos-12 - xcode: "13.4.1" + xcode: '13.4.1' steps: - uses: actions/checkout@v3 @@ -81,33 +81,31 @@ jobs: **/Debug-iphoneos/iOS-Swift.app **/Debug-iphoneos/iOS-SwiftUITests-Runner.app - run-ui-tests-with-sauce: name: Run UI Tests for iOS ${{ matrix.suite }} on Sauce Labs runs-on: ubuntu-latest needs: build-ui-tests - strategy: + strategy: fail-fast: false matrix: include: - - xcode: "13.4.1" - suite: "iOS-15" + - xcode: '13.4.1' + suite: 'iOS-15' # We want to test the frame tracker at 120 fps - - xcode: "13.4.1" - suite: "iPhone-Pro" + - xcode: '13.4.1' + suite: 'iPhone-Pro' - - xcode: "13.4.1" - suite: "iOS-14" + - xcode: '13.4.1' + suite: 'iOS-14' - - xcode: "13.4.1" - suite: "iOS-13" + - xcode: '13.4.1' + suite: 'iOS-13' # iOS 12 has a failing test that we need to fix https://github.com/getsentry/sentry-cocoa/issues/1566 # iOS 11 keeps timing out and we don't know how to fix it. - - - xcode: "12.5.1" - suite: "iOS-10" + - xcode: '12.5.1' + suite: 'iOS-10' steps: - uses: actions/checkout@v3 @@ -123,4 +121,4 @@ jobs: env: SAUCE_USERNAME: ${{ secrets.SAUCE_USERNAME }} SAUCE_ACCESS_KEY: ${{ secrets.SAUCE_ACCESS_KEY }} - run: for i in {1..5}; do saucectl run --select-suite ${{ matrix.suite }} && break ; done + run: for i in {1..5}; do saucectl run --select-suite ${{ matrix.suite }} && break ; done diff --git a/.github/workflows/stale.yml b/.github/workflows/stale.yml index c05d0338d42..fcc7ef0aaaa 100644 --- a/.github/workflows/stale.yml +++ b/.github/workflows/stale.yml @@ -12,14 +12,14 @@ jobs: repo-token: ${{ github.token }} days-before-stale: 21 days-before-close: 7 - only-labels: "" + only-labels: '' operations-per-run: 100 remove-stale-when-updated: true debug-only: false ascending: false - exempt-issue-labels: "Status: Backlog,Status: In Progress" - stale-issue-label: "Status: Stale" + exempt-issue-labels: 'Status: Backlog,Status: In Progress' + stale-issue-label: 'Status: Stale' stale-issue-message: |- This issue has gone three weeks without activity. In another week, I will close it. @@ -29,11 +29,11 @@ jobs: "A weed is but an unloved flower." ― _Ella Wheeler Wilcox_ 🥀 skip-stale-issue-message: false - close-issue-label: "" - close-issue-message: "" + close-issue-label: '' + close-issue-message: '' - exempt-pr-labels: "Status: Backlog,Status: In Progress" - stale-pr-label: "Status: Stale" + exempt-pr-labels: 'Status: Backlog,Status: In Progress' + stale-pr-label: 'Status: Stale' stale-pr-message: |- This pull request has gone three weeks without activity. In another week, I will close it. @@ -44,4 +44,4 @@ jobs: "A weed is but an unloved flower." ― _Ella Wheeler Wilcox_ 🥀 skip-stale-pr-message: false close-pr-label: - close-pr-message: "" + close-pr-message: '' diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 6da05b039be..c0e24059568 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -55,79 +55,78 @@ jobs: runs-on: ${{matrix.runs-on}} timeout-minutes: 20 needs: build-test-server - - strategy: + + strategy: fail-fast: false matrix: - # Can't run tests on watchOS because XCTest is not available + # Can't run tests on watchOS because XCTest is not available # We can't use Xcode 10.3 because our tests contain a reference to MacCatalyst, # which is only available since iOS 13 / Xcode 11. # We can't use Xcode 11.7 as we use XCTestObservation. When building with Xcode 11.7 # we get the error 'XCTest/XCTest.h' not found. Setting ENABLE_TESTING_SEARCH_PATH=YES - # doesn't work. - + # doesn't work. include: # Test on iOS 12.4 - runs-on: macos-10.15 - platform: "iOS" - xcode: "12.4" - test-destination-os: "12.4" + platform: 'iOS' + xcode: '12.4' + test-destination-os: '12.4' - # Test on iOS 13.7 - - runs-on: macos-11 - platform: "iOS" - xcode: "13.2.1" - test-destination-os: "13.7" + # Test on iOS 13.7 + - runs-on: macos-11 + platform: 'iOS' + xcode: '13.2.1' + test-destination-os: '13.7' # iOS 14 - runs-on: macos-11 - platform: "iOS" - xcode: "12.5.1" - test-destination-os: "latest" + platform: 'iOS' + xcode: '12.5.1' + test-destination-os: 'latest' # iOS 15 - runs-on: macos-12 - platform: "iOS" - xcode: "13.4.1" - test-destination-os: "latest" + platform: 'iOS' + xcode: '13.4.1' + test-destination-os: 'latest' # iOS 16 - runs-on: macos-12 - platform: "iOS" - xcode: "14.0" - test-destination-os: "latest" + platform: 'iOS' + xcode: '14.0' + test-destination-os: 'latest' # macOS 11 - runs-on: macos-11 - platform: "macOS" - xcode: "12.5.1" - test-destination-os: "latest" + platform: 'macOS' + xcode: '12.5.1' + test-destination-os: 'latest' # macOS 12 - runs-on: macos-12 - platform: "macOS" - xcode: "13.4.1" - test-destination-os: "latest" + platform: 'macOS' + xcode: '13.4.1' + 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-12 - platform: "Catalyst" - xcode: "13.4.1" - test-destination-os: "latest" + platform: 'Catalyst' + xcode: '13.4.1' + test-destination-os: 'latest' # tvOS 4 - runs-on: macos-11 - platform: "tvOS" - xcode: "12.5.1" - test-destination-os: "latest" + platform: 'tvOS' + xcode: '12.5.1' + test-destination-os: 'latest' # tvOS 15 - runs-on: macos-12 - platform: "tvOS" - xcode: "13.4.1" - test-destination-os: "latest" + platform: 'tvOS' + xcode: '13.4.1' + test-destination-os: 'latest' steps: - uses: actions/checkout@v3 @@ -144,24 +143,24 @@ jobs: # we can't run the tests with Xcode 10.3. Therefore we use a workaround with a symlink pointed out in: # https://github.com/actions/virtual-environments/issues/551#issuecomment-637344435 - name: Prepare iOS 12.4 simulator - if: ${{ matrix.platform == 'iOS' && matrix.test-destination-os == '12.4'}} + if: ${{ matrix.platform == 'iOS' && matrix.test-destination-os == '12.4'}} run: | sudo mkdir -p /Library/Developer/CoreSimulator/Profiles/Runtimes sudo ln -s /Applications/Xcode_10.3.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/Library/CoreSimulator/Profiles/Runtimes/iOS.simruntime /Library/Developer/CoreSimulator/Profiles/Runtimes/iOS\ 12.4.simruntime xcrun simctl create custom-test-device "iPhone 8" "com.apple.CoreSimulator.SimRuntime.iOS-12-4" - name: Prepare iOS 13.7 simulator - if: ${{ matrix.platform == 'iOS' && matrix.test-destination-os == '13.7'}} + if: ${{ matrix.platform == 'iOS' && matrix.test-destination-os == '13.7'}} run: | sudo mkdir -p /Library/Developer/CoreSimulator/Profiles/Runtimes sudo ln -s /Applications/Xcode_11.7.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime /Library/Developer/CoreSimulator/Profiles/Runtimes/iOS\ 13.7.simruntime - xcrun simctl create custom-test-device "iPhone 8" "com.apple.CoreSimulator.SimRuntime.iOS-13-7" + xcrun simctl create custom-test-device "iPhone 8" "com.apple.CoreSimulator.SimRuntime.iOS-13-7" - name: Running tests # We call a script with the platform so the destination - # passed to xcodebuild doesn't end up in the job name, - # because GitHub Actions don't provide an easy way of - # manipulating string in expressions. + # passed to xcodebuild doesn't end up in the job name, + # because GitHub Actions don't provide an easy way of + # manipulating string in expressions. run: ./scripts/xcode-test.sh ${{matrix.platform}} ${{matrix.test-destination-os}} ${{matrix.xcode}} $GITHUB_REF_NAME - name: Archiving DerivedData Logs @@ -179,23 +178,22 @@ jobs: name: raw-test-output-${{matrix.platform}}-xcode-${{matrix.xcode}}-os-${{matrix.test-destination-os}} path: | raw-test-output.log - # We can upload all coverage reports, because codecov merges them. # See https://docs.codecov.io/docs/merging-reports # Checkout .codecov.yml to see the config of Codecov - name: Push code coverage to codecov - uses: codecov/codecov-action@v3 - + uses: codecov/codecov-action@d9f34f8cd5cb3b3eb79b3e4b5dae3a16df499a70 # pin@v3 + # SentrySystemEventsBreadcrumbsTest only run on Catalyst and iOS # so the coverage report shows a reduced coverage. - if: ${{ contains(matrix.platform, 'Mac Catalyst') || contains(matrix.platform, 'iOS') }} + if: ${{ contains(matrix.platform, 'Mac Catalyst') || contains(matrix.platform, 'iOS') }} # We don't run all unit tests with Thread Sanitizer enabled because # that adds a significant overhead. thread-sanitizer: name: Unit iOS - Thread Sanitizer - runs-on: macos-12 + runs-on: macos-12 # When there are threading issues the tests sometimes keep hanging timeout-minutes: 20 @@ -221,23 +219,22 @@ jobs: - name: Running tests with ThreadSanitizer run: ./scripts/tests-with-thread-sanitizer.sh - + - name: Archiving Test Logs uses: actions/upload-artifact@v3 with: path: thread-sanitizer.log - ui-tests: name: UI Tests for ${{matrix.target}} on Simulators runs-on: macos-12 strategy: matrix: - target: ["ios_swift", "ios_objc", "tvos_swift" ] + target: ['ios_swift', 'ios_objc', 'tvos_swift'] steps: - uses: actions/checkout@v3 - - run: ./scripts/ci-select-xcode.sh + - run: ./scripts/ci-select-xcode.sh # GitHub Actions sometimes fail to launch the UI tests. Therefore we retry - name: Run Fastlane @@ -250,16 +247,16 @@ jobs: runs-on: ${{matrix.runs-on}} strategy: fail-fast: false - matrix: + matrix: include: - runs-on: macos-12 - xcode: "13.4.1" - device: "iPhone 8 (15.2)" + xcode: '13.4.1' + device: 'iPhone 8 (15.2)' - runs-on: macos-11 - xcode: "12.5.1" - device: "iPhone 8 (14.5)" - + xcode: '12.5.1' + device: 'iPhone 8 (14.5)' + steps: - uses: actions/checkout@v3 - run: ./scripts/ci-select-xcode.sh ${{matrix.xcode}} @@ -275,7 +272,7 @@ jobs: runs-on: macos-10.15 strategy: matrix: - target: ["ios_swift", "ios_objc", "tvos_swift" ] + target: ['ios_swift', 'ios_objc', 'tvos_swift'] steps: - uses: actions/checkout@v3 diff --git a/.github/workflows/testflight.yml b/.github/workflows/testflight.yml index 0d156a6a219..12864443079 100644 --- a/.github/workflows/testflight.yml +++ b/.github/workflows/testflight.yml @@ -11,7 +11,6 @@ on: - 'scripts/ci-select-xcode.sh' jobs: - upload_to_testflight: name: Build and Upload iOS-Swift to Testflight runs-on: macos-12 @@ -23,7 +22,7 @@ jobs: # We upload a new version to TestFlight on every commit on Master # So we need to bump the build number each time - name: Bump Build Version - env: + env: FASTLANE_BUILD_NUMBER: ${{ github.run_number }} run: bundle exec fastlane bump_build_number @@ -48,7 +47,7 @@ jobs: - name: Archiving uses: actions/upload-artifact@v3 with: - name: dSYMs + name: dSYMs path: | ${{ github.workspace }}/iOS-Swift.* ${{ github.workspace }}/*.dSYM.zip From ee127f4baeaeee116b81fefd850e3b84e48cbae1 Mon Sep 17 00:00:00 2001 From: Kevin Renskers Date: Tue, 4 Oct 2022 15:51:18 +0200 Subject: [PATCH 07/16] fix: Fix VLC integration test (#2251) Use iOS 16.0 --- .github/workflows/integration-tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/integration-tests.yml b/.github/workflows/integration-tests.yml index 54463668110..41341944001 100644 --- a/.github/workflows/integration-tests.yml +++ b/.github/workflows/integration-tests.yml @@ -180,4 +180,4 @@ jobs: - name: Run UI Tests # Run the tests twice in case they are flaky. - run: for i in {1..2} ; do set -o pipefail && env NSUnbufferedIO=YES xcodebuild -workspace "VLC.xcworkspace" -scheme "VLC-iOS-UITests" -destination "OS=15.5,name=iPhone 13 Pro" test | xcpretty && break ; done + run: for i in {1..2} ; do set -o pipefail && env NSUnbufferedIO=YES xcodebuild -workspace "VLC.xcworkspace" -scheme "VLC-iOS-UITests" -destination "platform=iOS Simulator,OS=16.0,name=iPhone 13 Pro" test | xcpretty && break ; done From c61d8693ae57394d82c1379aa7b2bf32fccdcee9 Mon Sep 17 00:00:00 2001 From: Philipp Hofmann Date: Tue, 4 Oct 2022 16:59:29 +0200 Subject: [PATCH 08/16] ci: Fix Validate podspec (#2253) Since October 3rd the default Xcode version is 14.0.1, which breaks pod lib lint. Ideally, we fix the underlying issue but for now, let's keep using Xcode 13.4.1 for pod lib lint. --- .github/workflows/lint.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index cc3107bbee9..2397b2d7b87 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -45,6 +45,7 @@ jobs: runs-on: macos-12 steps: - uses: actions/checkout@v3 + - run: ./scripts/ci-select-xcode.sh - name: Validate Podspec run: pod lib lint --verbose shell: sh From 6760996dfbdf41831a77fd7859d26eca81d45d32 Mon Sep 17 00:00:00 2001 From: Andrew McKnight Date: Tue, 4 Oct 2022 10:18:49 -0500 Subject: [PATCH 09/16] fix: adverse frame timestamps (#2226) * remove duplicate assignment of current->previous frame timestamp before usages testing stuff: * factor out assert(slow:frozen:total:) function and add assert for adverse timestamps and frame rate timestamps * always record timestamps when testing instead of checking if profiling is enabled various cleanup: * rename assertPreviousCountBiggerThanCurrent->assertPreviousCountLesserThanCurrent * set to default frame rate in divide by 0 situations * clarify the checks made before recording a frame rate, and dont record insignificant rate changes --- CHANGELOG.md | 1 + Sources/Sentry/SentryBacktrace.cpp | 3 - Sources/Sentry/SentryFramesTracker.m | 52 +++++++++----- .../SentryFramesTrackerTests.swift | 67 +++++++++++-------- 4 files changed, 76 insertions(+), 47 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0fab681a1ad..393f25a990b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ ### Fixes - Return SentryNoOpSpan when starting a child on a finished transaction (#2239) +- Fix profiling timestamps for slow/frozen frames (#2226) ## 7.27.0 diff --git a/Sources/Sentry/SentryBacktrace.cpp b/Sources/Sentry/SentryBacktrace.cpp index 401285c7d49..dc0c557f58a 100644 --- a/Sources/Sentry/SentryBacktrace.cpp +++ b/Sources/Sentry/SentryBacktrace.cpp @@ -19,9 +19,6 @@ using namespace sentry::profiling; using namespace sentry::profiling::thread; -# define LIKELY(x) __builtin_expect(!!(x), 1) -# define UNLIKELY(x) __builtin_expect(!!(x), 0) - namespace { ALWAYS_INLINE bool isValidFrame(std::uintptr_t frame, const StackBounds &bounds) diff --git a/Sources/Sentry/SentryFramesTracker.m b/Sources/Sentry/SentryFramesTracker.m index b7fbebce0f5..0bb56ce673d 100644 --- a/Sources/Sentry/SentryFramesTracker.m +++ b/Sources/Sentry/SentryFramesTracker.m @@ -1,4 +1,5 @@ #import "SentryFramesTracker.h" +#import "SentryCompiler.h" #import "SentryDisplayLinkWrapper.h" #import "SentryProfilingConditionals.h" #import "SentryTracer.h" @@ -102,10 +103,10 @@ - (void)start - (void)displayLinkCallback { - CFTimeInterval lastFrameTimestamp = self.displayLinkWrapper.timestamp; + CFTimeInterval thisFrameTimestamp = self.displayLinkWrapper.timestamp; if (self.previousFrameTimestamp == SentryPreviousFrameInitialValue) { - self.previousFrameTimestamp = lastFrameTimestamp; + self.previousFrameTimestamp = thisFrameTimestamp; return; } @@ -118,15 +119,30 @@ - (void)displayLinkCallback // 60 fps. double actualFramesPerSecond = 60.0; if (@available(iOS 10.0, tvOS 10.0, *)) { - actualFramesPerSecond - = 1 / (self.displayLinkWrapper.targetTimestamp - self.displayLinkWrapper.timestamp); + if (UNLIKELY( + (self.displayLinkWrapper.targetTimestamp == self.displayLinkWrapper.timestamp))) { + actualFramesPerSecond = 60.0; + } else { + actualFramesPerSecond + = 1 / (self.displayLinkWrapper.targetTimestamp - self.displayLinkWrapper.timestamp); + } } # if SENTRY_TARGET_PROFILING_SUPPORTED - if (self.currentTracer.isProfiling - && (self.frameRateTimestamps.count == 0 - || self.frameRateTimestamps.lastObject[@"frame_rate"].doubleValue - != actualFramesPerSecond)) { +# if defined(TEST) || defined(TESTCI) + BOOL shouldRecordFrameRates = YES; +# else + BOOL shouldRecordFrameRates = self.currentTracer.isProfiling; +# endif // defined(TEST) || defined(TESTCI) + BOOL hasNoFrameRatesYet = self.frameRateTimestamps.count == 0; + BOOL frameRateSignificantlyChanged + = fabs(self.frameRateTimestamps.lastObject[@"frame_rate"].doubleValue + - actualFramesPerSecond) + > 1e-10f; // these may be a small fraction off of a whole number of frames per second, so + // allow some small epsilon difference + BOOL shouldRecordNewFrameRate + = shouldRecordFrameRates && (hasNoFrameRatesYet || frameRateSignificantlyChanged); + if (shouldRecordNewFrameRate) { [self.frameRateTimestamps addObject:@{ @"timestamp" : @(self.displayLinkWrapper.timestamp), @"frame_rate" : @(actualFramesPerSecond), @@ -134,34 +150,36 @@ - (void)displayLinkCallback } # endif // SENTRY_TARGET_PROFILING_SUPPORTED - // Most frames take just a few microseconds longer than the optimal caculated duration. - // Therefore we substract one, because otherwise almost all frames would be slow. + // Most frames take just a few microseconds longer than the optimal calculated duration. + // Therefore we subtract one, because otherwise almost all frames would be slow. CFTimeInterval slowFrameThreshold = 1 / (actualFramesPerSecond - 1); - CFTimeInterval frameDuration = lastFrameTimestamp - self.previousFrameTimestamp; - self.previousFrameTimestamp = lastFrameTimestamp; + CFTimeInterval frameDuration = thisFrameTimestamp - self.previousFrameTimestamp; if (frameDuration > slowFrameThreshold && frameDuration <= SentryFrozenFrameThreshold) { atomic_fetch_add_explicit(&_slowFrames, 1, SentryFramesMemoryOrder); # if SENTRY_TARGET_PROFILING_SUPPORTED - [self recordTimestampStart:@(self.previousFrameTimestamp) end:@(lastFrameTimestamp)]; + [self recordTimestampStart:@(self.previousFrameTimestamp) end:@(thisFrameTimestamp)]; # endif // SENTRY_TARGET_PROFILING_SUPPORTED } else if (frameDuration > SentryFrozenFrameThreshold) { atomic_fetch_add_explicit(&_frozenFrames, 1, SentryFramesMemoryOrder); # if SENTRY_TARGET_PROFILING_SUPPORTED - [self recordTimestampStart:@(self.previousFrameTimestamp) end:@(lastFrameTimestamp)]; + [self recordTimestampStart:@(self.previousFrameTimestamp) end:@(thisFrameTimestamp)]; # endif // SENTRY_TARGET_PROFILING_SUPPORTED } atomic_fetch_add_explicit(&_totalFrames, 1, SentryFramesMemoryOrder); - - self.previousFrameTimestamp = lastFrameTimestamp; + self.previousFrameTimestamp = thisFrameTimestamp; } # if SENTRY_TARGET_PROFILING_SUPPORTED - (void)recordTimestampStart:(NSNumber *)start end:(NSNumber *)end { - if (self.currentTracer.isProfiling) { + BOOL shouldRecord = self.currentTracer.isProfiling; +# if defined(TEST) || defined(TESTCI) + shouldRecord = YES; +# endif + if (shouldRecord) { [self.frameTimestamps addObject:@{ @"start_timestamp" : start, @"end_timestamp" : end }]; } } diff --git a/Tests/SentryTests/Integrations/Performance/FramesTracking/SentryFramesTrackerTests.swift b/Tests/SentryTests/Integrations/Performance/FramesTracking/SentryFramesTrackerTests.swift index 0557fe43471..98a44962196 100644 --- a/Tests/SentryTests/Integrations/Performance/FramesTracking/SentryFramesTrackerTests.swift +++ b/Tests/SentryTests/Integrations/Performance/FramesTracking/SentryFramesTrackerTests.swift @@ -13,9 +13,9 @@ class SentryFramesTrackerTests: XCTestCase { queue = DispatchQueue(label: "SentryFramesTrackerTests", qos: .background, attributes: [.concurrent]) } - var sut: SentryFramesTracker { + lazy var sut: SentryFramesTracker = { return SentryFramesTracker(displayLinkWrapper: displayLinkWrapper) - } + }() } private var fixture: Fixture! @@ -50,11 +50,8 @@ class SentryFramesTrackerTests: XCTestCase { fixture.displayLinkWrapper.slowFrame() fixture.displayLinkWrapper.normalFrame() fixture.displayLinkWrapper.almostFrozenFrame() - - let currentFrames = sut.currentFrames - XCTAssertEqual(2, currentFrames.slow) - XCTAssertEqual(3, currentFrames.total) - XCTAssertEqual(0, currentFrames.frozen) + + assert(slow: 2, frozen: 0, total: 3) } func testFrozenFrame() { @@ -64,11 +61,8 @@ class SentryFramesTrackerTests: XCTestCase { fixture.displayLinkWrapper.call() fixture.displayLinkWrapper.slowFrame() fixture.displayLinkWrapper.frozenFrame() - - let currentFrames = sut.currentFrames - XCTAssertEqual(1, currentFrames.slow) - XCTAssertEqual(2, currentFrames.total) - XCTAssertEqual(1, currentFrames.frozen) + + assert(slow: 1, frozen: 1, total: 2) } func testAllFrames_ConcurrentRead() { @@ -76,11 +70,11 @@ class SentryFramesTrackerTests: XCTestCase { sut.start() let group = DispatchGroup() - - var currentFrames = sut.currentFrames - assertPreviousCountBiggerThanCurrent(group) { return currentFrames.frozen } - assertPreviousCountBiggerThanCurrent(group) { return currentFrames.slow } - assertPreviousCountBiggerThanCurrent(group) { return currentFrames.total } + + let currentFrames = sut.currentFrames + assertPreviousCountLesserThanCurrent(group) { return currentFrames.frozen } + assertPreviousCountLesserThanCurrent(group) { return currentFrames.slow } + assertPreviousCountLesserThanCurrent(group) { return currentFrames.total } fixture.displayLinkWrapper.call() @@ -92,10 +86,7 @@ class SentryFramesTrackerTests: XCTestCase { } group.wait() - currentFrames = sut.currentFrames - XCTAssertEqual(3 * frames, currentFrames.total) - XCTAssertEqual(frames, currentFrames.slow) - XCTAssertEqual(frames, currentFrames.frozen) + assert(slow: frames, frozen: frames, total: 3 * frames) } func testPerformanceOfTrackingFrames() { @@ -108,12 +99,35 @@ class SentryFramesTrackerTests: XCTestCase { fixture.displayLinkWrapper.normalFrame() } } - - XCTAssertEqual(0, sut.currentFrames.slow) - XCTAssertEqual(0, sut.currentFrames.frozen) + + assert(slow: 0, frozen: 0) } - - private func assertPreviousCountBiggerThanCurrent(_ group: DispatchGroup, count: @escaping () -> UInt) { +} + +private extension SentryFramesTrackerTests { + func assert(slow: UInt? = nil, frozen: UInt? = nil, total: UInt? = nil) { + let currentFrames = fixture.sut.currentFrames + if let total = total { + XCTAssertEqual(total, currentFrames.total) + } + if let slow = slow { + XCTAssertEqual(slow, currentFrames.slow) + } + if let frozen = frozen { + XCTAssertEqual(frozen, currentFrames.frozen) + } +#if SENTRY_TARGET_PROFILING_SUPPORTED + if ((slow ?? 0) + (frozen ?? 0)) > 0 { + XCTAssertGreaterThan(currentFrames.frameTimestamps.count, 0) + for frame in currentFrames.frameTimestamps { + XCTAssertFalse(frame["start_timestamp"] == frame["end_timestamp"]) + } + } + XCTAssertGreaterThan(currentFrames.frameRateTimestamps.count, 0) +#endif + } + + private func assertPreviousCountLesserThanCurrent(_ group: DispatchGroup, count: @escaping () -> UInt) { group.enter() fixture.queue.async { var previousCount: UInt = 0 @@ -125,7 +139,6 @@ class SentryFramesTrackerTests: XCTestCase { group.leave() } } - } #endif From 4a257fb961ef018a061524a2f3ee5964f3bfa51e Mon Sep 17 00:00:00 2001 From: Philipp Hofmann Date: Tue, 4 Oct 2022 17:20:03 +0200 Subject: [PATCH 10/16] ci: Run pod lib lint in parallel (#2255) Pod lib lint runs validations for all platforms sequentially. We can speed up CI by using a matrix for each platform, so they run in parallel. --- .github/workflows/lint.yml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 2397b2d7b87..95429f1707b 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -43,11 +43,15 @@ jobs: validate-podspec: name: Validate Podspec runs-on: macos-12 + strategy: + matrix: + platform: ['ios', 'macos', 'tvos', 'watchos'] + steps: - uses: actions/checkout@v3 - run: ./scripts/ci-select-xcode.sh - name: Validate Podspec - run: pod lib lint --verbose + run: pod lib lint --verbose --platforms=${{ matrix.platform }} shell: sh validate-high-risk-files: From 347a8e9283b68c324cdd87978f84033339ccfc4e Mon Sep 17 00:00:00 2001 From: Philipp Hofmann Date: Tue, 4 Oct 2022 17:23:12 +0200 Subject: [PATCH 11/16] ci: Remove test retries (#2242) Instead of retrying the failing tests multiple times, we should fix them or disable them. Retry can hide flaky tests. Furthermore, retries slow down CI. --- .../xcshareddata/xcschemes/iOS-Swift.xcscheme | 5 ++ .../xcshareddata/xcschemes/Sentry.xcscheme | 3 ++ .../SentrySystemEventBreadcrumbsTest.swift | 2 +- ...SentryFileIOTrackingIntegrationTests.swift | 2 +- scripts/xcode-test.sh | 48 +------------------ 5 files changed, 12 insertions(+), 48 deletions(-) diff --git a/Samples/iOS-Swift/iOS-Swift.xcodeproj/xcshareddata/xcschemes/iOS-Swift.xcscheme b/Samples/iOS-Swift/iOS-Swift.xcodeproj/xcshareddata/xcschemes/iOS-Swift.xcscheme index 85036ca1718..19ea1dabdc1 100644 --- a/Samples/iOS-Swift/iOS-Swift.xcodeproj/xcshareddata/xcschemes/iOS-Swift.xcscheme +++ b/Samples/iOS-Swift/iOS-Swift.xcodeproj/xcshareddata/xcschemes/iOS-Swift.xcscheme @@ -37,6 +37,11 @@ BlueprintName = "iOS-SwiftUITests" ReferencedContainer = "container:iOS-Swift.xcodeproj"> + + + + diff --git a/Sentry.xcodeproj/xcshareddata/xcschemes/Sentry.xcscheme b/Sentry.xcodeproj/xcshareddata/xcschemes/Sentry.xcscheme index c45165f8334..77bb934edc7 100644 --- a/Sentry.xcodeproj/xcshareddata/xcschemes/Sentry.xcscheme +++ b/Sentry.xcodeproj/xcshareddata/xcschemes/Sentry.xcscheme @@ -61,6 +61,9 @@ + + diff --git a/Tests/SentryTests/Integrations/Breadcrumbs/SentrySystemEventBreadcrumbsTest.swift b/Tests/SentryTests/Integrations/Breadcrumbs/SentrySystemEventBreadcrumbsTest.swift index 2b1f8818d41..6d21fd29507 100644 --- a/Tests/SentryTests/Integrations/Breadcrumbs/SentrySystemEventBreadcrumbsTest.swift +++ b/Tests/SentryTests/Integrations/Breadcrumbs/SentrySystemEventBreadcrumbsTest.swift @@ -252,7 +252,7 @@ class SentrySystemEventBreadcrumbsTest: XCTestCase { } } - func testTimezoneChangeNotificationBreadcrumb() { + func testTimezoneChangeNotificationBreadcrumb_disabled() { let scope = Scope() sut = fixture.getSut(scope: scope, currentDevice: nil) diff --git a/Tests/SentryTests/Integrations/Performance/IO/SentryFileIOTrackingIntegrationTests.swift b/Tests/SentryTests/Integrations/Performance/IO/SentryFileIOTrackingIntegrationTests.swift index ca59fa5f8e3..6bdeb55a0e7 100644 --- a/Tests/SentryTests/Integrations/Performance/IO/SentryFileIOTrackingIntegrationTests.swift +++ b/Tests/SentryTests/Integrations/Performance/IO/SentryFileIOTrackingIntegrationTests.swift @@ -205,7 +205,7 @@ class SentryFileIOTrackingIntegrationTests: XCTestCase { XCTAssertEqual(randomValue, readValue) } - func test_DataConsistency_readPath() { + func test_DataConsistency_readPath_disabled() { SentrySDK.start(options: fixture.getOptions()) let randomValue = UUID().uuidString diff --git a/scripts/xcode-test.sh b/scripts/xcode-test.sh index ee75c9e3834..b157b5918aa 100755 --- a/scripts/xcode-test.sh +++ b/scripts/xcode-test.sh @@ -53,8 +53,6 @@ esac echo "CONFIGURATION: $CONFIGURATION" -XCODE_MAJOR_VERSION=$(echo $XCODE | sed -E 's/([0-9]*)\.[0-9]*\.?[0-9]+/\1/g') - if [ $PLATFORM == "iOS" -a $OS == "12.4" ]; then # Skip some tests that fail on iOS 12.4. env NSUnbufferedIO=YES xcodebuild -workspace Sentry.xcworkspace \ @@ -63,51 +61,9 @@ if [ $PLATFORM == "iOS" -a $OS == "12.4" ]; then -skip-testing:"SentryTests/SentrySDKTests/testMemoryFootprintOfAddingBreadcrumbs" \ -skip-testing:"SentryTests/SentrySDKTests/testMemoryFootprintOfTransactions" \ test | tee raw-test-output.log | xcpretty -t && exit ${PIPESTATUS[0]} -elif [ $XCODE_MAJOR_VERSION == "13" ] || [ $XCODE_MAJOR_VERSION == "14" ]; then - # We can retry flaky tests that fail with the -retry-tests-on-failure option introduced in Xcode 13. - env NSUnbufferedIO=YES xcodebuild -retry-tests-on-failure -test-iterations 3 -workspace Sentry.xcworkspace \ - -scheme Sentry -configuration $CONFIGURATION \ - GCC_GENERATE_TEST_COVERAGE_FILES=YES GCC_INSTRUMENT_PROGRAM_FLOW_ARCS=YES -destination "$DESTINATION" \ - test | tee raw-test-output.log | xcpretty -t && exit ${PIPESTATUS[0]} -elif [ $XCODE_MAJOR_VERSION == "12" ]; then - # To retry flaky tests in Xcode <13, Run the suite normally without them, then run the suite with just the known flaky tests up to 3 times in a bash loop because xcodebuild didn't get the -retry-tests-on-failure option until version 13. - env NSUnbufferedIO=YES xcodebuild -workspace Sentry.xcworkspace \ - -scheme Sentry -configuration $CONFIGURATION \ - GCC_GENERATE_TEST_COVERAGE_FILES=YES GCC_INSTRUMENT_PROGRAM_FLOW_ARCS=YES -destination "$DESTINATION" \ - -skip-testing:"SentryTests/SentrySessionTrackerTests" \ - test | tee raw-test-output.log | xcpretty -t - nonflaky_test_status=${PIPESTATUS[0]} - - # try the flaky tests once. if they pass, exit with the combined status of flaky and nonflaky tests. - # if they fail, retry them twice more. - +else env NSUnbufferedIO=YES xcodebuild -workspace Sentry.xcworkspace \ -scheme Sentry -configuration $CONFIGURATION \ GCC_GENERATE_TEST_COVERAGE_FILES=YES GCC_INSTRUMENT_PROGRAM_FLOW_ARCS=YES -destination "$DESTINATION" \ - -only-testing:"SentryTests/SentrySessionTrackerTests" \ - test | tee raw-test-output.log | xcpretty -t - flaky_test_status=${PIPESTATUS[0]} - if [ $flaky_test_status -eq 0 ]; then - exit $nonflaky_test_status - else - for i in {1..2}; do - bash -c "env NSUnbufferedIO=YES xcodebuild -workspace Sentry.xcworkspace \ - -scheme Sentry -configuration $CONFIGURATION \ - GCC_GENERATE_TEST_COVERAGE_FILES=YES GCC_INSTRUMENT_PROGRAM_FLOW_ARCS=YES -destination '$DESTINATION' \ - -only-testing:'SentryTests/SentrySessionTrackerTests' \ - test-without-building | tee raw-test-output.log | xcpretty -t && exit ${PIPESTATUS[0]}" - flaky_test_status=$? - if [ $flaky_test_status -eq 0 ]; then - exit $nonflaky_test_status - fi - done - - # combine flaky/nonflaky statuses for the exit status of this script so that if either have failed, the script will fail - all_test_status=$nonflaky_test_status - let 'all_test_status|=flaky_test_status' - exit $all_test_status - fi -else - # The branches above are exhaustive at the time they were written. This will help us catch unexpected deviations with future changes. - exit 1 + test | tee raw-test-output.log | xcpretty -t && exit ${PIPESTATUS[0]} fi From 604586ac122b5f650622f44081b9e3b7f70f43e6 Mon Sep 17 00:00:00 2001 From: Andrew McKnight Date: Wed, 5 Oct 2022 01:47:51 -0500 Subject: [PATCH 12/16] ref: remove watchkit project from workspace as it is rarely worked on and constantly dirties the index (#2256) --- Sentry.xcworkspace/contents.xcworkspacedata | 3 --- 1 file changed, 3 deletions(-) diff --git a/Sentry.xcworkspace/contents.xcworkspacedata b/Sentry.xcworkspace/contents.xcworkspacedata index ceff7f7f211..6145ea0f3dd 100644 --- a/Sentry.xcworkspace/contents.xcworkspacedata +++ b/Sentry.xcworkspace/contents.xcworkspacedata @@ -16,9 +16,6 @@ - - From db5f62ad930677f9eeb62d0fcd58acafa67862c6 Mon Sep 17 00:00:00 2001 From: Philipp Hofmann Date: Wed, 5 Oct 2022 09:38:30 +0200 Subject: [PATCH 13/16] ci: Fix building watchOS sample (#2260) Was broken with https://github.com/getsentry/sentry-cocoa/pull/2256, as this PR removed it from the workspace. Now we call the project directly. --- .github/workflows/build.yml | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index db2d2780431..43b37d2a658 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -13,6 +13,7 @@ on: - '.github/workflows/build.yml' - 'fastlane/**' - 'scripts/ci-select-xcode.sh' + - Sentry.xcworkspace jobs: # We had issues that the release build was broken on master. @@ -42,21 +43,14 @@ jobs: strategy: fail-fast: false matrix: - beforeXcode: [''] # other sample projects are built in ui-tests scheme: - macOS-Swift - iOS13-Swift - # WatchOS needs Sentry as a XCFramework - include: - - scheme: watchOS-Swift WatchKit App - beforeXcode: 'make build-for-watchos' - steps: - uses: actions/checkout@v3 - run: ./scripts/ci-select-xcode.sh - - run: ${{matrix.beforeXcode}} # Disable code signing. We just want to make sure these compile. - run: >- @@ -68,6 +62,23 @@ jobs: CODE_SIGNING_ALLOWED="NO" build + build-watch-os-sample: + name: Sample watchOS + runs-on: macos-12 + steps: + - uses: actions/checkout@v3 + - run: ./scripts/ci-select-xcode.sh + - run: make build-for-watchos + + # Disable code signing. We just want to make sure these compile. + - run: >- + env NSUnbufferedIO=YES + xcodebuild + -project Samples/watchOS-Swift/watchOS-Swift.xcodeproj + -configuration Debug + CODE_SIGNING_ALLOWED="NO" + build + build-xcframework: name: Build & Validate XCFramework runs-on: macos-12 From fbeb49aa4bf63d1ce6537cbc4d509564d1510617 Mon Sep 17 00:00:00 2001 From: Kevin Renskers Date: Wed, 5 Oct 2022 10:00:19 +0200 Subject: [PATCH 14/16] ref: Remove a possible race condition related to reading previous app state (#2250) --- Sources/Sentry/SentryAppStateManager.m | 7 +- Sources/Sentry/SentryFileManager.m | 68 +++++++++++++++---- Sources/Sentry/SentryOutOfMemoryLogic.m | 2 +- Sources/Sentry/SentryOutOfMemoryTracker.m | 2 +- Sources/Sentry/SentrySDK.m | 3 + .../Sentry/include/SentryAppStateManager.h | 4 +- Sources/Sentry/include/SentryFileManager.h | 2 + .../Helper/SentryFileManagerTests.swift | 18 ++++- .../SentryOutOfMemoryTrackerTests.swift | 14 ++-- .../SentryCrashIntegrationTests.swift | 1 + Tests/SentryTests/TestClient.swift | 6 ++ 11 files changed, 104 insertions(+), 23 deletions(-) diff --git a/Sources/Sentry/SentryAppStateManager.m b/Sources/Sentry/SentryAppStateManager.m index 0459c7a8a96..7c17d4ba17c 100644 --- a/Sources/Sentry/SentryAppStateManager.m +++ b/Sources/Sentry/SentryAppStateManager.m @@ -57,6 +57,11 @@ - (SentryAppState *)buildCurrentAppState systemBootTimestamp:self.sysctl.systemBootTimestamp]; } +- (SentryAppState *)loadPreviousAppState +{ + return [self.fileManager readPreviousAppState]; +} + - (SentryAppState *)loadCurrentAppState { return [self.fileManager readAppState]; @@ -67,7 +72,7 @@ - (void)storeCurrentAppState [self.fileManager storeAppState:[self buildCurrentAppState]]; } -- (void)removeCurrentAppState +- (void)deleteAppState { [self.fileManager deleteAppState]; } diff --git a/Sources/Sentry/SentryFileManager.m b/Sources/Sentry/SentryFileManager.m index 98a8f055ed8..96676404fb1 100644 --- a/Sources/Sentry/SentryFileManager.m +++ b/Sources/Sentry/SentryFileManager.m @@ -23,6 +23,7 @@ @property (nonatomic, copy) NSString *currentSessionFilePath; @property (nonatomic, copy) NSString *crashedSessionFilePath; @property (nonatomic, copy) NSString *lastInForegroundFilePath; +@property (nonatomic, copy) NSString *previousAppStateFilePath; @property (nonatomic, copy) NSString *appStateFilePath; @property (nonatomic, copy) NSString *timezoneOffsetFilePath; @property (nonatomic, assign) NSUInteger currentFileCounter; @@ -65,6 +66,8 @@ - (nullable instancetype)initWithOptions:(SentryOptions *)options self.lastInForegroundFilePath = [self.sentryPath stringByAppendingPathComponent:@"lastInForeground.timestamp"]; + self.previousAppStateFilePath = + [self.sentryPath stringByAppendingPathComponent:@"previous.app.state"]; self.appStateFilePath = [self.sentryPath stringByAppendingPathComponent:@"app.state"]; self.timezoneOffsetFilePath = [self.sentryPath stringByAppendingPathComponent:@"timezone.offset"]; @@ -395,32 +398,71 @@ - (void)storeAppState:(SentryAppState *)appState } } +- (void)moveAppStateToPreviousAppState +{ + @synchronized(self.appStateFilePath) { + NSFileManager *fileManager = [NSFileManager defaultManager]; + NSError *error = nil; + [fileManager moveItemAtPath:self.appStateFilePath + toPath:self.previousAppStateFilePath + error:&error]; + + // We don't want to log an error if the file doesn't exist. + if (nil != error && error.code != NSFileNoSuchFileError) { + [SentryLog + logWithMessage:[NSString + stringWithFormat: + @"Failed to move app state to previous app state: %@", error] + andLevel:kSentryLevelError]; + } + } +} + - (SentryAppState *_Nullable)readAppState +{ + @synchronized(self.appStateFilePath) { + return [self readAppStateFrom:self.appStateFilePath]; + } +} + +- (SentryAppState *_Nullable)readPreviousAppState +{ + @synchronized(self.previousAppStateFilePath) { + return [self readAppStateFrom:self.previousAppStateFilePath]; + } +} + +- (SentryAppState *_Nullable)readAppStateFrom:(NSString *)path { NSFileManager *fileManager = [NSFileManager defaultManager]; NSData *currentData = nil; - @synchronized(self.appStateFilePath) { - currentData = [fileManager contentsAtPath:self.appStateFilePath]; - if (nil == currentData) { - return nil; - } + currentData = [fileManager contentsAtPath:path]; + if (nil == currentData) { + return nil; } return [SentrySerialization appStateWithData:currentData]; } - (void)deleteAppState +{ + @synchronized(self.appStateFilePath) { + [self deleteAppStateFrom:self.appStateFilePath]; + [self deleteAppStateFrom:self.previousAppStateFilePath]; + } +} + +- (void)deleteAppStateFrom:(NSString *)path { NSError *error = nil; NSFileManager *fileManager = [NSFileManager defaultManager]; - @synchronized(self.appStateFilePath) { - [fileManager removeItemAtPath:self.appStateFilePath error:&error]; + [fileManager removeItemAtPath:path error:&error]; - // We don't want to log an error if the file doesn't exist. - if (nil != error && error.code != NSFileNoSuchFileError) { - [SentryLog - logWithMessage:[NSString stringWithFormat:@"Failed to delete app state %@", error] - andLevel:kSentryLevelError]; - } + // We don't want to log an error if the file doesn't exist. + if (nil != error && error.code != NSFileNoSuchFileError) { + [SentryLog + logWithMessage:[NSString stringWithFormat:@"Failed to delete app state from %@: %@", + path, error] + andLevel:kSentryLevelError]; } } diff --git a/Sources/Sentry/SentryOutOfMemoryLogic.m b/Sources/Sentry/SentryOutOfMemoryLogic.m index 7994dcd3938..95fa5a4c1cc 100644 --- a/Sources/Sentry/SentryOutOfMemoryLogic.m +++ b/Sources/Sentry/SentryOutOfMemoryLogic.m @@ -40,7 +40,7 @@ - (BOOL)isOOM } #if SENTRY_HAS_UIKIT - SentryAppState *previousAppState = [self.appStateManager loadCurrentAppState]; + SentryAppState *previousAppState = [self.appStateManager loadPreviousAppState]; SentryAppState *currentAppState = [self.appStateManager buildCurrentAppState]; // If there is no previous app state, we can't do anything. diff --git a/Sources/Sentry/SentryOutOfMemoryTracker.m b/Sources/Sentry/SentryOutOfMemoryTracker.m index 2b30ad7a93d..15ca05e6c6f 100644 --- a/Sources/Sentry/SentryOutOfMemoryTracker.m +++ b/Sources/Sentry/SentryOutOfMemoryTracker.m @@ -129,7 +129,7 @@ - (void)stop removeObserver:self name:SentryNSNotificationCenterWrapper.willTerminateNotificationName object:nil]; - [self.appStateManager removeCurrentAppState]; + [self.appStateManager deleteAppState]; #endif } diff --git a/Sources/Sentry/SentrySDK.m b/Sources/Sentry/SentrySDK.m index 0aaef686538..ad9b925b709 100644 --- a/Sources/Sentry/SentrySDK.m +++ b/Sources/Sentry/SentrySDK.m @@ -146,7 +146,10 @@ + (void)startWithOptionsObject:(SentryOptions *)options startInvocations++; [SentryLog configure:options.debug diagnosticLevel:options.diagnosticLevel]; + SentryClient *newClient = [[SentryClient alloc] initWithOptions:options]; + [newClient.fileManager moveAppStateToPreviousAppState]; + // The Hub needs to be initialized with a client so that closing a session // can happen. [SentrySDK setCurrentHub:[[SentryHub alloc] initWithClient:newClient andScope:nil]]; diff --git a/Sources/Sentry/include/SentryAppStateManager.h b/Sources/Sentry/include/SentryAppStateManager.h index c2e9822f899..14a49f7608f 100644 --- a/Sources/Sentry/include/SentryAppStateManager.h +++ b/Sources/Sentry/include/SentryAppStateManager.h @@ -26,11 +26,13 @@ SENTRY_NO_INIT */ - (SentryAppState *)buildCurrentAppState; +- (SentryAppState *)loadPreviousAppState; + - (SentryAppState *)loadCurrentAppState; - (void)storeCurrentAppState; -- (void)removeCurrentAppState; +- (void)deleteAppState; - (void)updateAppState:(void (^)(SentryAppState *))block; diff --git a/Sources/Sentry/include/SentryFileManager.h b/Sources/Sentry/include/SentryFileManager.h index 16164615a58..fd72e185d5e 100644 --- a/Sources/Sentry/include/SentryFileManager.h +++ b/Sources/Sentry/include/SentryFileManager.h @@ -60,7 +60,9 @@ SENTRY_NO_INIT - (NSString *)storeDictionary:(NSDictionary *)dictionary toPath:(NSString *)path; - (void)storeAppState:(SentryAppState *)appState; +- (void)moveAppStateToPreviousAppState; - (SentryAppState *_Nullable)readAppState; +- (SentryAppState *_Nullable)readPreviousAppState; - (void)deleteAppState; - (NSNumber *_Nullable)readTimezoneOffset; diff --git a/Tests/SentryTests/Helper/SentryFileManagerTests.swift b/Tests/SentryTests/Helper/SentryFileManagerTests.swift index 06806be9bfc..5e6e895db25 100644 --- a/Tests/SentryTests/Helper/SentryFileManagerTests.swift +++ b/Tests/SentryTests/Helper/SentryFileManagerTests.swift @@ -439,6 +439,15 @@ class SentryFileManagerTests: XCTestCase { sut.deleteAppState() XCTAssertNil(sut.readAppState()) } + + func testDeletePreviousAppState() { + sut.store(TestData.appState) + sut.moveAppStateToPreviousAppState() + sut.deleteAppState() + + XCTAssertNil(sut.readAppState()) + XCTAssertNil(sut.readPreviousAppState()) + } func testStore_WhenFileImmutable_AppStateIsNotOverwritten() { sut.store(TestData.appState) @@ -471,6 +480,14 @@ class SentryFileManagerTests: XCTestCase { XCTAssertNotNil(sut.readAppState()) } + func testMoveAppStateAndReadPreviousAppState() { + sut.store(TestData.appState) + sut.moveAppStateToPreviousAppState() + + let actual = sut.readPreviousAppState() + XCTAssertEqual(TestData.appState, actual) + } + func testStoreAndReadTimezoneOffset() { sut.storeTimezoneOffset(7_200) XCTAssertEqual(sut.readTimezoneOffset(), 7_200) @@ -600,7 +617,6 @@ class SentryFileManagerTests: XCTestCase { private func assertValidAppStateStored() { let actual = sut.readAppState() XCTAssertEqual(TestData.appState, actual) - } private func advanceTime(bySeconds: TimeInterval) { diff --git a/Tests/SentryTests/Integrations/OutOfMemory/SentryOutOfMemoryTrackerTests.swift b/Tests/SentryTests/Integrations/OutOfMemory/SentryOutOfMemoryTrackerTests.swift index bb3dc82abd3..7454e29ef05 100644 --- a/Tests/SentryTests/Integrations/OutOfMemory/SentryOutOfMemoryTrackerTests.swift +++ b/Tests/SentryTests/Integrations/OutOfMemory/SentryOutOfMemoryTrackerTests.swift @@ -189,6 +189,7 @@ class SentryOutOfMemoryTrackerTests: NotificationCenterTestCase { sut.start() goToForeground() + fixture.fileManager.moveAppStateToPreviousAppState() sut.start() assertOOMEventSent() } @@ -208,7 +209,8 @@ class SentryOutOfMemoryTrackerTests: NotificationCenterTestCase { func testAppOOM_WithOnlyHybridSdkDidBecomeActive() { sut.start() hybridSdkDidBecomeActive() - + + fixture.fileManager.moveAppStateToPreviousAppState() sut.start() assertOOMEventSent() } @@ -217,7 +219,8 @@ class SentryOutOfMemoryTrackerTests: NotificationCenterTestCase { sut.start() goToForeground() hybridSdkDidBecomeActive() - + + fixture.fileManager.moveAppStateToPreviousAppState() sut.start() assertOOMEventSent() } @@ -226,7 +229,8 @@ class SentryOutOfMemoryTrackerTests: NotificationCenterTestCase { sut.start() hybridSdkDidBecomeActive() goToForeground() - + + fixture.fileManager.moveAppStateToPreviousAppState() sut.start() assertOOMEventSent() } @@ -253,7 +257,7 @@ class SentryOutOfMemoryTrackerTests: NotificationCenterTestCase { func testStop_StopsObserving_NoMoreFileManagerInvocations() throws { let fileManager = try TestFileManager(options: Options(), andCurrentDateProvider: TestCurrentDateProvider()) sut = fixture.getSut(fileManager: fileManager) - + sut.start() sut.stop() @@ -261,7 +265,7 @@ class SentryOutOfMemoryTrackerTests: NotificationCenterTestCase { goToForeground() terminateApp() - XCTAssertEqual(1, fileManager.readAppStateInvocations.count) + XCTAssertEqual(1, fileManager.readPreviousAppStateInvocations.count) } private func givenPreviousAppState(appState: SentryAppState) { diff --git a/Tests/SentryTests/Integrations/SentryCrash/SentryCrashIntegrationTests.swift b/Tests/SentryTests/Integrations/SentryCrash/SentryCrashIntegrationTests.swift index f639cfbd52e..79830269a9e 100644 --- a/Tests/SentryTests/Integrations/SentryCrash/SentryCrashIntegrationTests.swift +++ b/Tests/SentryTests/Integrations/SentryCrash/SentryCrashIntegrationTests.swift @@ -319,6 +319,7 @@ class SentryCrashIntegrationTests: NotificationCenterTestCase { let appState = SentryAppState(releaseName: TestData.appState.releaseName, osVersion: UIDevice.current.systemVersion, vendorId: UIDevice.current.identifierForVendor?.uuidString ?? "", isDebugging: false, systemBootTimestamp: fixture.currentDateProvider.date()) appState.isActive = true fixture.fileManager.store(appState) + fixture.fileManager.moveAppStateToPreviousAppState() } #endif diff --git a/Tests/SentryTests/TestClient.swift b/Tests/SentryTests/TestClient.swift index e76c3f73ad5..70ff760a87e 100644 --- a/Tests/SentryTests/TestClient.swift +++ b/Tests/SentryTests/TestClient.swift @@ -161,4 +161,10 @@ class TestFileManager: SentryFileManager { readAppStateInvocations.record(Void()) return nil } + + var readPreviousAppStateInvocations = Invocations() + override func readPreviousAppState() -> SentryAppState? { + readPreviousAppStateInvocations.record(Void()) + return nil + } } From 6dc0bd10b844be6853040af9f54716a3920987ce Mon Sep 17 00:00:00 2001 From: Philipp Hofmann Date: Wed, 5 Oct 2022 10:38:52 +0200 Subject: [PATCH 15/16] fix: Add app start to first finished transaction (#2252) The SDK added the app start measurement and spans to the first finished auto-generated UIViewController transaction. The first finished UIViewController transaction is not necessarily the transaction of the first loaded screen. As auto-generated transactions for UIViewControllers wait for all children to finish, it may kick off, for example, a web request that lasts for a couple of seconds in the background. In the meantime, the user navigates to another screen, which finishes loading before the web request. The SDK added the app start data to the wrong transaction in such an edge case. This is fixed now by adding the app start data to the first started transaction. Fixes GH-2248 Co-authored-by: Bruno Garcia --- CHANGELOG.md | 1 + .../xcshareddata/xcschemes/Sentry.xcscheme | 12 +++++ Sources/Sentry/SentryTracer.m | 12 ++--- ...SentryFileIOTrackingIntegrationTests.swift | 2 +- .../Performance/SentryTracerTests.swift | 51 ++++++++++++++++--- .../SentryStacktraceBuilderTests.swift | 2 +- 6 files changed, 63 insertions(+), 17 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 393f25a990b..cd098f4a48e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,7 @@ ### Fixes +- Add app start measurement to first finished transaction (#2252) - Return SentryNoOpSpan when starting a child on a finished transaction (#2239) - Fix profiling timestamps for slow/frozen frames (#2226) diff --git a/Sentry.xcodeproj/xcshareddata/xcschemes/Sentry.xcscheme b/Sentry.xcodeproj/xcshareddata/xcschemes/Sentry.xcscheme index 77bb934edc7..b1bbd8edbd7 100644 --- a/Sentry.xcodeproj/xcshareddata/xcschemes/Sentry.xcscheme +++ b/Sentry.xcodeproj/xcshareddata/xcschemes/Sentry.xcscheme @@ -55,12 +55,24 @@ ReferencedContainer = "container:Sentry.xcodeproj"> + + + + + + + + diff --git a/Sources/Sentry/SentryTracer.m b/Sources/Sentry/SentryTracer.m index 29baa07c68f..167363dc263 100644 --- a/Sources/Sentry/SentryTracer.m +++ b/Sources/Sentry/SentryTracer.m @@ -58,6 +58,7 @@ @implementation SentryTracer { BOOL _waitForChildren; SentryTraceContext *_traceContext; SentryProfilesSamplerDecision *_profilesSamplerDecision; + SentryAppStartMeasurement *appStartMeasurement; NSMutableDictionary *_tags; NSMutableDictionary *_data; dispatch_block_t _idleTimeoutBlock; @@ -162,6 +163,7 @@ - (instancetype)initWithTransactionContext:(SentryTransactionContext *)transacti self.finishStatus = kSentrySpanStatusUndefined; self.idleTimeout = idleTimeout; self.dispatchQueueWrapper = dispatchQueueWrapper; + appStartMeasurement = [self getAppStartMeasurement]; if ([self hasIdleTimeout]) { [self dispatchIdleTimeout]; @@ -557,9 +559,7 @@ - (void)trimEndTimestamp - (SentryTransaction *)toTransaction { - SentryAppStartMeasurement *appStartMeasurement = [self getAppStartMeasurement]; - - NSArray> *appStartSpans = [self buildAppStartSpans:appStartMeasurement]; + NSArray> *appStartSpans = [self buildAppStartSpans]; NSArray> *spans; @synchronized(_children) { @@ -573,7 +573,7 @@ - (SentryTransaction *)toTransaction SentryTransaction *transaction = [[SentryTransaction alloc] initWithTrace:self children:spans]; transaction.transaction = self.transactionContext.name; - [self addMeasurements:transaction appStartMeasurement:appStartMeasurement]; + [self addMeasurements:transaction]; return transaction; } @@ -626,8 +626,7 @@ - (nullable SentryAppStartMeasurement *)getAppStartMeasurement return measurement; } -- (NSArray *)buildAppStartSpans: - (nullable SentryAppStartMeasurement *)appStartMeasurement +- (NSArray *)buildAppStartSpans { if (appStartMeasurement == nil) { return @[]; @@ -687,7 +686,6 @@ - (nullable SentryAppStartMeasurement *)getAppStartMeasurement } - (void)addMeasurements:(SentryTransaction *)transaction - appStartMeasurement:(nullable SentryAppStartMeasurement *)appStartMeasurement { NSString *valueKey = @"value"; diff --git a/Tests/SentryTests/Integrations/Performance/IO/SentryFileIOTrackingIntegrationTests.swift b/Tests/SentryTests/Integrations/Performance/IO/SentryFileIOTrackingIntegrationTests.swift index 6bdeb55a0e7..f19ca2e3a7f 100644 --- a/Tests/SentryTests/Integrations/Performance/IO/SentryFileIOTrackingIntegrationTests.swift +++ b/Tests/SentryTests/Integrations/Performance/IO/SentryFileIOTrackingIntegrationTests.swift @@ -191,7 +191,7 @@ class SentryFileIOTrackingIntegrationTests: XCTestCase { ?? bundle.path(forResource: "fatal-error-binary-images-message2", ofType: "json") } - func test_DataConsistency_readUrl() { + func test_DataConsistency_readUrl_disabled() { SentrySDK.start(options: fixture.getOptions()) let randomValue = UUID().uuidString diff --git a/Tests/SentryTests/Performance/SentryTracerTests.swift b/Tests/SentryTests/Performance/SentryTracerTests.swift index 0bc3295d991..c42763268ff 100644 --- a/Tests/SentryTests/Performance/SentryTracerTests.swift +++ b/Tests/SentryTests/Performance/SentryTracerTests.swift @@ -432,19 +432,41 @@ class SentryTracerTests: XCTestCase { let appStartMeasurement = fixture.getAppStartMeasurement(type: .warm) SentrySDK.setAppStartMeasurement(appStartMeasurement) + advanceTime(bySeconds: -(fixture.appStartDuration + 4)) + let sut = fixture.getSut() - sut.startTimestamp = fixture.appStartEnd.addingTimeInterval(-5) + advanceTime(bySeconds: 1) sut.finish() fixture.hub.group.wait() XCTAssertEqual(1, fixture.hub.capturedEventsWithScopes.count) - let serializedTransaction = fixture.hub.capturedEventsWithScopes.first!.event.serialize() - let measurements = serializedTransaction["measurements"] as? [String: [String: Int]] - XCTAssertEqual(["app_start_warm": ["value": 500]], measurements) + assertAppStartMeasurementOn(transaction: fixture.hub.capturedEventsWithScopes.first!.event as! Transaction, appStartMeasurement: appStartMeasurement) + } + + func testAddColdStartMeasurement_PutOnFirstStartedTransaction() { + let appStartMeasurement = fixture.getAppStartMeasurement(type: .warm) + SentrySDK.setAppStartMeasurement(appStartMeasurement) - let transaction = fixture.hub.capturedEventsWithScopes.first!.event as! Transaction - assertAppStartsSpanAdded(transaction: transaction, startType: "Warm Start", operation: fixture.appStartWarmOperation, appStartMeasurement: appStartMeasurement) + advanceTime(bySeconds: 0.5) + + let firstTransaction = fixture.getSut() + advanceTime(bySeconds: 0.5) + + let secondTransaction = fixture.getSut() + advanceTime(bySeconds: 0.5) + secondTransaction.finish() + + fixture.hub.group.wait() + XCTAssertEqual(1, fixture.hub.capturedEventsWithScopes.count) + let serializedSecondTransaction = fixture.hub.capturedEventsWithScopes.first!.event.serialize() + XCTAssertNil(serializedSecondTransaction["measurements"]) + + firstTransaction.finish() + fixture.hub.group.wait() + + XCTAssertEqual(2, fixture.hub.capturedEventsWithScopes.count) + assertAppStartMeasurementOn(transaction: fixture.hub.capturedEventsWithScopes[1].event as! Transaction, appStartMeasurement: appStartMeasurement) } func testAddUnknownAppStartMeasurement_NotPutOnNextTransaction() { @@ -488,8 +510,10 @@ class SentryTracerTests: XCTestCase { let appStartMeasurement = fixture.getAppStartMeasurement(type: .warm) SentrySDK.setAppStartMeasurement(appStartMeasurement) + advanceTime(bySeconds: fixture.appStartDuration + 5.01) + let sut = fixture.getSut() - sut.startTimestamp = fixture.appStartEnd.addingTimeInterval(5.1) + advanceTime(bySeconds: 1.0) sut.finish() fixture.hub.group.wait() @@ -500,8 +524,10 @@ class SentryTracerTests: XCTestCase { let appStartMeasurement = fixture.getAppStartMeasurement(type: .warm) SentrySDK.setAppStartMeasurement(appStartMeasurement) + advanceTime(bySeconds: -(fixture.appStartDuration + 4.01)) + let sut = fixture.getSut() - sut.startTimestamp = fixture.appStartEnd.addingTimeInterval(-5.1) + advanceTime(bySeconds: 1.0) sut.finish() fixture.hub.group.wait() @@ -821,6 +847,15 @@ class SentryTracerTests: XCTestCase { assertSpan("Initial Frame Render", appStartMeasurement.didFinishLaunchingTimestamp, fixture.appStartEnd) } + private func assertAppStartMeasurementOn(transaction: Transaction, appStartMeasurement: SentryAppStartMeasurement) { + let serializedTransaction = transaction.serialize() + let measurements = serializedTransaction["measurements"] as? [String: [String: Int]] + + XCTAssertEqual(["app_start_warm": ["value": 500]], measurements) + + assertAppStartsSpanAdded(transaction: transaction, startType: "Warm Start", operation: fixture.appStartWarmOperation, appStartMeasurement: appStartMeasurement) + } + private func assertAppStartMeasurementNotPutOnTransaction() { XCTAssertEqual(1, fixture.hub.capturedEventsWithScopes.count) let serializedTransaction = fixture.hub.capturedEventsWithScopes.first!.event.serialize() diff --git a/Tests/SentryTests/SentryCrash/SentryStacktraceBuilderTests.swift b/Tests/SentryTests/SentryCrash/SentryStacktraceBuilderTests.swift index 3c2ac60b926..c65beeb9c79 100644 --- a/Tests/SentryTests/SentryCrash/SentryStacktraceBuilderTests.swift +++ b/Tests/SentryTests/SentryCrash/SentryStacktraceBuilderTests.swift @@ -67,7 +67,7 @@ class SentryStacktraceBuilderTests: XCTestCase { XCTAssertTrue(filteredFrames.count == 1, "The frames must be ordered from caller to callee, or oldest to youngest.") } - func testAsyncStacktraces() throws { + func testAsyncStacktraces_disabled() throws { SentrySDK.start { options in options.dsn = TestConstants.dsnAsString(username: "SentryStacktraceBuilderTests") options.stitchAsyncCode = true From 3441e8f9be290edcc7be57c93a1c128c1a787c2a Mon Sep 17 00:00:00 2001 From: getsentry-bot Date: Wed, 5 Oct 2022 08:51:04 +0000 Subject: [PATCH 16/16] release: 7.27.1 --- CHANGELOG.md | 2 +- Samples/iOS-Swift/iOS-Swift.xcodeproj/project.pbxproj | 8 ++++---- Sentry.podspec | 2 +- Sources/Configuration/Sentry.xcconfig | 2 +- Sources/Sentry/SentryMeta.m | 2 +- 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index cd098f4a48e..e9e2ec4d81c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,6 @@ # Changelog -## Unreleased +## 7.27.1 ### Fixes diff --git a/Samples/iOS-Swift/iOS-Swift.xcodeproj/project.pbxproj b/Samples/iOS-Swift/iOS-Swift.xcodeproj/project.pbxproj index 903f34dc3f1..c1b595b7b5d 100644 --- a/Samples/iOS-Swift/iOS-Swift.xcodeproj/project.pbxproj +++ b/Samples/iOS-Swift/iOS-Swift.xcodeproj/project.pbxproj @@ -1082,7 +1082,7 @@ "$(inherited)", "@executable_path/Frameworks", ); - MARKETING_VERSION = 7.27.0; + MARKETING_VERSION = 7.27.1; PRODUCT_BUNDLE_IDENTIFIER = "io.sentry.sample.iOS-Swift"; PRODUCT_NAME = "$(TARGET_NAME)"; PROVISIONING_PROFILE_SPECIFIER = "match Development io.sentry.sample.iOS-Swift"; @@ -1111,7 +1111,7 @@ "$(inherited)", "@executable_path/Frameworks", ); - MARKETING_VERSION = 7.27.0; + MARKETING_VERSION = 7.27.1; PRODUCT_BUNDLE_IDENTIFIER = "io.sentry.sample.iOS-Swift"; PRODUCT_NAME = "$(TARGET_NAME)"; PROVISIONING_PROFILE_SPECIFIER = "match AppStore io.sentry.sample.iOS-Swift"; @@ -1310,7 +1310,7 @@ "$(inherited)", "@executable_path/Frameworks", ); - MARKETING_VERSION = 7.27.0; + MARKETING_VERSION = 7.27.1; PRODUCT_BUNDLE_IDENTIFIER = "io.sentry.sample.iOS-Swift.Clip"; PRODUCT_NAME = "$(TARGET_NAME)"; PROVISIONING_PROFILE_SPECIFIER = "match Development io.sentry.sample.iOS-Swift.Clip"; @@ -1345,7 +1345,7 @@ "$(inherited)", "@executable_path/Frameworks", ); - MARKETING_VERSION = 7.27.0; + MARKETING_VERSION = 7.27.1; PRODUCT_BUNDLE_IDENTIFIER = "io.sentry.sample.iOS-Swift.Clip"; PRODUCT_NAME = "$(TARGET_NAME)"; PROVISIONING_PROFILE_SPECIFIER = "match AppStore io.sentry.sample.iOS-Swift.Clip"; diff --git a/Sentry.podspec b/Sentry.podspec index 19bf34c121e..deba1824aec 100644 --- a/Sentry.podspec +++ b/Sentry.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = "Sentry" - s.version = "7.27.0" + s.version = "7.27.1" s.summary = "Sentry client for cocoa" s.homepage = "https://github.com/getsentry/sentry-cocoa" s.license = "mit" diff --git a/Sources/Configuration/Sentry.xcconfig b/Sources/Configuration/Sentry.xcconfig index 4fb3c883ae7..c70747b54c4 100644 --- a/Sources/Configuration/Sentry.xcconfig +++ b/Sources/Configuration/Sentry.xcconfig @@ -29,7 +29,7 @@ MACH_O_TYPE = mh_dylib FRAMEWORK_VERSION = A PRODUCT_NAME = Sentry -CURRENT_PROJECT_VERSION = 7.27.0 +CURRENT_PROJECT_VERSION = 7.27.1 INFOPLIST_FILE = Sources/Sentry/Info.plist PRODUCT_BUNDLE_IDENTIFIER = io.sentry.Sentry ALWAYS_SEARCH_USER_PATHS = NO diff --git a/Sources/Sentry/SentryMeta.m b/Sources/Sentry/SentryMeta.m index 6a7380bbdc2..a9aedc4605e 100644 --- a/Sources/Sentry/SentryMeta.m +++ b/Sources/Sentry/SentryMeta.m @@ -5,7 +5,7 @@ @implementation SentryMeta // Don't remove the static keyword. If you do the compiler adds the constant name to the global // symbol table and it might clash with other constants. When keeping the static keyword the // compiler replaces all occurrences with the value. -static NSString *versionString = @"7.27.0"; +static NSString *versionString = @"7.27.1"; static NSString *sdkName = @"sentry.cocoa"; + (NSString *)versionString