-
-
Notifications
You must be signed in to change notification settings - Fork 329
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: Don't start the SDK inside Xcode preview #4601
base: feat/swiftui-ttid
Are you sure you want to change the base?
Conversation
Performance metrics 🚀
|
Revision | Plain | With Sentry | Diff |
---|---|---|---|
8b6def0 | 1226.11 ms | 1247.20 ms | 21.10 ms |
51e85b4 | 1228.22 ms | 1249.19 ms | 20.96 ms |
9ef5a81 | 1234.29 ms | 1256.35 ms | 22.07 ms |
895b829 | 1232.55 ms | 1250.90 ms | 18.35 ms |
f6a9e2b | 1234.94 ms | 1245.60 ms | 10.66 ms |
8c646bc | 1221.49 ms | 1245.31 ms | 23.82 ms |
f583fd1 | 1243.27 ms | 1258.91 ms | 15.65 ms |
f38e16a | 1237.13 ms | 1262.76 ms | 25.62 ms |
7ce0058 | 1230.49 ms | 1246.94 ms | 16.45 ms |
App size
Revision | Plain | With Sentry | Diff |
---|---|---|---|
8b6def0 | 22.30 KiB | 750.46 KiB | 728.16 KiB |
51e85b4 | 22.31 KiB | 756.73 KiB | 734.42 KiB |
9ef5a81 | 22.30 KiB | 750.46 KiB | 728.16 KiB |
895b829 | 22.30 KiB | 750.46 KiB | 728.16 KiB |
f6a9e2b | 22.30 KiB | 750.46 KiB | 728.16 KiB |
8c646bc | 22.31 KiB | 756.74 KiB | 734.44 KiB |
f583fd1 | 22.30 KiB | 750.46 KiB | 728.16 KiB |
f38e16a | 22.30 KiB | 750.46 KiB | 728.16 KiB |
7ce0058 | 22.30 KiB | 750.46 KiB | 728.16 KiB |
Previous results on branch: feat/disableSDKSwiftUIPreview
Startup times
Revision | Plain | With Sentry | Diff |
---|---|---|---|
b421d36 | 1234.29 ms | 1249.18 ms | 14.89 ms |
db8a1d5 | 1245.84 ms | 1263.08 ms | 17.24 ms |
3965049 | 1228.13 ms | 1242.18 ms | 14.06 ms |
0cb9336 | 1223.10 ms | 1244.09 ms | 20.99 ms |
9ce8938 | 1233.04 ms | 1254.67 ms | 21.63 ms |
c994cb9 | 1231.63 ms | 1255.37 ms | 23.74 ms |
3578731 | 1221.36 ms | 1245.63 ms | 24.28 ms |
App size
Revision | Plain | With Sentry | Diff |
---|---|---|---|
b421d36 | 22.30 KiB | 750.94 KiB | 728.64 KiB |
db8a1d5 | 22.30 KiB | 750.94 KiB | 728.64 KiB |
3965049 | 22.30 KiB | 750.83 KiB | 728.52 KiB |
0cb9336 | 22.30 KiB | 750.89 KiB | 728.59 KiB |
9ce8938 | 22.30 KiB | 750.82 KiB | 728.52 KiB |
c994cb9 | 22.30 KiB | 750.89 KiB | 728.59 KiB |
3578731 | 22.30 KiB | 750.89 KiB | 728.59 KiB |
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'm not sure about the whole approach of the PR. What exactly is causing the slow-down? Can we do something to improve this? Maybe we should only turn off certain parts of the SDK. It's not obvious that we do this, and some users might get confused.
Do you have any reason why should Sentry run inside Xcode preview? |
Some users might expect it to and have reasons and get confused that we deactivate it. I haven't seen this approach in any other SDK. Again, I would like to understand what's causing the slowdown before deactivating it. |
I disagree; No user expects their monitoring solution to be running inside of Xcode preview, that is meant to help with creation of screens. There is no relevant information that could be used out of it, and the SDK would be initialized and dealloc many times in sequence, we don’t even know what the expected behavior of such usage is.
The entire SDK. In order to see my SwiftUI preview the SDK needs to initialize all its integrations, needs to create a new thread to monitor Apphangs, needs to swizzle a bunch of functions and make an analysis of the startup time, and none of this will be used. Again, what's the use case to run the SDK inside Xcode preview? |
I agree with @brustolin on this one. Xcode preview supports a static Preview Mode and an interactive Live Mode (Docs). As the preview can be used for individual UI components, it is most likely used in some kind of container framework/application (which then runs on the simulator in live mode), therefore not the full application as if it would run normally. Letting users think they can use the SDK in this environment, might actually cause confusion down the road. Regarding the performance, not sure how heavy the impact is, but generally the |
It seems wrong that we have to add this logic to our SDK. Why is the SDK even running in the Preview? Isn't this something our users should ensure doesn't happen? The preview shouldn't start Sentry. That should be in the |
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.
A question about using TestSentryNSProcessInfoWrapper, but otherwise I agree we should move forward with this.
…tsentry/sentry-cocoa into feat/disableSDKSwiftUIPreview
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.
You all convinced me. Thanks for the PR, @brustolin, and thanks for all the extra context, @armcknight. LGTM when adding some log messages.
#if TEST || TESTCI | ||
static NSDictionary<NSString *, NSString *> *_processInfoEnvironment; | ||
|
||
+ (void)setProcessInfoEnvironment:(NSDictionary<NSString *, NSString *> *)dictionary | ||
{ | ||
_processInfoEnvironment = dictionary; | ||
} | ||
|
||
+ (NSDictionary<NSString *, NSString *> *)processInfoEnvironment | ||
{ | ||
return _processInfoEnvironment; | ||
} | ||
|
||
#endif |
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.
m
: That code isn't used.
@@ -201,6 +203,11 @@ + (void)setStartTimestamp:(NSDate *)value | |||
|
|||
+ (void)startWithOptions:(SentryOptions *)options | |||
{ | |||
if ([SentryDependencyContainer.sharedInstance.processInfoWrapper | |||
.environment[SENTRY_XCODE_PREVIEW_ENVIRONMENT_KEY] isEqualToString:@"1"]) { | |||
return; |
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.
m
: Please add a WARN log message to communicate why we don't start the SDK.
private func shouldTrace() -> Bool { | ||
#if DEBUG | ||
if ProcessInfo.processInfo.environment[SENTRY_XCODE_PREVIEW_ENVIRONMENT_KEY] == "1" { | ||
return false |
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.
m
: Please add a log message explaining why we don't trace.
📜 Description
The SDK was running inside Xcode preview for SwiftUI and slowing things down for development.
💚 How did you test it?
Sample and Unit test
📝 Checklist
You have to check all boxes before merging:
sendDefaultPII
is enabled.🔮 Next steps