Skip to content

TTID/TTFD Improvements #2866

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

Open
wants to merge 67 commits into
base: main
Choose a base branch
from
Open

TTID/TTFD Improvements #2866

wants to merge 67 commits into from

Conversation

denrase
Copy link
Collaborator

@denrase denrase commented Apr 15, 2025

📜 Description

  • Adds a SentryDisplay with reportFullyDisplayed, fixing TTFD improvements #2852
  • Adds SentryDisplayWidget to wrap SentryDisplay
  • Refactoring
    • Remove global singleton instances for TTID/TTFD trackers
    • Remove redundant startTimestamp
    • Inject options in TTFD tracker instead of using static
  • Fixes an issue where root screen ttfd could not be reported

💡 Motivation and Context

Closes #2852

💚 How did you test it?

Unit tests

📝 Checklist

  • I reviewed submitted code
  • I added tests to verify changes
  • No new PII added or SDK only sends newly added PII if sendDefaultPii is enabled
  • I updated the docs if needed
  • All tests passing
  • No breaking changes

Copy link

codecov bot commented Apr 15, 2025

Codecov Report

Attention: Patch coverage is 93.19728% with 10 lines in your changes missing coverage. Please review.

Project coverage is 89.11%. Comparing base (3925712) to head (462fd87).

Files with missing lines Patch % Lines
flutter/lib/src/sentry_flutter.dart 55.55% 4 Missing ⚠️
flutter/lib/src/navigation/sentry_display.dart 75.00% 2 Missing ⚠️
...tter/lib/src/navigation/sentry_display_widget.dart 89.47% 2 Missing ⚠️
...b/src/navigation/time_to_full_display_tracker.dart 93.33% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2866      +/-   ##
==========================================
+ Coverage   87.63%   89.11%   +1.47%     
==========================================
  Files         278       95     -183     
  Lines        9180     3104    -6076     
==========================================
- Hits         8045     2766    -5279     
+ Misses       1135      338     -797     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@denrase denrase marked this pull request as ready for review April 15, 2025 15:59
Copy link
Contributor

github-actions bot commented Apr 15, 2025

iOS Performance metrics 🚀

  Plain With Sentry Diff
Startup time 1257.44 ms 1266.44 ms 9.01 ms
Size 7.85 MiB 9.44 MiB 1.59 MiB

Baseline results on branch: main

Startup times

Revision Plain With Sentry Diff
daa1b33 1224.41 ms 1244.59 ms 20.18 ms
be8cafe 1239.94 ms 1266.20 ms 26.27 ms
586d7d2 1248.73 ms 1257.39 ms 8.66 ms
b5c66ec 1257.66 ms 1275.00 ms 17.34 ms
4b943a1 1250.23 ms 1262.28 ms 12.05 ms
9f9dd52 1364.63 ms 1394.89 ms 30.25 ms
ec4c9da 1228.33 ms 1261.63 ms 33.31 ms
f7f46dc 1285.82 ms 1315.06 ms 29.24 ms
4b29d6e 1208.18 ms 1230.92 ms 22.73 ms
fe6dcac 1234.19 ms 1260.71 ms 26.52 ms

App size

Revision Plain With Sentry Diff
daa1b33 8.28 MiB 9.34 MiB 1.05 MiB
be8cafe 8.33 MiB 9.40 MiB 1.07 MiB
586d7d2 8.33 MiB 9.54 MiB 1.22 MiB
b5c66ec 7.85 MiB 9.42 MiB 1.57 MiB
4b943a1 8.33 MiB 9.40 MiB 1.07 MiB
9f9dd52 8.33 MiB 9.63 MiB 1.29 MiB
ec4c9da 8.38 MiB 9.71 MiB 1.34 MiB
f7f46dc 8.10 MiB 9.17 MiB 1.08 MiB
4b29d6e 8.32 MiB 9.38 MiB 1.05 MiB
fe6dcac 8.38 MiB 9.74 MiB 1.36 MiB

Previous results on branch: enha/ttfd-tracking-imporvements

Startup times

Revision Plain With Sentry Diff
13c4582 1265.98 ms 1278.06 ms 12.08 ms
e6c151d 1265.26 ms 1276.04 ms 10.79 ms
7f5d8b4 1250.23 ms 1262.70 ms 12.47 ms
4aca1fa 1254.02 ms 1263.76 ms 9.73 ms
129b785 1258.48 ms 1268.57 ms 10.10 ms
22dfd2b 1258.24 ms 1271.00 ms 12.76 ms
31c6c6b 1267.96 ms 1282.86 ms 14.90 ms
abf0025 1248.33 ms 1264.54 ms 16.21 ms
18daedc 1252.35 ms 1266.81 ms 14.46 ms
cfec46d 1275.14 ms 1287.55 ms 12.41 ms

App size

Revision Plain With Sentry Diff
13c4582 8.43 MiB 10.01 MiB 1.58 MiB
e6c151d 8.43 MiB 10.01 MiB 1.58 MiB
7f5d8b4 7.85 MiB 9.42 MiB 1.57 MiB
4aca1fa 8.43 MiB 10.01 MiB 1.58 MiB
129b785 8.43 MiB 10.01 MiB 1.58 MiB
22dfd2b 8.43 MiB 10.01 MiB 1.58 MiB
31c6c6b 8.43 MiB 10.01 MiB 1.58 MiB
abf0025 8.43 MiB 10.01 MiB 1.58 MiB
18daedc 8.43 MiB 10.01 MiB 1.58 MiB
cfec46d 8.43 MiB 10.01 MiB 1.58 MiB

Copy link
Contributor

github-actions bot commented Apr 15, 2025

Android Performance metrics 🚀

  Plain With Sentry Diff
Startup time 556.84 ms 600.20 ms 43.36 ms
Size 6.54 MiB 7.53 MiB 1015.05 KiB

Baseline results on branch: main

Startup times

Revision Plain With Sentry Diff
04db237 330.16 ms 428.38 ms 98.22 ms
b47809a 333.42 ms 368.36 ms 34.95 ms
68677de 364.41 ms 415.61 ms 51.20 ms
6daa837 363.28 ms 424.71 ms 61.43 ms
9a604e8 470.65 ms 485.90 ms 15.24 ms
322aa66 284.98 ms 341.76 ms 56.78 ms
acc307e 455.04 ms 492.26 ms 37.22 ms
3e5ee37 317.56 ms 366.84 ms 49.28 ms
333903e 332.76 ms 406.86 ms 74.10 ms
1a93825 347.31 ms 424.54 ms 77.23 ms

App size

Revision Plain With Sentry Diff
04db237 5.94 MiB 6.95 MiB 1.01 MiB
b47809a 5.94 MiB 6.96 MiB 1.02 MiB
68677de 6.06 MiB 7.10 MiB 1.04 MiB
6daa837 6.34 MiB 7.29 MiB 970.37 KiB
9a604e8 6.49 MiB 7.57 MiB 1.08 MiB
322aa66 5.94 MiB 6.92 MiB 1005.75 KiB
acc307e 6.49 MiB 7.56 MiB 1.08 MiB
3e5ee37 5.94 MiB 6.92 MiB 1001.19 KiB
333903e 6.06 MiB 7.10 MiB 1.04 MiB
1a93825 6.27 MiB 7.20 MiB 956.36 KiB

Previous results on branch: enha/ttfd-tracking-imporvements

Startup times

Revision Plain With Sentry Diff
22dfd2b 452.07 ms 511.98 ms 59.91 ms
f4ecdff 489.02 ms 561.08 ms 72.06 ms
13c4582 426.02 ms 493.63 ms 67.61 ms
b4bfadb 444.74 ms 519.98 ms 75.23 ms
7f5d8b4 472.94 ms 517.72 ms 44.78 ms
abf0025 504.36 ms 558.93 ms 54.57 ms
4aca1fa 463.57 ms 513.39 ms 49.83 ms
6ab10aa 481.67 ms 505.76 ms 24.09 ms
129b785 527.02 ms 528.60 ms 1.58 ms
082b145 449.61 ms 500.54 ms 50.93 ms

App size

Revision Plain With Sentry Diff
22dfd2b 6.44 MiB 7.43 MiB 1011.88 KiB
f4ecdff 6.44 MiB 7.43 MiB 1009.83 KiB
13c4582 6.44 MiB 7.43 MiB 1012.17 KiB
b4bfadb 6.44 MiB 7.43 MiB 1010.10 KiB
7f5d8b4 6.54 MiB 7.53 MiB 1015.03 KiB
abf0025 6.44 MiB 7.43 MiB 1012.19 KiB
4aca1fa 6.44 MiB 7.43 MiB 1011.88 KiB
6ab10aa 6.44 MiB 7.43 MiB 1012.18 KiB
129b785 6.44 MiB 7.43 MiB 1012.19 KiB
082b145 6.54 MiB 7.53 MiB 1015.05 KiB

Copy link
Contributor

@buenaflor buenaflor left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe there's still the issue of the async calls not being awaited - finish and start time to display in didPush

@buenaflor
Copy link
Contributor

as discussed let's find a more user friendly way to solve this. perhaps through a widget

@denrase denrase requested a review from buenaflor April 17, 2025 13:11
@buenaflor
Copy link
Contributor

As discussed let's try to use the spanId similar to react native

Copy link
Contributor

@buenaflor buenaflor left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like the approach manual and widget approach!

let's try and figure out how to handle the root transactions.

maybe it makes sense to have a central place where the navigator and the app start fetches the transaction from

@denrase denrase requested a review from buenaflor May 6, 2025 11:36
@denrase denrase requested a review from buenaflor May 6, 2025 14:20
@buenaflor
Copy link
Contributor

buenaflor commented Jun 17, 2025

@denrase I've done some tests on Android and Web

✅ TTFD reported correctly when navigating to screen and reportFullyDisplayed() is called

✅ TTFD auto finishes after timeout (default 30s)

✅ TTFD in progress in Screen A, navigate to Screen B, then Screen A TTFD finishes async - should not finish TTFD of Screen B

✅ StatelessWidget auto-reporting - TTFD reported immediately for StatelessWidget and should be the same as TTID

✅ Multiple reportFullyDisplayed() calls - Only first call counts, subsequent calls ignored

✅ Late reportFullyDisplayed() call - Call after 30s timeout should be ignored

🚫 Navigate from Screen A to Screen B where Screen A does not do reportFullyDisplayed but Screen B does
* Expected outcome: screen B has successful TTFD, Screen A should be deadline_exceeded
* Actual outcome: screen B and A have deadline_exceeded on Android
* For some reason on Web this works fine but not on Android

✅ TTFD disabled doesn’t track

@denrase
Copy link
Collaborator Author

denrase commented Jun 17, 2025

@buenaflor Fixed, we called clear one too many times, and also after async calls. So with this race condition it would clear the transactionId right before we'd get the display reference.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

TTFD improvements
3 participants