UIWindow called from background thread
sabvente opened this issue · comments
Platform
iOS
Environment
Develop
Installed
CocoaPods
Version
8.31.1
Xcode Version
15.3
Did it work on previous versions?
8.19.3
Steps to Reproduce
- Call SentrySDK.capture(error: error) from a background thread.
Might be related to #3280
Expected Result
SentrySDK doesn't crash the app. Be able to call SentrySDK.capture(error: error) from a background thread.
Actual Result
Error: [UIWindow screen] must be used from main thread only
Logs:
Main Thread Checker: UI API called on a background thread: -[UIWindow screen]
Backtrace:
4 Sentry 0x000000010658d9c8 -[SentryCrashWrapper enrichScope:] + 1120
5 Sentry 0x00000001065a2888 -[SentryHub initWithClient:andScope:] + 716
6 Sentry 0x00000001065ca418 +[SentrySDK currentHub] + 68
7 Sentry 0x00000001065cb514 +[SentrySDK captureError:] + 44
Crash in:
SentryCrashWrapper.m:188
UIScreen *appScreen = appWindows.firstObject.screen;
Are you willing to submit a PR?
No response
Hello @sabvente, thanks for reaching out.
Are you calling SentrySDK.capture(error: error)
before cellist SentrySDK.start
?
Hello @brustolin,
Yes, that might be the problem. In the dev environment, I do not call SentrySDK.start, and I expected Sentry to handle all function calls as no-op in that case.
Now I can see that there is an enabled
property in SentryOptions
that I can use. My test case works now.
I will close this issue.
Any update on the fix can be found in here.