-
-
Notifications
You must be signed in to change notification settings - Fork 341
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
feat: Update view hierarchy attachment format to Json #2491
Conversation
|
Codecov Report
Additional details and impacted files@@ Coverage Diff @@
## 8.0.0 #2491 +/- ##
==========================================
+ Coverage 78.94% 79.04% +0.10%
==========================================
Files 240 243 +3
Lines 22124 22259 +135
Branches 9768 9839 +71
==========================================
+ Hits 17466 17595 +129
- Misses 4206 4213 +7
+ Partials 452 451 -1
Continue to review full report at Codecov.
|
Performance metrics 🚀
|
Revision | Plain | With Sentry | Diff |
---|---|---|---|
5da2d48 | 1209.52 ms | 1232.16 ms | 22.64 ms |
9f8d429 | 1239.57 ms | 1255.12 ms | 15.55 ms |
3fdb749 | 1227.42 ms | 1248.48 ms | 21.06 ms |
b9c9598 | 1232.86 ms | 1253.84 ms | 20.98 ms |
b696ae1 | 1229.64 ms | 1246.94 ms | 17.30 ms |
d8c347f | 1240.53 ms | 1257.70 ms | 17.17 ms |
459ae5e | 1223.84 ms | 1250.14 ms | 26.31 ms |
a8ac44f | 1198.63 ms | 1231.08 ms | 32.45 ms |
a0c8696 | 1239.33 ms | 1261.92 ms | 22.59 ms |
88ac2c2 | 1223.04 ms | 1243.12 ms | 20.08 ms |
App size
Revision | Plain | With Sentry | Diff |
---|---|---|---|
5da2d48 | 20.75 KiB | 383.77 KiB | 363.01 KiB |
9f8d429 | 20.75 KiB | 383.40 KiB | 362.65 KiB |
3fdb749 | 20.75 KiB | 383.81 KiB | 363.06 KiB |
b9c9598 | 20.75 KiB | 383.77 KiB | 363.01 KiB |
b696ae1 | 20.75 KiB | 383.77 KiB | 363.01 KiB |
d8c347f | 20.75 KiB | 383.77 KiB | 363.02 KiB |
459ae5e | 20.75 KiB | 383.50 KiB | 362.75 KiB |
a8ac44f | 20.75 KiB | 405.17 KiB | 384.41 KiB |
a0c8696 | 20.75 KiB | 383.89 KiB | 363.14 KiB |
88ac2c2 | 20.75 KiB | 373.61 KiB | 352.86 KiB |
Previous results on branch: feat/view-hierarchy
Startup times
Revision | Plain | With Sentry | Diff |
---|---|---|---|
fbb44fb | 1217.22 ms | 1239.00 ms | 21.78 ms |
4ffd327 | 1217.31 ms | 1248.26 ms | 30.95 ms |
e9ee171 | 1203.84 ms | 1237.76 ms | 33.92 ms |
2e2a243 | 1238.42 ms | 1268.50 ms | 30.08 ms |
797af24 | 1243.04 ms | 1279.43 ms | 36.39 ms |
806bdb8 | 1248.11 ms | 1252.32 ms | 4.21 ms |
5551192 | 1188.55 ms | 1234.82 ms | 46.27 ms |
b989d78 | 1196.17 ms | 1241.08 ms | 44.91 ms |
ddb8e6c | 1213.39 ms | 1239.22 ms | 25.83 ms |
App size
Revision | Plain | With Sentry | Diff |
---|---|---|---|
fbb44fb | 20.75 KiB | 405.61 KiB | 384.85 KiB |
4ffd327 | 20.75 KiB | 406.30 KiB | 385.54 KiB |
e9ee171 | 20.75 KiB | 384.62 KiB | 363.86 KiB |
2e2a243 | 20.75 KiB | 406.25 KiB | 385.50 KiB |
797af24 | 20.75 KiB | 406.78 KiB | 386.03 KiB |
806bdb8 | 20.75 KiB | 406.69 KiB | 385.93 KiB |
5551192 | 20.75 KiB | 406.30 KiB | 385.54 KiB |
b989d78 | 20.75 KiB | 406.97 KiB | 386.21 KiB |
ddb8e6c | 20.75 KiB | 406.81 KiB | 386.06 KiB |
…oa into feat/view-hierarchy
…oa into feat/view-hierarchy
tryJson(sentrycrashjson_addFloatingPointElement(context, "x", view.frame.origin.x)); | ||
tryJson(sentrycrashjson_addFloatingPointElement(context, "y", view.frame.origin.y)); | ||
tryJson(sentrycrashjson_addFloatingPointElement(context, "alpha", view.alpha)); | ||
tryJson(sentrycrashjson_addBooleanElement(context, "visible", !view.hidden)); |
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.
Why are we not just using [NSJSONSerialization dataWithJSONObject:]
? I don't really understand why we're creating JSON in such a strange way with sentrycrashjson_addFloatingPointElement
.
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.
This way we can write directly to file, or to memory buffer, no need to first create a dictionary, and then serialize the dictionary.
This will be used during signal handling, the faster and less memory allocation being done the better.
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.
Yes, but we already call into objective C code to make this work. We should only call async safe code in a signal handler, but as we are already violating that contract, I'm unsure if it's worth the effort. We call this only after SentryCrash wrote the crash report. In some cases, we will crash when calling into ObjC, but I think it doesn't matter how often we do it. Once is enough.
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.
Is not about safety, because this code itself is called from an objc class. Is about performance, this is the fastest way to do it, and since we may deal of view hierarchy with hundreds of views, the faster the better.
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.
How much faster? Do you have benchmarks?
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 convinced me with during signal handling
.
…oa into feat/view-hierarchy
…oa into feat/view-hierarchy
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.
Personally I don't think the JSON code is a good thing to maintain, but if you say it makes a significant difference with CPU / memory usage, I guess it makes sense?
I also feel the goto
code is a footgun, but I'll leave final judgement for @philipphofmann.
@kevinrenskers But in this case I have another solution, I will use it to make you happy! 😁 |
Well I didn't deny the PR, like I said I'll just leave it up to Philipp :) |
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.
First pass. Still need to review a couple of files.
I also don't like |
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 unsure about writing the hierarchy with C APIs. I explained my concerns in my comment. Once we resolved that I'm going to give this another review.
const char *path = [filePath UTF8String]; | ||
int fd = open(path, O_RDWR | O_CREAT | O_TRUNC, 0644); | ||
if (fd < 0) { | ||
SENTRY_LOG_DEBUG(@"Could not open file %s for writing: %s", path, strerror(errno)); | ||
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
: Why don't we use ObjC here? SENTRY_LOG_DEBUG
calls into ObjC code.
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.
Why don't we use ObjC here?
What do you mean? Almost everything here is objc.
If you're talking about the serialization approach in the other function, the explanation is here
Tests/SentryTests/Integrations/ViewHierarchy/TestSentryViewHierarchy.h
Outdated
Show resolved
Hide resolved
tryJson(sentrycrashjson_addFloatingPointElement(context, "x", view.frame.origin.x)); | ||
tryJson(sentrycrashjson_addFloatingPointElement(context, "y", view.frame.origin.y)); | ||
tryJson(sentrycrashjson_addFloatingPointElement(context, "alpha", view.alpha)); | ||
tryJson(sentrycrashjson_addBooleanElement(context, "visible", !view.hidden)); |
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.
Yes, but we already call into objective C code to make this work. We should only call async safe code in a signal handler, but as we are already violating that contract, I'm unsure if it's worth the effort. We call this only after SentryCrash wrote the crash report. In some cases, we will crash when calling into ObjC, but I think it doesn't matter how often we do it. Once is enough.
Co-authored-by: Philipp Hofmann <philipp.hofmann@sentry.io>
…oa into feat/view-hierarchy
@@ -396,6 +396,19 @@ - (void)addAttachment:(SentryAttachment *)attachment | |||
} | |||
} | |||
|
|||
- (void)addCrashReportAttachmentInPath:(NSString *)filePath | |||
{ | |||
if ([filePath.lastPathComponent isEqualToString:@"view-hierarchy.json"]) { |
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.
Can you please address this comment ⬆️
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.
LGTM
@philipphofmann @brustolin is there docs for that already? |
I'm pretty sure there aren't. @brustolin, please add some after your PTO. I created an issue getsentry/sentry-docs#5984. |
📜 Description
Change view hierarchy format to conform to RFC 33
💡 Motivation and Context
close #2467
💚 How did you test it?
Unit tests
📝 Checklist
🔮 Next steps