Skip to content

ref: move startOption storage to SentrySDKInternal - #8054

Merged
philprime merged 10 commits into
mainfrom
ref/move-startoption-to-sdkinternal
Jun 24, 2026
Merged

ref: move startOption storage to SentrySDKInternal#8054
philprime merged 10 commits into
mainfrom
ref/move-startoption-to-sdkinternal

Conversation

@philprime

@philprime philprime commented Jun 12, 2026

Copy link
Copy Markdown
Member

Description

Moves _startOption state and its lock from SentrySDK.swift into SentrySDKInternal.m, making SentrySDK.startOption and setStart(with:) thin passthroughs. All internal callers now use SentrySDKInternal.options directly.

Motivation

Remove state from the public SentrySDK Swift class — it should be a stateless facade. The existing SentrySDKInternal.options property already existed but was backwards (delegating to SentrySDK); this flips the ownership so SentrySDKInternal is the source of truth.

Changes

  • SentrySDKInternal.m — owns _startOptions storage + lock; options getter and setStartOptions: use local synchronized storage
  • SentrySDK+Private.h — declares setStartOptions: (moved from test-only header)
  • SentrySDK.swift — removes _startOption and startOptionLock; startOption / setStart(with:) delegate to SentrySDKInternal
  • 13 call sites — replaced SentrySDK.startOptionSentrySDKInternal.options across ObjC and Swift files
  • SentrySDKInternal+Tests.h — removed duplicate setStartOptions: declaration

Refs #8051

#skip-changelog

Move the `_startOption` state and its lock from `SentrySDK.swift`
into `SentrySDKInternal.m`, making `SentrySDK.startOption` and
`setStart(with:)` thin passthroughs. All internal callers now
use `SentrySDKInternal.options` directly.
@philprime philprime self-assigned this Jun 12, 2026
@philprime philprime added the ready-to-merge (deprecated) Use run-full-ci instead. label Jun 12, 2026
@philprime
philprime enabled auto-merge (squash) June 12, 2026 12:54
@philprime
philprime marked this pull request as draft June 12, 2026 12:57
auto-merge was automatically disabled June 12, 2026 12:57

Pull request was converted to draft

@sentry

sentry Bot commented Jun 12, 2026

Copy link
Copy Markdown

📲 Install Builds

iOS

🔗 App Name App ID Version Configuration
SDK-Size io.sentry.sample.SDK-Size 9.18.0 (1) Release

⚙️ sentry-cocoa Build Distribution Settings

@github-actions

github-actions Bot commented Jun 12, 2026

Copy link
Copy Markdown
Contributor

Performance metrics 🚀

  Plain With Sentry Diff
Startup time 1238.98 ms 1272.34 ms 33.36 ms
Size 24.14 KiB 1.19 MiB 1.17 MiB

Baseline results on branch: main

Startup times

Revision Plain With Sentry Diff
d1ddc41 1236.42 ms 1267.21 ms 30.79 ms
78aad96 1232.02 ms 1262.42 ms 30.40 ms
8bb6aeb 1232.15 ms 1260.78 ms 28.63 ms
bc68ff6 1227.02 ms 1254.89 ms 27.87 ms
4082d65 1225.47 ms 1252.28 ms 26.81 ms
e0946cf 1233.33 ms 1258.57 ms 25.24 ms
1155f0c 1222.41 ms 1251.18 ms 28.76 ms
8180609 1214.67 ms 1243.36 ms 28.69 ms
151b3ee 1238.69 ms 1270.73 ms 32.05 ms
ae8cece 1216.83 ms 1251.37 ms 34.55 ms

App size

Revision Plain With Sentry Diff
d1ddc41 24.14 KiB 1.17 MiB 1.15 MiB
78aad96 24.14 KiB 1.18 MiB 1.16 MiB
8bb6aeb 24.14 KiB 1.17 MiB 1.15 MiB
bc68ff6 24.14 KiB 1.16 MiB 1.14 MiB
4082d65 24.14 KiB 1.19 MiB 1.17 MiB
e0946cf 24.14 KiB 1.16 MiB 1.13 MiB
1155f0c 24.14 KiB 1.16 MiB 1.13 MiB
8180609 24.14 KiB 1.16 MiB 1.13 MiB
151b3ee 24.14 KiB 1.15 MiB 1.13 MiB
ae8cece 24.14 KiB 1.15 MiB 1.13 MiB

