Skip to content

ref: move startOption storage to SentrySDKInternal#8054

Open
philprime wants to merge 7 commits into
mainfrom
ref/move-startoption-to-sdkinternal
Open

ref: move startOption storage to SentrySDKInternal#8054
philprime wants to merge 7 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 Use this label to trigger all PR workflows 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 1225.40 ms 1247.93 ms 22.54 ms
Size 24.14 KiB 1.18 MiB 1.16 MiB

Baseline results on branch: main

Startup times

Revision Plain With Sentry Diff
71e6611 1213.27 ms 1242.25 ms 28.98 ms
4014441 1232.16 ms 1266.41 ms 34.25 ms
1c5ecda 1219.35 ms 1253.76 ms 34.41 ms
655e96d 1217.63 ms 1258.34 ms 40.72 ms
a48979e 1244.58 ms 1269.00 ms 24.42 ms
ba5a1dd 1234.15 ms 1257.50 ms 23.35 ms
8bb6aeb 1215.82 ms 1244.84 ms 29.02 ms
da35aa2 1224.21 ms 1249.00 ms 24.79 ms
c3064bc 1227.20 ms 1248.25 ms 21.05 ms
943b250 1214.69 ms 1257.32 ms 42.63 ms

App size

Revision Plain With Sentry Diff
71e6611 24.14 KiB 1.15 MiB 1.12 MiB
4014441 24.14 KiB 1.16 MiB 1.14 MiB
1c5ecda 24.14 KiB 1.15 MiB 1.12 MiB
655e96d 24.14 KiB 1.18 MiB 1.16 MiB
a48979e 24.14 KiB 1.17 MiB 1.15 MiB
ba5a1dd 24.14 KiB 1.18 MiB 1.16 MiB
8bb6aeb 24.14 KiB 1.17 MiB 1.15 MiB
da35aa2 24.14 KiB 1.15 MiB 1.13 MiB
c3064bc 24.14 KiB 1.18 MiB 1.15 MiB
943b250 24.14 KiB 1.17 MiB 1.15 MiB

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

Startup times

Revision Plain With Sentry Diff
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
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

@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 ee10dc7. Configure here.

Comment thread Sources/Swift/SentryDependencyContainer.swift
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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready-to-merge Use this label to trigger all PR workflows

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant