getsentry / sentry-dart

Sentry SDK for Dart and Flutter
https://sentry.io/for/flutter/
MIT License
725 stars 223 forks source link

feat(performance): report total frames, frame delay, slow & frozen frames #2106

Closed buenaflor closed 1 day ago

buenaflor commented 1 week ago

:scroll: Description

Attaches frame metrics to spans such as total frames, frame delay, slow & frozen frames

:bulb: Motivation and Context

Mobile Starfish

:green_heart: How did you test it?

Unit tests, manually

:pencil: Checklist

:crystal_ball: Next steps

### Tasks
- [ ] Update docs
- [x] Create issue that Linux, Windows and Web refresh rates are currently locked at 60hz for frame metrics calculation
github-actions[bot] commented 1 week ago
Fails
:no_entry_sign: Please consider adding a changelog entry for the next release.
Messages
:book: Do not forget to update Sentry-docs with your feature once the pull request gets approved.

Instructions and example for changelog

Please add an entry to CHANGELOG.md to the "Unreleased" section. Make sure the entry includes this PR's number.

Example:

## Unreleased

- report total frames, frame delay, slow & frozen frames ([#2106](https://github.com/getsentry/sentry-dart/pull/2106))

If none of the above apply, you can opt out of this check by adding #skip-changelog to the PR description.

Generated by :no_entry_sign: dangerJS against 736bafc8a2397544d6219e57535dce33c7ea229d

github-actions[bot] commented 1 week ago

Android Performance metrics :rocket:

  Plain With Sentry Diff
Startup time 353.21 ms 410.35 ms 57.13 ms
Size 6.35 MiB 7.35 MiB 1017.84 KiB

Baseline results on branch: main

Startup times

Revision Plain With Sentry Diff
f275487b349060e5e84df5d00e3c98d0b8a7cc68 369.08 ms 432.44 ms 63.36 ms
8776cdf4688ec58628a4b68a24f5d8840f2b523f 353.32 ms 416.58 ms 63.26 ms
42f6e7e6bf2882e21c1f664a1a6c8277ab07ad3b 308.71 ms 360.06 ms 51.35 ms
04db237c887e97fd4e5843a50e97135e2e03ce53 330.16 ms 428.38 ms 98.22 ms
1c6eb5b33483c440c18525f0e946a9031d09863c 350.69 ms 393.86 ms 43.17 ms
ccc09e46acc7147666e81efa418c893b72686644 308.21 ms 357.74 ms 49.54 ms
e5b744f308ef88a70f679a622a88ade69705613c 302.70 ms 342.17 ms 39.47 ms
43abc4fd929361a54f3e4ba1570914ec882272fa 406.54 ms 475.53 ms 68.99 ms
64e4616c0444f9dd46605b79140797623a76b10b 349.82 ms 436.96 ms 87.14 ms
56810ff730b5c918da021c12c84ee1cd88d62aa1 309.72 ms 352.26 ms 42.54 ms

App size

Revision Plain With Sentry Diff
f275487b349060e5e84df5d00e3c98d0b8a7cc68 6.33 MiB 7.26 MiB 947.03 KiB
8776cdf4688ec58628a4b68a24f5d8840f2b523f 6.34 MiB 7.28 MiB 966.66 KiB
42f6e7e6bf2882e21c1f664a1a6c8277ab07ad3b 6.27 MiB 7.20 MiB 956.06 KiB
04db237c887e97fd4e5843a50e97135e2e03ce53 5.94 MiB 6.95 MiB 1.01 MiB
1c6eb5b33483c440c18525f0e946a9031d09863c 5.94 MiB 6.92 MiB 1001.53 KiB
ccc09e46acc7147666e81efa418c893b72686644 5.94 MiB 6.95 MiB 1.01 MiB
e5b744f308ef88a70f679a622a88ade69705613c 6.06 MiB 7.09 MiB 1.03 MiB
43abc4fd929361a54f3e4ba1570914ec882272fa 6.35 MiB 7.34 MiB 1007.72 KiB
64e4616c0444f9dd46605b79140797623a76b10b 6.27 MiB 7.20 MiB 956.52 KiB
56810ff730b5c918da021c12c84ee1cd88d62aa1 5.94 MiB 6.92 MiB 1001.71 KiB

Previous results on branch: feat/frame-duration

Startup times

Revision Plain With Sentry Diff
2219ec3ba29bbb0b399cdd07b49aabcc7fbeb115 394.26 ms 451.51 ms 57.25 ms
cb8e94f81ff928ffecc5716fe2a76c3e44c72f4c 368.41 ms 433.87 ms 65.47 ms
28de2ed23d70bc2f9211b9da8bb3fb21e680bd5f 407.94 ms 487.00 ms 79.06 ms
71cdcdb1521c0c922a4d5eb6e3bd1bad8f1f01f7 363.48 ms 429.50 ms 66.02 ms
b5630cb93cef8179f383dbbcc96aef0678fed253 367.54 ms 387.82 ms 20.28 ms
cf7c96ce067e9fc171bb7dfceef5db055f64cd95 383.45 ms 440.74 ms 57.30 ms

App size

Revision Plain With Sentry Diff
2219ec3ba29bbb0b399cdd07b49aabcc7fbeb115 6.35 MiB 7.34 MiB 1013.39 KiB
cb8e94f81ff928ffecc5716fe2a76c3e44c72f4c 6.35 MiB 7.34 MiB 1013.39 KiB
28de2ed23d70bc2f9211b9da8bb3fb21e680bd5f 6.35 MiB 7.35 MiB 1017.84 KiB
71cdcdb1521c0c922a4d5eb6e3bd1bad8f1f01f7 6.35 MiB 7.35 MiB 1017.84 KiB
b5630cb93cef8179f383dbbcc96aef0678fed253 6.35 MiB 7.35 MiB 1017.84 KiB
cf7c96ce067e9fc171bb7dfceef5db055f64cd95 6.35 MiB 7.34 MiB 1013.40 KiB
codecov[bot] commented 1 week ago

Codecov Report

Attention: Patch coverage is 74.40000% with 32 lines in your changes missing coverage. Please review.

Project coverage is 88.41%. Comparing base (7e7f0b1) to head (736bafc).

Files Patch % Lines
flutter/lib/src/span_frame_metrics_collector.dart 86.31% 13 Missing :warning:
flutter/lib/src/frame_callback_handler.dart 0.00% 6 Missing :warning:
dart/lib/src/protocol/sentry_span.dart 54.54% 5 Missing :warning:
dart/lib/src/sentry_tracer.dart 33.33% 4 Missing :warning:
dart/lib/src/sentry_options.dart 50.00% 2 Missing :warning:
flutter/lib/src/native/sentry_native_channel.dart 0.00% 2 Missing :warning:
Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #2106 +/- ## ========================================== - Coverage 88.64% 88.41% -0.24% ========================================== Files 223 224 +1 Lines 7583 7705 +122 ========================================== + Hits 6722 6812 +90 - Misses 861 893 +32 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

buenaflor commented 2 days ago

@stefanosiano I updated the cocoa refresh rate fetching so it also works on macos. Linux, windows and web don't have specific refresh rate fetching yet so it stays at 60hz for them and I don't think they're a priority currently. Maybe we can create an issue afterwards so we have it tracked at least?

stefanosiano commented 2 days ago

@stefanosiano I updated the cocoa refresh rate fetching so it also works on macos. Linux, windows and web don't have specific refresh rate fetching yet so it stays at 60hz for them and I don't think they're a priority currently. Maybe we can create an issue afterwards so we have it tracked at least?

yep, totally fine!

github-actions[bot] commented 2 days ago

iOS Performance metrics :rocket:

  Plain With Sentry Diff
Startup time 1212.69 ms 1240.47 ms 27.78 ms
Size 8.33 MiB 9.62 MiB 1.29 MiB

Baseline results on branch: main

Startup times

Revision Plain With Sentry Diff
a60913453866bc81901784aec6fa8aad023135f8 1254.50 ms 1265.08 ms 10.58 ms
ddc97adb5918b9f9eda573656e6edd9401b17801 1228.02 ms 1232.61 ms 4.59 ms
9fe67d51d3fe8a8daa73206ae4eac77ca507e406 1242.33 ms 1268.77 ms 26.44 ms
95d0636f4b734360bc5fdbe6f3c53ea2ecc9ee97 1243.73 ms 1245.54 ms 1.81 ms
bd37365fd6e136a94c2538957f6b6e46e0fba5f8 1236.22 ms 1243.27 ms 7.04 ms
b0811ccc76dccb91004b36b5f710163daf733d92 1238.23 ms 1255.82 ms 17.59 ms
689d2fdeffcb3a68ad5a04b3c752edf558236f4a 1257.71 ms 1265.16 ms 7.45 ms
3334ac176f15a6d39b435960620ea9a4919aae79 1259.22 ms 1275.40 ms 16.17 ms
4efee31c65f1fefbb85fc97598de6b3ae8fd93b4 1270.33 ms 1285.75 ms 15.42 ms
ae0263294aa289445fd162ceb85a18ede257e8fd 1286.77 ms 1300.37 ms 13.60 ms

App size

Revision Plain With Sentry Diff
a60913453866bc81901784aec6fa8aad023135f8 8.16 MiB 9.16 MiB 1.01 MiB
ddc97adb5918b9f9eda573656e6edd9401b17801 8.29 MiB 9.37 MiB 1.08 MiB
9fe67d51d3fe8a8daa73206ae4eac77ca507e406 8.32 MiB 9.50 MiB 1.18 MiB
95d0636f4b734360bc5fdbe6f3c53ea2ecc9ee97 8.29 MiB 9.38 MiB 1.09 MiB
bd37365fd6e136a94c2538957f6b6e46e0fba5f8 8.28 MiB 9.34 MiB 1.06 MiB
b0811ccc76dccb91004b36b5f710163daf733d92 8.32 MiB 9.38 MiB 1.06 MiB
689d2fdeffcb3a68ad5a04b3c752edf558236f4a 8.10 MiB 9.16 MiB 1.06 MiB
3334ac176f15a6d39b435960620ea9a4919aae79 8.10 MiB 9.17 MiB 1.08 MiB
4efee31c65f1fefbb85fc97598de6b3ae8fd93b4 8.15 MiB 9.12 MiB 991.35 KiB
ae0263294aa289445fd162ceb85a18ede257e8fd 8.16 MiB 9.15 MiB 1020.68 KiB

Previous results on branch: feat/frame-duration

Startup times

Revision Plain With Sentry Diff
cb8e94f81ff928ffecc5716fe2a76c3e44c72f4c 1227.33 ms 1260.00 ms 32.67 ms
71cdcdb1521c0c922a4d5eb6e3bd1bad8f1f01f7 1345.35 ms 1397.72 ms 52.37 ms
cf7c96ce067e9fc171bb7dfceef5db055f64cd95 1218.04 ms 1230.35 ms 12.31 ms
28de2ed23d70bc2f9211b9da8bb3fb21e680bd5f 1241.15 ms 1254.57 ms 13.42 ms
2219ec3ba29bbb0b399cdd07b49aabcc7fbeb115 1207.22 ms 1230.77 ms 23.55 ms
b5630cb93cef8179f383dbbcc96aef0678fed253 1241.14 ms 1254.73 ms 13.59 ms

App size

Revision Plain With Sentry Diff
cb8e94f81ff928ffecc5716fe2a76c3e44c72f4c 8.33 MiB 9.59 MiB 1.26 MiB
71cdcdb1521c0c922a4d5eb6e3bd1bad8f1f01f7 8.33 MiB 9.62 MiB 1.29 MiB
cf7c96ce067e9fc171bb7dfceef5db055f64cd95 8.33 MiB 9.59 MiB 1.26 MiB
28de2ed23d70bc2f9211b9da8bb3fb21e680bd5f 8.33 MiB 9.62 MiB 1.29 MiB
2219ec3ba29bbb0b399cdd07b49aabcc7fbeb115 8.33 MiB 9.59 MiB 1.26 MiB
b5630cb93cef8179f383dbbcc96aef0678fed253 8.33 MiB 9.62 MiB 1.29 MiB
buenaflor commented 2 days ago

@stefanosiano seems like CVDisplayLink which I'm using for the macos refresh rate impl is deprecated, I'll try to migrate it to the recommended API

buenaflor commented 1 day ago

Updated the implementation, works nicely and detects the refresh rate depending on the screen where the window is currently at