Previous results on branch: ref/move-startoption-to-sdkinternal

Startup times

Revision Plain With Sentry Diff
8c1475b 1225.40 ms 1247.93 ms 22.54 ms
98673e9 1235.83 ms 1269.64 ms 33.81 ms
898e4b2 1221.73 ms 1261.21 ms 39.48 ms

App size

Revision Plain With Sentry Diff
8c1475b 24.14 KiB 1.18 MiB 1.16 MiB
98673e9 24.14 KiB 1.18 MiB 1.16 MiB
898e4b2 24.14 KiB 1.18 MiB 1.16 MiB

@codecov

codecov Bot commented Jun 12, 2026

Copy link
Copy Markdown

❌ 54 Tests Failed:

Tests completed Failed Passed Skipped
60 54 6 0
View the top 3 failed test(s) by shortest run time
iOS_Swift6_UITests.UITests::testLaunchAndCaptureError
Stack Traces | 0s run time
.../UITests/Sources/UITests.swift:12 - Failed to application io.sentry.sample.iOS-Swift6 is not running
iOS_SwiftUI_UITests.FeedbackUITests::testWidgetDisplayInSwiftUIApp
Stack Traces | 0s run time
.../UITests/Sources/FeedbackUITests.swift:14 - Failed to application io.sentry.iOS-SwiftUI is not running
iOS_SwiftUI_UITests.LaunchUITests::testCaptureErrorReturnsValidId
Stack Traces | 0s run time
.../UITests/Sources/LaunchUITests.swift:56 - Failed to application io.sentry.iOS-SwiftUI is not running
iOS_SwiftUI_UITests.LaunchUITests::testNoNewTransactionForSecondCallToBody
Stack Traces | 0s run time
.../UITests/Sources/LaunchUITests.swift:37 - Failed to application io.sentry.iOS-SwiftUI is not running
iOS_SwiftUI_UITests.LaunchUITests::testTTID_TTFD
Stack Traces | 0s run time
.../UITests/Sources/LaunchUITests.swift:91 - Failed to get background assertion for target app with pid 6176: No failure details provided
iOS_SwiftUI_UITests.LaunchUITests::testTransactionSpan
Stack Traces | 0s run time
.../UITests/Sources/LaunchUITests.swift:20 - failed - Span operation label not found
iOS_SwiftUI_UITests.UIApplicationSwizzleTests::testSendEvent
Stack Traces | 0s run time
.../UITests/Sources/UIApplicationSwizzleTests.swift:14 - Failed to application io.sentry.iOS-SwiftUI is not running
iOS_Swift_UITests.LaunchProfilingVCTransactionUITests::testVCTransactionsCapturedDuringLaunchProfiling
Stack Traces | 0s run time
.../UITests/Sources/UITestHelpers.swift:5 - XCTAssertTrue failed - Home Screen doesn't exist.
iOS_Swift_UITests.LaunchUITests::testBreadcrumbData
Stack Traces | 0s run time
<unknown>:0 - io.sentry.sample.iOS-Swift crashed in <external symbol>
iOS_Swift_UITests.LaunchUITests::testCaptureError
Stack Traces | 0s run time
.../UITests/Sources/UITestHelpers.swift:5 - XCTAssertTrue failed - Home Screen doesn't exist.
iOS_Swift_UITests.LaunchUITests::testCaptureException
Stack Traces | 0s run time
<unknown>:0 - io.sentry.sample.iOS-Swift crashed in <external symbol>
iOS_Swift_UITests.LaunchUITests::testCheckSlowAndFrozenFrames
Stack Traces | 0s run time
.../UITests/Sources/UITestHelpers.swift:5 - XCTAssertTrue failed - Home Screen doesn't exist.
iOS_Swift_UITests.LaunchUITests::testCheckTotalFrames
Stack Traces | 0s run time
.../UITests/Sources/UITestHelpers.swift:5 - XCTAssertTrue failed - Home Screen doesn't exist.
iOS_Swift_UITests.LaunchUITests::testLoremIpsum
Stack Traces | 0s run time
.../UITests/Sources/UITestHelpers.swift:5 - XCTAssertTrue failed - Home Screen doesn't exist.
iOS_Swift_UITests.LaunchUITests::testNavigationTransaction
Stack Traces | 0s run time
<unknown>:0 - io.sentry.sample.iOS-Swift crashed in <external symbol>
iOS_Swift_UITests.LaunchUITests::testShowNib
Stack Traces | 0s run time
.../UITests/Sources/UITestHelpers.swift:5 - XCTAssertTrue failed - Home Screen doesn't exist.
iOS_Swift_UITests.LaunchUITests::testShowTableView
Stack Traces | 0s run time
.../UITests/Sources/UITestHelpers.swift:5 - XCTAssertTrue failed - Home Screen doesn't exist.
iOS_Swift_UITests.LaunchUITests::testSplitView
Stack Traces | 0s run time
<unknown>:0 - io.sentry.sample.iOS-Swift crashed in <external symbol>
iOS_Swift_UITests.LaunchUITests::testUiClickTransaction
Stack Traces | 0s run time
.../UITests/Sources/UITestHelpers.swift:5 - XCTAssertTrue failed - Home Screen doesn't exist.
iOS_Swift_UITests.LaunchUITests::testUseAfterFreeAfterUIImageNamedEmptyString
Stack Traces | 0s run time
<unknown>:0 - io.sentry.sample.iOS-Swift crashed in <external symbol>
iOS_Swift_UITests.ProfilingUITests::testAppLaunchesWithContinuousProfilerV2ManualLifeCycle
Stack Traces | 0s run time
<unknown>:0 - io.sentry.sample.iOS-Swift crashed in <external symbol>
iOS_Swift_UITests.ProfilingUITests::testAppLaunchesWithContinuousProfilerV2TraceLifecycle
Stack Traces | 0s run time
<unknown>:0 - io.sentry.sample.iOS-Swift crashed in <external symbol>
iOS_Swift_UITests.SessionReplayUITests::testCameraUI_shouldNotCrashOnIOS26
Stack Traces | 0s run time
.../UITests/Sources/UITestHelpers.swift:5 - XCTAssertTrue failed - Home Screen doesn't exist.
iOS_Swift_UITests.TopViewControllerTests::testChildControllerLoadCount
Stack Traces | 0s run time
.../UITests/Sources/UITestHelpers.swift:5 - XCTAssertTrue failed - Home Screen doesn't exist.
iOS_Swift_UITests.TopViewControllerTests::testNavigationViewController
Stack Traces | 0s run time
.../UITests/Sources/UITestHelpers.swift:5 - XCTAssertTrue failed - Home Screen doesn't exist.
iOS_Swift_UITests.TopViewControllerTests::testPagesViewController
Stack Traces | 0s run time
.../UITests/Sources/UITestHelpers.swift:5 - XCTAssertTrue failed - Home Screen doesn't exist.
iOS_Swift_UITests.TopViewControllerTests::testSplitViewController
Stack Traces | 0s run time
.../UITests/Sources/UITestHelpers.swift:5 - XCTAssertTrue failed - Home Screen doesn't exist.
iOS_Swift_UITests.TopViewControllerTests::testTabBarViewController
Stack Traces | 0s run time
.../UITests/Sources/UITestHelpers.swift:5 - XCTAssertTrue failed - Home Screen doesn't exist.
iOS_Swift_UITests.UIEventBreadcrumbTests::testExtractInfoFromView
Stack Traces | 0s run time
.../UITests/Sources/UITestHelpers.swift:5 - XCTAssertTrue failed - Home Screen doesn't exist.
iOS_Swift_UITests.UIEventBreadcrumbTests::testNoBreadcrumbForTextFieldEditingChanged
Stack Traces | 0s run time
.../UITests/Sources/UITestHelpers.swift:5 - XCTAssertTrue failed - Home Screen doesn't exist.
iOS_Swift_UITests.UserFeedbackUITests::testCancelFromFormByButton
Stack Traces | 0s run time
.../UITests/Sources/UITestHelpers.swift:5 - XCTAssertTrue failed - Home Screen doesn't exist.
iOS_Swift_UITests.UserFeedbackUITests::testCancelFromFormBySwipeDown
Stack Traces | 0s run time
.../UITests/Sources/UITestHelpers.swift:5 - XCTAssertTrue failed - Home Screen doesn't exist.
iOS_Swift_UITests.UserFeedbackUITests::testFormShowsAndDismissesProperlyWithCustomButton
Stack Traces | 0s run time
.../UITests/Sources/UITestHelpers.swift:5 - XCTAssertTrue failed - Home Screen doesn't exist.
iOS_Swift_UITests.UserFeedbackUITests::testManuallyDisplayingWidget
Stack Traces | 0s run time
.../UITests/Sources/UITestHelpers.swift:5 - XCTAssertTrue failed - Home Screen doesn't exist.
iOS_Swift_UITests.UserFeedbackUITests::testNoAutomaticallyInjectedWidgetWithCustomButton
Stack Traces | 0s run time
.../UITests/Sources/UITestHelpers.swift:5 - XCTAssertTrue failed - Home Screen doesn't exist.
iOS_Swift_UITests.UserFeedbackUITests::testNoPrefilledUserInformation
Stack Traces | 0s run time
.../UITests/Sources/UITestHelpers.swift:5 - XCTAssertTrue failed - Home Screen doesn't exist.
iOS_Swift_UITests.UserFeedbackUITests::testPrefilledUserInformation
Stack Traces | 0s run time
.../UITests/Sources/UITestHelpers.swift:5 - XCTAssertTrue failed - Home Screen doesn't exist.
iOS_Swift_UITests.UserFeedbackUITests::testSubmissionErrorThenSuccessAfterFixingIssues
Stack Traces | 0s run time
.../UITests/Sources/UITestHelpers.swift:5 - XCTAssertTrue failed - Home Screen doesn't exist.
iOS_Swift_UITests.UserFeedbackUITests::testSubmitOnlyWithOptionalFieldsFilled
Stack Traces | 0s run time
.../UITests/Sources/UITestHelpers.swift:5 - XCTAssertTrue failed - Home Screen doesn't exist.
iOS_Swift_UITests.UserFeedbackUITests::testSubmitWithNoFieldsFilledAllRequired
Stack Traces | 0s run time
.../UITests/Sources/UITestHelpers.swift:5 - XCTAssertTrue failed - Home Screen doesn't exist.
iOS_Swift_UITests.UserFeedbackUITests::testSubmitWithNoFieldsFilledDefault
Stack Traces | 0s run time
.../UITests/Sources/UITestHelpers.swift:5 - XCTAssertTrue failed - Home Screen doesn't exist.
iOS_Swift_UITests.UserFeedbackUITests::testSubmitWithNoFieldsFilledEmailAndMessageRequired
Stack Traces | 0s run time
.../UITests/Sources/UITestHelpers.swift:5 - XCTAssertTrue failed - Home Screen doesn't exist.
iOS_Swift_UITests.UserFeedbackUITests::testSubmitWithOnlyRequiredFieldsFilled
Stack Traces | 0s run time
.../UITests/Sources/UITestHelpers.swift:5 - XCTAssertTrue failed - Home Screen doesn't exist.
iOS_Swift_UITests.UserFeedbackUITests::testUIElementsWithCustomizations
Stack Traces | 0s run time
.../UITests/Sources/UITestHelpers.swift:5 - XCTAssertTrue failed - Home Screen doesn't exist.
iOS_Swift_UITests.UserFeedbackUITests::testUIElementsWithDefaults
Stack Traces | 0s run time
.../UITests/Sources/UITestHelpers.swift:5 - XCTAssertTrue failed - Home Screen doesn't exist.
iOS_Swift_UITests.ViewLifecycleUITests::testViewLifecycle_callingDismissWithLoadView_shouldNotCrashSDK
Stack Traces | 0s run time
.../UITests/Sources/UITestHelpers.swift:5 - XCTAssertTrue failed - Home Screen doesn't exist.
iOS_Swift_UITests.ViewLifecycleUITests::testViewLifecycle_callingDismissWithViewDidAppear_shouldNotCrashSDK
Stack Traces | 0s run time
.../UITests/Sources/UITestHelpers.swift:5 - XCTAssertTrue failed - Home Screen doesn't exist.
iOS_Swift_UITests.ViewLifecycleUITests::testViewLifecycle_callingDismissWithViewDidDisappear_shouldNotCrashSDK
Stack Traces | 0s run time
.../UITests/Sources/UITestHelpers.swift:5 - XCTAssertTrue failed - Home Screen doesn't exist.
iOS_Swift_UITests.ViewLifecycleUITests::testViewLifecycle_callingDismissWithViewDidLayoutSubviews_shouldNotCrashSDK
Stack Traces | 0s run time
.../UITests/Sources/UITestHelpers.swift:5 - XCTAssertTrue failed - Home Screen doesn't exist.
iOS_Swift_UITests.ViewLifecycleUITests::testViewLifecycle_callingDismissWithViewDidLoad_shouldNotCrashSDK
Stack Traces | 0s run time
.../UITests/Sources/UITestHelpers.swift:5 - XCTAssertTrue failed - Home Screen doesn't exist.
iOS_Swift_UITests.ViewLifecycleUITests::testViewLifecycle_callingDismissWithViewWillAppear_shouldNotCrashSDK
Stack Traces | 0s run time
.../UITests/Sources/UITestHelpers.swift:5 - XCTAssertTrue failed - Home Screen doesn't exist.
iOS_Swift_UITests.ViewLifecycleUITests::testViewLifecycle_callingDismissWithViewWillDisappear_shouldNotCrashSDK
Stack Traces | 0s run time
.../UITests/Sources/UITestHelpers.swift:5 - XCTAssertTrue failed - Home Screen doesn't exist.
iOS_Swift_UITests.ViewLifecycleUITests::testViewLifecycle_callingDismissWithViewWillLayoutSubviews_shouldNotCrashSDK
Stack Traces | 0s run time
.../UITests/Sources/UITestHelpers.swift:5 - XCTAssertTrue failed - Home Screen doesn't exist.
tvOS_Swift_UITests.LaunchUITests::testLaunch
Stack Traces | 0s run time
.../UITests/Sources/LaunchUITests.swift:27 - XCTAssertTrue failed - Home Screen doesn't exist.

