ref: move startOption storage to SentrySDKInternal#8054
Open
philprime wants to merge 7 commits into
Open
Conversation
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.
5 tasks
auto-merge was automatically disabled
June 12, 2026 12:57
Pull request was converted to draft
📲 Install BuildsiOS
|
Contributor
Performance metrics 🚀
|
| 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 |
❌ 54 Tests Failed:
View the top 3 failed test(s) by shortest run time
To view more test analytics, go to the Test Analytics Dashboard |
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.
Member
Author
|
@sentry review |
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.
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ 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.
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:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Description
Moves
_startOptionstate and its lock fromSentrySDK.swiftintoSentrySDKInternal.m, makingSentrySDK.startOptionandsetStart(with:)thin passthroughs. All internal callers now useSentrySDKInternal.optionsdirectly.Motivation
Remove state from the public
SentrySDKSwift class — it should be a stateless facade. The existingSentrySDKInternal.optionsproperty already existed but was backwards (delegating toSentrySDK); this flips the ownership soSentrySDKInternalis the source of truth.Changes
SentrySDKInternal.m— owns_startOptionsstorage + lock;optionsgetter andsetStartOptions:use local synchronized storageSentrySDK+Private.h— declaressetStartOptions:(moved from test-only header)SentrySDK.swift— removes_startOptionandstartOptionLock;startOption/setStart(with:)delegate toSentrySDKInternalSentrySDK.startOption→SentrySDKInternal.optionsacross ObjC and Swift filesSentrySDKInternal+Tests.h— removed duplicatesetStartOptions:declarationRefs #8051
#skip-changelog