-
-
Notifications
You must be signed in to change notification settings - Fork 336
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(screenshots): Don't capture zero size screenshots #2459
fix(screenshots): Don't capture zero size screenshots #2459
Conversation
Performance metrics 🚀
|
Revision | Plain | With Sentry | Diff |
---|---|---|---|
a9e77dc | 1231.94 ms | 1254.85 ms | 22.91 ms |
8361c4c | 1204.07 ms | 1252.74 ms | 48.67 ms |
cdf9acd | 1219.62 ms | 1254.80 ms | 35.18 ms |
b9c9598 | 1228.57 ms | 1251.10 ms | 22.53 ms |
034ff5e | 1231.22 ms | 1255.37 ms | 24.14 ms |
dd266f5 | 1224.76 ms | 1252.63 ms | 27.87 ms |
2b42e4e | 1212.52 ms | 1249.24 ms | 36.72 ms |
bbf5334 | 1216.84 ms | 1238.82 ms | 21.98 ms |
fb9f27a | 1218.55 ms | 1249.17 ms | 30.62 ms |
b9c9598 | 1232.86 ms | 1253.84 ms | 20.98 ms |
App size
Revision | Plain | With Sentry | Diff |
---|---|---|---|
a9e77dc | 20.75 KiB | 379.12 KiB | 358.36 KiB |
8361c4c | 20.75 KiB | 383.87 KiB | 363.12 KiB |
cdf9acd | 20.75 KiB | 383.78 KiB | 363.03 KiB |
b9c9598 | 20.75 KiB | 383.77 KiB | 363.01 KiB |
034ff5e | 20.75 KiB | 383.83 KiB | 363.07 KiB |
dd266f5 | 20.75 KiB | 383.39 KiB | 362.64 KiB |
2b42e4e | 20.75 KiB | 383.89 KiB | 363.14 KiB |
bbf5334 | 20.75 KiB | 383.37 KiB | 362.62 KiB |
fb9f27a | 20.75 KiB | 382.11 KiB | 361.36 KiB |
b9c9598 | 20.75 KiB | 383.77 KiB | 363.01 KiB |
Previous results on branch: fix-dont-capture-zero-size-screenshots
Startup times
Revision | Plain | With Sentry | Diff |
---|---|---|---|
d91ca50 | 1229.62 ms | 1259.23 ms | 29.61 ms |
d15071c | 1223.67 ms | 1234.66 ms | 10.99 ms |
63b24e1 | 1261.49 ms | 1272.02 ms | 10.53 ms |
3c09ad9 | 1194.24 ms | 1228.64 ms | 34.40 ms |
App size
Revision | Plain | With Sentry | Diff |
---|---|---|---|
d91ca50 | 20.75 KiB | 374.87 KiB | 354.12 KiB |
d15071c | 20.75 KiB | 374.63 KiB | 353.88 KiB |
63b24e1 | 20.75 KiB | 374.87 KiB | 354.12 KiB |
3c09ad9 | 20.75 KiB | 374.91 KiB | 354.16 KiB |
Co-authored-by: Dhiogo Brustolin <[email protected]>
@@ -47,7 +47,12 @@ - (void)saveScreenShots:(NSString *)path | |||
|
|||
if ([window drawViewHierarchyInRect:window.bounds afterScreenUpdates:false]) { | |||
UIImage *img = UIGraphicsGetImageFromCurrentImageContext(); | |||
[result addObject:UIImagePNGRepresentation(img)]; | |||
if (img.size.width > 0 || img.size.height > 0) { |
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
: Can we please add tests for this new functionality? As this code is not really testable you could extract this code into a method, expose it via a private category that you would have to add similar as we have it, for example, for SentryClient+Private.h, and then call it from tests. I can also push the basic solution to your branch if you want @krystofwoldrich.
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 can push the solution to this branch and I will work with that. It will definitely help me.
Besides exposing it with the private header. Are there any examples in the test on how to mock functions, likely I will have to mock UIGraphicsGetImageFromCurrentImageContext
.
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.
The code was already testable. I added a test.
@krystofwoldrich, does this need to be released quickly or can it wait until 8.0.0, which we are currently preparing? |
@philipphofmann It can wait. |
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
NSData *bytes = UIImagePNGRepresentation(img); | ||
if (bytes && bytes.length > 0) { |
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.
l
: If the image has 0 height or width, it's already empty. I think we don't need to check for bytes && bytes.length > 0
here.
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.
Its not the size of the view that makes the image 0 length, its not being able to render the image.
@krystofwoldrich, what's stopping us from merging this PR? |
…o-size-screenshots
Codecov Report
Additional details and impacted files@@ Coverage Diff @@
## 8.0.0 #2459 +/- ##
==========================================
+ Coverage 0.00% 88.41% +88.41%
==========================================
Files 239 178 -61
Lines 22236 15211 -7025
Branches 9134 5282 -3852
==========================================
+ Hits 0 13449 +13449
+ Misses 22231 1583 -20648
- Partials 5 179 +174 Continue to review full report at Codecov.
|
@philipphofmann Nothing, just waiting for CI to finish and it's merged. |
Thanks @krystofwoldrich for the fix 👏😀 |
📜 Description
In Android SDK the screenshot function checks for invalid screenshots values, like zero-size screenshots. This was missing in iOS.
💡 Motivation and Context
💚 How did you test it?
I run the SDK locally with the RN sample app.
📝 Checklist
🔮 Next steps