fix(flutter): Send frame delay in seconds#3677
Conversation
Convert accumulated frame delay from milliseconds to seconds before writing frames.delay and frames_delay. This matches the backend convention and the Android SDK behavior. Co-Authored-By: OpenAI Codex <noreply@openai.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #3677 +/- ##
=======================================
Coverage 86.80% 86.80%
=======================================
Files 335 335
Lines 11934 11935 +1
=======================================
+ Hits 10359 10360 +1
Misses 1575 1575
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
There was a problem hiding this comment.
Pull request overview
Adjusts Flutter frame delay reporting to match backend/Android expectations by emitting frame delay values in seconds (instead of milliseconds), ensuring correct magnitude in performance data.
Changes:
- Convert accumulated frame delay from milliseconds to seconds before writing span data/measurements (
frames.delay/frames_delay). - Update streaming span attribute emission to use a double-valued attribute for
frames.delay. - Update frame tracking tests to assert seconds-based values.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| packages/flutter/lib/src/frames_tracking/sentry_delayed_frames_tracker.dart | Converts computed frame delay from ms to seconds and changes SpanFrameMetrics.framesDelay to double. |
| packages/flutter/lib/src/frames_tracking/span_frame_metrics_collector.dart | Emits frames.delay as a double attribute for streaming spans. |
| packages/dart/lib/src/sentry_measurement.dart | Updates documentation for frames_delay measurement to clarify seconds. |
| packages/flutter/test/frame_tracking/sentry_delayed_frames_tracker_test.dart | Updates expected framesDelay values to seconds. |
| packages/flutter/test/frame_tracking/span_frame_metrics_test.dart | Updates span data/measurement expectations for seconds-based delay. |
| packages/flutter/test/frame_tracking/span_frame_metrics_collector_test.dart | Updates collector expectations for seconds-based delay in data/measurements/attributes. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
📲 Install BuildsAndroid
|
iOS Performance metrics 🚀
|
| Revision | Plain | With Sentry | Diff |
|---|---|---|---|
| 1fff351 | 1265.77 ms | 1256.06 ms | -9.70 ms |
| d2356d0 | 1257.04 ms | 1257.94 ms | 0.89 ms |
| c002f00 | 1252.47 ms | 1258.78 ms | 6.31 ms |
| cf443d2 | 1255.79 ms | 1248.38 ms | -7.40 ms |
| 3f47ea3 | 1263.90 ms | 1263.87 ms | -0.02 ms |
| 1ce780b | 1252.49 ms | 1256.17 ms | 3.68 ms |
| 0929dbf | 1275.89 ms | 1282.22 ms | 6.33 ms |
| 6b69699 | 1254.80 ms | 1273.31 ms | 18.52 ms |
| a10aff4 | 1241.67 ms | 1255.02 ms | 13.35 ms |
| fd88186 | 1255.06 ms | 1252.76 ms | -2.30 ms |
App size
| Revision | Plain | With Sentry | Diff |
|---|---|---|---|
| 1fff351 | 5.73 MiB | 6.17 MiB | 455.43 KiB |
| d2356d0 | 5.66 MiB | 6.09 MiB | 448.38 KiB |
| c002f00 | 5.65 MiB | 6.09 MiB | 448.38 KiB |
| cf443d2 | 5.53 MiB | 6.00 MiB | 479.99 KiB |
| 3f47ea3 | 5.53 MiB | 5.96 MiB | 444.81 KiB |
| 1ce780b | 5.66 MiB | 6.10 MiB | 451.58 KiB |
| 0929dbf | 7.86 MiB | 9.54 MiB | 1.69 MiB |
| 6b69699 | 7.86 MiB | 9.44 MiB | 1.58 MiB |
| a10aff4 | 5.53 MiB | 6.00 MiB | 486.71 KiB |
| fd88186 | 5.53 MiB | 6.00 MiB | 479.94 KiB |
denrase
left a comment
There was a problem hiding this comment.
Worth checking the unit that was flagged.
Mark frames_delay measurements as seconds when using the public measurement constructor and when applying Flutter frame metrics to root spans. Co-Authored-By: OpenAI Codex <noreply@openai.com>
Android Performance metrics 🚀
|
| Revision | Plain | With Sentry | Diff |
|---|---|---|---|
| c97f488 | 502.43 ms | 492.47 ms | -9.97 ms |
| 3801d52 | 397.53 ms | 378.87 ms | -18.66 ms |
| 0929dbf | 462.82 ms | 492.76 ms | 29.94 ms |
| 426fbfd | 368.10 ms | 353.23 ms | -14.87 ms |
| 0e2b9b0 | 368.00 ms | 356.72 ms | -11.28 ms |
| cf443d2 | 464.64 ms | 479.04 ms | 14.40 ms |
| 396cb30 | 405.70 ms | 427.56 ms | 21.86 ms |
| ce5c42b | 401.52 ms | 394.63 ms | -6.90 ms |
| c8596a6 | 474.00 ms | 492.96 ms | 18.96 ms |
| 2d34233 | 470.54 ms | 558.90 ms | 88.36 ms |
App size
| Revision | Plain | With Sentry | Diff |
|---|---|---|---|
| c97f488 | 14.31 MiB | 15.49 MiB | 1.19 MiB |
| 3801d52 | 14.31 MiB | 15.49 MiB | 1.19 MiB |
| 0929dbf | 6.54 MiB | 7.70 MiB | 1.17 MiB |
| 426fbfd | 13.93 MiB | 15.06 MiB | 1.13 MiB |
| 0e2b9b0 | 14.30 MiB | 15.49 MiB | 1.19 MiB |
| cf443d2 | 13.93 MiB | 15.00 MiB | 1.06 MiB |
| 396cb30 | 13.93 MiB | 15.06 MiB | 1.13 MiB |
| ce5c42b | 14.31 MiB | 15.49 MiB | 1.19 MiB |
| c8596a6 | 6.54 MiB | 7.53 MiB | 1015.27 KiB |
| 2d34233 | 6.54 MiB | 7.55 MiB | 1.01 MiB |
📜 Description
Send Flutter frame delay metrics in seconds instead of milliseconds.
The frame tracker still computes delays from millisecond timestamps internally,
but converts the accumulated value before writing
frames.delayandframes_delay. This matches the backend convention and the Android SDKbehavior.
💡 Motivation and Context
The backend processes frame delay values as seconds. Flutter was sending
millisecond values directly, which made frame delay data 1000x too large.
💚 How did you test it?
fvm flutter test test/frame_tracking/sentry_delayed_frames_tracker_test.dart test/frame_tracking/span_frame_metrics_test.dart test/frame_tracking/span_frame_metrics_collector_test.dartfvm flutter analyze lib/src/frames_tracking/sentry_delayed_frames_tracker.dart lib/src/frames_tracking/span_frame_metrics_collector.dart test/frame_tracking/sentry_delayed_frames_tracker_test.dart test/frame_tracking/span_frame_metrics_test.dart test/frame_tracking/span_frame_metrics_collector_test.dartfvm dart analyze lib/src/sentry_measurement.dartPre-commit checks also ran
dart analyze --fatal-warningsforsentryandflutter analyze --fatal-warningsforsentry_flutter.📝 Checklist
sendDefaultPiiis enabled🔮 Next steps
None.