Open ncltg opened 1 month ago
Hello @ncltg, thanks for reaching out. Add breadcrumb is not meant to be used only in the main thread.
I believe this SentryLogRepository
is an auxiliar class in your project correct?
Could it be that this function its being called before starting SentrySDK? That's when we use enrichScope
.
Although this is something we should improve, calling SentrySDK
before starting it, creates a new SentryHub
in any thread and this causes the problem.
Hey @brustolin
I believe this SentryLogRepository is an auxiliar class in your project correct?
Yes 👍
Based on the information you provided it's very likely that some of our launch tasks produce calls to addBreadcrumb
before we start SentrySDK
ourselves.
Thanks a lot for the clarification 🙏
I also see main thread checker issues within enrichScrope:
8.26.0 but only after calling SentrySDK.close()
.
Hello @swhitty, thanks for reaching out.
By calling SentrySDK.close()
you're cleaning up Sentry hub and its scope, by calling any function of the SDK a new one will be created.
But we need to improve this to not trigger a thread checker.
We can change this to initialize a new SentryNoOpHub when there is none instead of creating a normal SentryHub. It's best to do this in the next major to avoid unwanted side effect.
Platform
iOS
Environment
Develop
Installed
Swift Package Manager
Version
8.26.0
Xcode Version
15.2
Did it work on previous versions?
not sure
Steps to Reproduce
Call
SentrySDK.addBreadcrumb()
from a background threadExpected Result
No main thread checker issue is found.
Actual Result
Result
Xcode shows a Main Thread checker warning. The SDK is calling UIKit methods that require Main Thread execution on a background thread.
Logs and screenshots
Question
I checked the iOS documentation and it does not mention that breadcrumb should be added from the main thread. Is it an issue from Sentry SDK that needs to be addressed or does it actually recommended to call that method from the main thread ?
Are you willing to submit a PR?
No response