getsentry / sentry-dart

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

feat: improve frame tracking accuracy #2372

Closed buenaflor closed 2 weeks ago

buenaflor commented 1 month ago

:scroll: Description

Changes the frames collected from addPersistentFrameCallback to using a custom widgets flutter binding where we override handleBeginFrame and handleDrawFrame. We are targeting the buildDuration

If the user already initialized the default or another binding before SentryFlutter.init then we simply don't collect any frames. Otherwise we urge the user to use SentryWidgetsFlutterBinding.ensureInitialized() if they need the binding before Sentry is initialized

:bulb: Motivation and Context

Flutter devtool results image

Our results image

It's quite accurate and very close to what Flutter reports from the engine. (the build duration, not the raster)

:green_heart: How did you test it?

Unit test, testing with widget, manual test

:pencil: Checklist

:crystal_ball: Next steps

github-actions[bot] commented 1 month ago
Messages
:book: Do not forget to update Sentry-docs with your feature once the pull request gets approved.

Generated by :no_entry_sign: dangerJS against e38700c04e69ea699bed053038c2d80568453da7

github-actions[bot] commented 1 month ago

🚨 Detected changes in high risk code 🚨

High-risk code has higher potential to break the SDK and may be hard to test. To prevent severe bugs, apply the rollout process for releasing such changes and be extra careful when changing and reviewing these files:

codecov[bot] commented 1 month ago

Codecov Report

Attention: Patch coverage is 96.82540% with 6 lines in your changes missing coverage. Please review.

Project coverage is 85.02%. Comparing base (73992eb) to head (e38700c). Report is 2 commits behind head on main.

Files with missing lines Patch % Lines
.../frames_tracking/span_frame_metrics_collector.dart 87.50% 3 Missing :warning:
dart/lib/src/sentry_measurement.dart 50.00% 1 Missing :warning:
dart/lib/src/span_data_convention.dart 0.00% 1 Missing :warning:
...frames_tracking/sentry_delayed_frames_tracker.dart 99.00% 1 Missing :warning:
Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #2372 +/- ## ========================================== + Coverage 84.72% 85.02% +0.29% ========================================== Files 254 257 +3 Lines 9113 9175 +62 ========================================== + Hits 7721 7801 +80 + Misses 1392 1374 -18 ```

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

github-actions[bot] commented 1 month ago

Android Performance metrics :rocket:

  Plain With Sentry Diff
Startup time 446.48 ms 497.08 ms 50.61 ms
Size 6.49 MiB 7.56 MiB 1.07 MiB

Baseline results on branch: main

Startup times

Revision Plain With Sentry Diff
e5b744f308ef88a70f679a622a88ade69705613c 302.70 ms 342.17 ms 39.47 ms
0ac1eed9198ed3ff6a9da538a7e34be4807120c3 370.60 ms 441.54 ms 70.94 ms
90a08ea59ea9a5f3aed6058b400411496b29aa91 477.25 ms 534.10 ms 56.85 ms
0db91ccbfaec953eb629db000f6a6034aa04e2c8 327.85 ms 387.31 ms 59.46 ms
061fed2925fdc038a8b4ed8f7905e646d7c0a887 434.11 ms 506.49 ms 72.38 ms
4829ad36de3c9b0c6cd7c1d030ee2987d7bb7347 381.55 ms 455.45 ms 73.90 ms
519423f251b6c787fd39742528f413087966d476 357.00 ms 415.77 ms 58.77 ms
ddc97adb5918b9f9eda573656e6edd9401b17801 331.45 ms 384.06 ms 52.61 ms
e3ef57098845edc69a00ce9b4845b54351beccbf 389.71 ms 459.16 ms 69.45 ms
2d3b03d17e0b28a698d4de81ab6ac6b586c4533a 309.53 ms 353.40 ms 43.87 ms

App size

Revision Plain With Sentry Diff
e5b744f308ef88a70f679a622a88ade69705613c 6.06 MiB 7.09 MiB 1.03 MiB
0ac1eed9198ed3ff6a9da538a7e34be4807120c3 6.06 MiB 7.03 MiB 990.44 KiB
90a08ea59ea9a5f3aed6058b400411496b29aa91 6.49 MiB 7.55 MiB 1.06 MiB
0db91ccbfaec953eb629db000f6a6034aa04e2c8 5.94 MiB 6.95 MiB 1.01 MiB
061fed2925fdc038a8b4ed8f7905e646d7c0a887 6.52 MiB 7.59 MiB 1.06 MiB
4829ad36de3c9b0c6cd7c1d030ee2987d7bb7347 6.33 MiB 7.26 MiB 943.11 KiB
519423f251b6c787fd39742528f413087966d476 6.06 MiB 7.03 MiB 989.24 KiB
ddc97adb5918b9f9eda573656e6edd9401b17801 6.16 MiB 7.14 MiB 1003.75 KiB
e3ef57098845edc69a00ce9b4845b54351beccbf 6.33 MiB 7.26 MiB 950.38 KiB
2d3b03d17e0b28a698d4de81ab6ac6b586c4533a 6.06 MiB 7.09 MiB 1.03 MiB

Previous results on branch: feat/improve-frame-tracking

Startup times

Revision Plain With Sentry Diff
eb5223b05918539af5a7bd86c5e5648c2a4a7c96 444.76 ms 508.62 ms 63.86 ms
b738cab7408016d30493106f6040c6e226baebf3 484.94 ms 529.06 ms 44.13 ms
20670ebbeba06164808e5d19ec7f53bf08edd52b 507.39 ms 559.13 ms 51.74 ms
519cf83050f59886b031cf616ca225e6a19c9a3b 456.48 ms 500.69 ms 44.21 ms
2a85afd231a82e7d532199d70ba9df2e304a9f83 593.73 ms 649.40 ms 55.66 ms
54e4e7c63c41f97911fe8593587499e9733976cb 451.19 ms 506.00 ms 54.81 ms
c47b0ca4cce69f2528c1895cb694847cd98bfb4f 609.23 ms 652.24 ms 43.02 ms
a3cadd70bc67de95792769d5eb2ac870cf87234a 432.74 ms 486.62 ms 53.88 ms
3be83c67cb1646809e84649dc1595c04ae65ec15 467.12 ms 531.85 ms 64.73 ms
63da945dc18bb207bb017afce3cbbdfdaea5e386 629.45 ms 700.42 ms 70.97 ms

App size

Revision Plain With Sentry Diff
eb5223b05918539af5a7bd86c5e5648c2a4a7c96 6.49 MiB 7.57 MiB 1.08 MiB
b738cab7408016d30493106f6040c6e226baebf3 6.49 MiB 7.56 MiB 1.07 MiB
20670ebbeba06164808e5d19ec7f53bf08edd52b 6.49 MiB 7.57 MiB 1.08 MiB
519cf83050f59886b031cf616ca225e6a19c9a3b 6.49 MiB 7.56 MiB 1.07 MiB
2a85afd231a82e7d532199d70ba9df2e304a9f83 6.49 MiB 7.56 MiB 1.07 MiB
54e4e7c63c41f97911fe8593587499e9733976cb 6.49 MiB 7.56 MiB 1.07 MiB
c47b0ca4cce69f2528c1895cb694847cd98bfb4f 6.49 MiB 7.57 MiB 1.08 MiB
a3cadd70bc67de95792769d5eb2ac870cf87234a 6.49 MiB 7.56 MiB 1.07 MiB
3be83c67cb1646809e84649dc1595c04ae65ec15 6.49 MiB 7.57 MiB 1.08 MiB
63da945dc18bb207bb017afce3cbbdfdaea5e386 6.49 MiB 7.56 MiB 1.07 MiB
github-actions[bot] commented 1 month ago

iOS Performance metrics :rocket:

  Plain With Sentry Diff
Startup time 1254.18 ms 1281.34 ms 27.16 ms
Size 8.38 MiB 9.76 MiB 1.39 MiB

Baseline results on branch: main

Startup times

Revision Plain With Sentry Diff
3a439051e01626aeb18b40f281823af4f1f1689c 1254.31 ms 1266.35 ms 12.04 ms
895beccc1c868667fa23473ba6287d23ed246bc8 1288.00 ms 1308.63 ms 20.63 ms
ed2ae087f58aef43c92ff2e06cdcd762fd45338b 1222.10 ms 1226.57 ms 4.47 ms
3a1617909872133e3cbb31acbb811bc3239c9806 1238.18 ms 1255.62 ms 17.44 ms
6572f8d71180920b30f2c566a955504cb215ecb1 1242.16 ms 1246.63 ms 4.47 ms
62dde4393f2d4ca67ddf0fe8a3bc4893228f67f5 1258.43 ms 1276.81 ms 18.38 ms
5112c69cbabc27fdee43278e7fae250aa56d0120 1272.76 ms 1293.37 ms 20.61 ms
b44db8ff5b31c762555dc432557e6f820798fab2 1255.29 ms 1258.90 ms 3.61 ms
8cb65572208ec7aa2e324de7cc642ae3104da349 1265.14 ms 1266.08 ms 0.94 ms
136c365a518666b435c0638af8bcd45b2be3e57a 1248.12 ms 1277.33 ms 29.20 ms

App size

Revision Plain With Sentry Diff
3a439051e01626aeb18b40f281823af4f1f1689c 8.10 MiB 9.18 MiB 1.08 MiB
895beccc1c868667fa23473ba6287d23ed246bc8 8.10 MiB 9.18 MiB 1.08 MiB
ed2ae087f58aef43c92ff2e06cdcd762fd45338b 8.28 MiB 9.34 MiB 1.06 MiB
3a1617909872133e3cbb31acbb811bc3239c9806 8.38 MiB 9.73 MiB 1.35 MiB
6572f8d71180920b30f2c566a955504cb215ecb1 8.29 MiB 9.36 MiB 1.07 MiB
62dde4393f2d4ca67ddf0fe8a3bc4893228f67f5 8.16 MiB 9.17 MiB 1.01 MiB
5112c69cbabc27fdee43278e7fae250aa56d0120 8.16 MiB 9.17 MiB 1.01 MiB
b44db8ff5b31c762555dc432557e6f820798fab2 8.29 MiB 9.37 MiB 1.08 MiB
8cb65572208ec7aa2e324de7cc642ae3104da349 8.10 MiB 9.18 MiB 1.08 MiB
136c365a518666b435c0638af8bcd45b2be3e57a 8.38 MiB 9.75 MiB 1.37 MiB

Previous results on branch: feat/improve-frame-tracking

Startup times

Revision Plain With Sentry Diff
a3cadd70bc67de95792769d5eb2ac870cf87234a 1239.02 ms 1252.80 ms 13.78 ms
519cf83050f59886b031cf616ca225e6a19c9a3b 1226.42 ms 1248.16 ms 21.75 ms
54e4e7c63c41f97911fe8593587499e9733976cb 1257.43 ms 1277.96 ms 20.53 ms
eb5223b05918539af5a7bd86c5e5648c2a4a7c96 1222.31 ms 1227.49 ms 5.18 ms
49a132cd2abbfd23ab11087a24f16700ee7dafff 1247.24 ms 1275.36 ms 28.11 ms
ef339abe648befba2d78cd1224907425c56897ed 1249.04 ms 1270.83 ms 21.79 ms
533d18fdf7332422a45b9b711ff4c5922296ef85 1241.61 ms 1260.67 ms 19.05 ms
f65fc0899f3cbbe63e16ae506c286c6d9ab4b54f 1239.18 ms 1255.53 ms 16.35 ms
4b3335e84a14858938e804bd94f2b3ae00253e93 1254.71 ms 1269.00 ms 14.29 ms
3be83c67cb1646809e84649dc1595c04ae65ec15 1255.57 ms 1279.31 ms 23.73 ms

App size

Revision Plain With Sentry Diff
a3cadd70bc67de95792769d5eb2ac870cf87234a 8.38 MiB 9.74 MiB 1.36 MiB
519cf83050f59886b031cf616ca225e6a19c9a3b 8.38 MiB 9.74 MiB 1.36 MiB
54e4e7c63c41f97911fe8593587499e9733976cb 8.38 MiB 9.74 MiB 1.36 MiB
eb5223b05918539af5a7bd86c5e5648c2a4a7c96 8.38 MiB 9.74 MiB 1.37 MiB
49a132cd2abbfd23ab11087a24f16700ee7dafff 8.38 MiB 9.74 MiB 1.36 MiB
ef339abe648befba2d78cd1224907425c56897ed 8.38 MiB 9.74 MiB 1.36 MiB
533d18fdf7332422a45b9b711ff4c5922296ef85 8.38 MiB 9.74 MiB 1.37 MiB
f65fc0899f3cbbe63e16ae506c286c6d9ab4b54f 8.38 MiB 9.74 MiB 1.36 MiB
4b3335e84a14858938e804bd94f2b3ae00253e93 8.38 MiB 9.74 MiB 1.36 MiB
3be83c67cb1646809e84649dc1595c04ae65ec15 8.38 MiB 9.74 MiB 1.37 MiB
buenaflor commented 1 month ago

@stefanosiano ptal when you have time 🙏