To view more test analytics, go to the Test Analytics Dashboard
📋 Got 3 mins? Take this short survey to help us improve Test Analytics.

Move startOption state from SentrySDKInternal (ObjC static
vars + lock) to SentryDependencyContainer (Swift instance
property). This avoids ObjC/Swift header visibility issues
in SPM and moves state out of SentrySDK toward making it a
stateless enum.
Move threadInspector and fileIOTracker from eager Dependencies
static vars to lazy properties on SentryDependencyContainer.

The eager initialization caused a deadlock: container init
triggered Dependencies.fileIOTracker → Dependencies.threadInspector
→ SentryThreadInspector.init() → SentryDependencyContainer
.sharedInstance() → re-entered dispatch_once for the static
instance.
@philprime

Copy link
Copy Markdown
Member Author

@sentry review

Comment thread Sources/Swift/SentryDependencyContainer.swift Outdated
The property was left unprotected after moving from SentrySDK
(where it had startOptionLock) to SentryDependencyContainer.
Background threads reading options (e.g. SentryNetworkTracker)
could race with the main thread writing during SDK start/close.
@philprime
philprime marked this pull request as ready for review June 17, 2026 13:49
Comment thread Sources/Swift/SentryDependencyContainer.swift
Comment thread Sources/Swift/SentryDependencyContainer.swift
@philprime
philprime enabled auto-merge (squash) June 19, 2026 12:27
Comment thread Sources/Swift/SentryCrash/SentryThreadInspector.swift Outdated
Comment thread Sources/Swift/SentryDependencyContainer.swift
@github-actions

Copy link
Copy Markdown
Contributor

🚨 Detected changes in high risk code 🚨

High-risk code can easily blow up and is hard to test. We had severe bugs in the past. Be extra careful when changing these files, and have an extra careful look at these:

  • Sources/Sentry/SentryNetworkTracker.m

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 654c633. Configure here.

Comment thread Sources/Swift/Helper/SentrySDK.swift
Comment thread Sources/Swift/SentryDependencyContainer.swift
@philprime
philprime merged commit 2db8d87 into main Jun 24, 2026
328 of 333 checks passed
@philprime
philprime deleted the ref/move-startoption-to-sdkinternal branch June 24, 2026 08:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready-to-merge (deprecated) Use run-full-ci instead.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants