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.
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: Always start SDK on the main thread #3291
fix: Always start SDK on the main thread #3291
Changes from 13 commits
b11c6c1
23da6cc
95ab17a
5a9e4ea
f0b432f
4fa8e1f
6ee2b67
490ed4f
3ffba00
af5a3e5
26f8b49
b87e505
673d34c
9304c1d
5791da4
ddc053b
17e6590
b96bc4b
3418390
73db556
581b8df
45b181b
cd29f40
fb5eebc
427f0a9
e682529
262c625
d41ebfc
60723f7
3194c1d
431978a
6692ff9
aedd343
cc4d0e3
f58236a
33e5dbe
9bb1c59
4815a2f
4ecd1bb
86d4247
ff64ac7
b1292b1
d174abf
0c88c23
e875917
0f5d42c
d2a9730
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I've seen another dispatch invocation (
[SentryThreadWrapper onMainThread:]
) in the other PR 🤔 I guess this one resolvingSentryDependencyContainer.sharedInstance
(which visits some sync lock again) should be dropped completely in favour of wrapping in theSentryThreadWrapper
type, just so that something so simple as sync/async dispatch to Main thread doesn't have to touch multiple instances around the Sentry scope & be performed with a very clear call path. 👌There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for following along here, the more eyes the better 👀 I guess you're talking about this: https://github.com/getsentry/sentry-cocoa/pull/3295/files#diff-1c7b8db05183d8ca8e29ad4450733675d013a6b4065104f150d37d04017a36beR20
That will always immediately return, as it will either directly execute the logic on the main thread if it's called from that context, or will dispatch asynchronously to the main queue otherwise, so we shouldn't see lock contention. The only issue is that if SDK consumers initialize from a non-main context, they can potentially lose information for events that happen very early in their launch sequence, but that should hopefully be a calculated tradeoff for whomever does that. We are going to recommend initializing on the main thread in our docs to avoid that kind of thing.
We are also working to resolve the lock contention we're seeing in
SentryDependencyContainer
in a third PR: #3294Does this all sound correct/acceptable to you?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking again, just a note for the future: we should have
-[SentryThreadWrapper onMainThread:]
use the dispatch queue wrapper, and then use it here as well since it's the same logic. Doesn't have to be in this PR though, it might involve other code/test changes.