Skip to content

Commit dbe67d1

Browse files
fix(profiling): Change path of non-sandboxed macOS app launch profile configuration (#5143)
Co-authored-by: Philip Niedertscheider <[email protected]>
1 parent dd30b39 commit dbe67d1

31 files changed

+1844
-142
lines changed

.github/workflows/build.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,8 @@ jobs:
5757
# other sample projects are built in ui-tests
5858
include:
5959
- scheme: macOS-Swift
60-
xcode: 15.4
61-
runs-on: macos-14
60+
xcode: 16.3
61+
runs-on: macos-15
6262
- scheme: iOS13-Swift
6363
xcode: 15.4
6464
runs-on: macos-14

CHANGELOG.md

+17-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,16 @@
11
# Changelog
22

3+
## Unreleased
4+
5+
> ![Important]
6+
> Version 8.21.0 introduced an issue for app launch profiling **only for macOS apps that run without a sandbox** (i.e. distributed outside the Mac App Store).
7+
> This issue could lead to starting the app launch profiler even when it's not configured via the options.
8+
> We recommend upgrading to at least this version.
9+
10+
### Fixes
11+
12+
- Non-sandboxed macOS app launch profile configuration are now respected (#5144)
13+
314
## 8.49.1
415

516
### Fixes
@@ -17,7 +28,7 @@
1728
- New continuous profiling configuration API (#4952 and #5063)
1829

1930
> [!Important]
20-
> With the addition of the new profiling configuation API, the previous profiling API are deprecated and will be removed in the next major version of the SDK:
31+
> With the addition of the new profiling configuration API, the previous profiling API are deprecated and will be removed in the next major version of the SDK:
2132
>
2233
> - `SentryOptions.enableProfiling`
2334
> - `SentryOptions.isProfilingEnabled`
@@ -897,6 +908,11 @@ The following two features, disabled by default, were mistakenly added to the re
897908

898909
## 8.21.0
899910

911+
> ![Important]
912+
> This version introduced an issue for app launch profiling **only for macOS apps that run without a sandbox** (i.e. distributed outside the Mac App Store).
913+
> This issue could lead to starting the app launch profiler even when it's not configured via the options.
914+
> We recommend upgrading to at least version 8.49.2.
915+
900916
### Features
901917

902918
- Add support for Sentry [Spotlight](https://spotlightjs.com/) (#3642), which is basically Sentry

Plans/iOS13-Swift_Base.xctestplan

+1-4
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,7 @@
1111
"defaultOptions" : {
1212
"codeCoverage" : false,
1313
"commandLineArgumentEntries" : [
14-
{
15-
"argument" : "--io.sentry.profiling.enable",
16-
"enabled" : false
17-
}
14+
1815
],
1916
"targetForVariableExpansion" : {
2017
"containerPath" : "container:iOS-Swift.xcodeproj",

Plans/macOS-Swift_Base.xctestplan

+8-5
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,7 @@
1111
"defaultOptions" : {
1212
"codeCoverage" : false,
1313
"commandLineArgumentEntries" : [
14-
{
15-
"argument" : "--io.sentry.profiling.enable",
16-
"enabled" : false
17-
}
14+
1815
],
1916
"targetForVariableExpansion" : {
2017
"containerPath" : "container:macOS-Swift.xcodeproj",
@@ -24,7 +21,13 @@
2421
"uiTestingScreenshotsLifetime" : "keepAlways"
2522
},
2623
"testTargets" : [
27-
24+
{
25+
"target" : {
26+
"containerPath" : "container:macOS-Swift.xcodeproj",
27+
"identifier" : "84B5A90E2DBD1AA4003327C9",
28+
"name" : "macOS-Swift-UITests"
29+
}
30+
}
2831
],
2932
"version" : 1
3033
}

Samples/iOS-Swift/iOS-Swift-UITests/UserFeedbackUITests.swift

+1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ class UserFeedbackUITests: BaseUITest {
88
let fm = FileManager.default
99

1010
/// The Application Support directory is different between this UITest runner app and the target app under test. We have to retrieve the target app's app support directory using UI elements and store it here for usage.
11+
/// - note: The SDK does not use application support for anything. We only use the app support directory for these tests to write marker files from the app indicating which feedback hooks have fired.
1112
var appSupportDirectory: String?
1213

1314
override func setUp() {

Samples/iOS-Swift/iOS-Swift.xcodeproj/xcshareddata/xcschemes/iOS13-Swift.xcscheme

-6
Original file line numberDiff line numberDiff line change
@@ -66,12 +66,6 @@
6666
ReferencedContainer = "container:iOS-Swift.xcodeproj">
6767
</BuildableReference>
6868
</BuildableProductRunnable>
69-
<CommandLineArguments>
70-
<CommandLineArgument
71-
argument = "--io.sentry.profiling.enable"
72-
isEnabled = "NO">
73-
</CommandLineArgument>
74-
</CommandLineArguments>
7569
</LaunchAction>
7670
<ProfileAction
7771
buildConfiguration = "Release"

Samples/iOS-Swift/iOS-Swift/Profiling/NSObject+SentryAppSetup.m

+11-6
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,18 @@ + (void)load
55
{
66
NSLog(@"[iOS-Swift] Starting app launch work");
77
if ([NSProcessInfo.processInfo.arguments containsObject:@"--io.sentry.slow-load-method"]) {
8-
NSMutableString *a = [NSMutableString string];
9-
// 1,000,000 iterations takes about 225 milliseconds in the iPhone 15 simulator on an
10-
// M2 macbook pro; we might have to adapt this for CI
11-
for (NSUInteger i = 0; i < 4000000; i++) {
12-
[a appendFormat:@"%d", arc4random() % 12345];
13-
}
8+
[self sentry_slowLoadWork];
149
}
1510
NSLog(@"[iOS-Swift] Finishing app launch work");
1611
}
12+
13+
+ (void)sentry_slowLoadWork
14+
{
15+
NSMutableString *a = [NSMutableString string];
16+
// 1,000,000 iterations takes about 225 milliseconds in the iPhone 15 simulator on an
17+
// M2 macbook pro; we might have to adapt this for CI
18+
for (NSUInteger i = 0; i < 4000000; i++) {
19+
[a appendFormat:@"%d", arc4random() % 12345];
20+
}
21+
}
1722
@end

Samples/macOS-Swift/macOS-Swift/AppDelegate.swift renamed to Samples/macOS-Swift/Shared/AppDelegate.swift

+12-5
Original file line numberDiff line numberDiff line change
@@ -5,23 +5,30 @@ import Sentry
55
class AppDelegate: NSObject, NSApplicationDelegate {
66

77
func applicationDidFinishLaunching(_ aNotification: Notification) {
8-
98
// Insert code here to initialize your application
109
SentrySDK.start { options in
1110
options.dsn = "https://[email protected]/5428557"
1211
options.debug = true
1312
options.tracesSampleRate = 1.0
1413

1514
let args = ProcessInfo.processInfo.arguments
16-
17-
if args.contains("--io.sentry.profiling.enable") {
18-
options.profilesSampleRate = 1
15+
16+
// Set the profilesSampleRate to `nil` to enable the configureProfiling block
17+
options.profilesSampleRate = nil
18+
options.configureProfiling = {
19+
$0.profileAppStarts = ProcessInfo.processInfo.arguments.contains("--io.sentry.enable-profile-app-starts")
20+
$0.sessionSampleRate = 1
21+
}
22+
23+
if args.contains("--disable-auto-performance-tracing") {
24+
options.enableAutoPerformanceTracing = false
1925
}
26+
2027
if #available(macOS 12.0, *), !args.contains("--disable-metrickit-integration") {
2128
options.enableMetricKit = true
2229
options.enableMetricKitRawPayload = true
2330
}
24-
31+
2532
options.initialScope = { scope in
2633
if let path = Bundle.main.path(forResource: "Tongariro", ofType: "jpg") {
2734
scope.addAttachment(Attachment(path: path, filename: "Tongariro.jpg", contentType: "image/jpeg"))

0 commit comments

Comments
 (0)