Skip to content
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(V6): Implement fallback system to screens that aren't reporting on the native layer the time to display. #4042 #4189

Draft
wants to merge 9 commits into
base: main
Choose a base branch
from

Conversation

lucas-zimerman
Copy link
Collaborator

@lucas-zimerman lucas-zimerman commented Oct 17, 2024

This is a port of #4042 to V6

Tested on Android/iOS:
https://sentry-sdks.sentry.io/performance/trace/b0125a1564324d17b42156b5edbd4555/?dataset=transactions&field=title&field=project&field=user.display&field=timestamp&field=replayId&field=transaction.duration&fov=0%2C1910.000244140625&id=21705&name=&node=txn-ccda2e67a35c486d801315ad5c5020d9&node=txn-48c53c8b7b4a4335a12082cd81adba27&project=5428561&query=&queryDataset=transaction-like&sort=-timestamp&source=discover&statsPeriod=24h&timestamp=1729179000&topEvents=5&yAxis=count%28%29

https://sentry-sdks.sentry.io/performance/trace/514b002f17874570b2f016f0f78b9953/?dataset=transactions&field=title&field=project&field=user.display&field=timestamp&field=replayId&fov=0%2C75.13809204101562&id=21705&name=&node=span-87836929b3543124&node=txn-400cebc647684a688c5355197859dd40&project=5428561&query=&queryDataset=transaction-like&sort=-timestamp&source=discover&statsPeriod=1h&timestamp=1729198686&topEvents=5&yAxis=count%28%29

📢 Type of change

  • Bugfix
  • New feature
  • Enhancement
  • Refactoring

📜 Description

Context: the current native implementation doesn't always emit the required event in order to track the required time to display to be set on the time to display span.

To fix that, I introduced an additional fallback emitter, in short, it reuses the same flow by emitting the original event when the fallback emitter received the notification that the page was rendered and the original emitter didn't emit any event on the following 3 seconds.

With those changes, we have the following benefits:

  • Support for React Native web by also having the JavaScript fallback of requestAnimationFrame.
  • Greatly reduces the wrong time to display end timestamp by having a fallback when the original implementation doesn't return any event.
  • Fallback to the JavaScript implementation in case both Native emitters fail.

💡 Motivation and Context

Close #3934, #3809

💚 How did you test it?

The playground tab on our sample is a good case for testing, since it doesn't use navigation stack on it, the events on this condition are limited, not generating and required event by us in order to track the time to display.

I used it and other tabs to compare the difference between the original implementation and also requestAnimationFrame, and the time difference between each other was quite low:

1St Tab
JS: requestAnimationFrame, "newFrameTimestampInSeconds" is 1724293664.8300002
Original: InitAsync Event received {"newFrameTimestampInSeconds":1724293664.8179998}

2Nd Tab
JS: requestAnimationFrame, "newFrameTimestampInSeconds" is 1724293761.688
Original: InitAsync Event received {"newFrameTimestampInSeconds":1724293761.689}

3Rd Tab
JS: requestAnimationFrame, "newFrameTimestampInSeconds" is 1724293824.887
Original: Android didn't emit an event for this page so it wasn't measured

Before this change on the playground screen:
https://sentry-sdks.sentry.io/performance/trace/10bd4bf28052404592f408f3cf58175a/?dataset=transactions&field=title&field=event.type&field=project&field=user.display&field=timestamp&field=replayId&fov=0%2C15046.88916015625&id=21705&name=&node=trace-root&project=5428561&query=&queryDataset=transaction-like&sort=-timestamp&source=discover&statsPeriod=1h&timestamp=1724358725&topEvents=5&yAxis=count%28%29

After this change on the playground screen:
https://sentry-sdks.sentry.io/performance/trace/8cb478b4370e444fa4a7b9be778d51ab/?dataset=transactions&field=title&field=event.type&field=project&field=user.display&field=timestamp&field=replayId&fov=0%2C235&id=21705&name=&node=txn-b5a8ba18aa254fe79743133baf9071b2&project=5428561&query=&queryDataset=transaction-like&sort=-timestamp&source=discover&statsPeriod=1h&timestamp=1724359145&topEvents=5&yAxis=count%28%29

📝 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
  • All tests passing
  • No breaking changes

🔮 Next steps

Copy link
Contributor

github-actions bot commented Oct 17, 2024

iOS (legacy) Performance metrics 🚀

  Plain With Sentry Diff
Startup time 1221.92 ms 1220.52 ms -1.40 ms
Size 2.36 MiB 3.10 MiB 753.25 KiB

Baseline results on branch: main

Startup times

Revision Plain With Sentry Diff
ac41368+dirty 1226.65 ms 1237.90 ms 11.24 ms
62a750b+dirty 1216.60 ms 1229.14 ms 12.54 ms
baa882f+dirty 1218.00 ms 1227.04 ms 9.04 ms
d361d38+dirty 1246.04 ms 1267.12 ms 21.08 ms
4cc5c27+dirty 1211.45 ms 1214.60 ms 3.16 ms
148f924+dirty 1214.76 ms 1215.73 ms 0.97 ms
8ae23a7+dirty 1230.02 ms 1227.62 ms -2.40 ms
31fcca2+dirty 1209.17 ms 1216.21 ms 7.04 ms
0db0c72+dirty 1275.02 ms 1285.84 ms 10.82 ms
3ffcddd+dirty 1244.47 ms 1264.14 ms 19.67 ms

App size

Revision Plain With Sentry Diff
ac41368+dirty 2.36 MiB 3.14 MiB 793.46 KiB
62a750b+dirty 2.36 MiB 2.92 MiB 570.00 KiB
baa882f+dirty 2.36 MiB 3.08 MiB 731.91 KiB
d361d38+dirty 2.36 MiB 2.85 MiB 499.84 KiB
4cc5c27+dirty 2.36 MiB 3.04 MiB 698.52 KiB
148f924+dirty 2.36 MiB 3.04 MiB 696.25 KiB
8ae23a7+dirty 2.36 MiB 3.10 MiB 752.42 KiB
31fcca2+dirty 2.36 MiB 2.90 MiB 552.95 KiB
0db0c72+dirty 2.36 MiB 2.84 MiB 487.01 KiB
3ffcddd+dirty 2.36 MiB 2.84 MiB 489.60 KiB

Previous results on branch: fix/v6-fallback-main

Startup times

Revision Plain With Sentry Diff
505e572+dirty 1226.98 ms 1231.87 ms 4.90 ms

App size

Revision Plain With Sentry Diff
505e572+dirty 2.36 MiB 3.10 MiB 753.25 KiB

Copy link
Contributor

github-actions bot commented Oct 17, 2024

iOS (new) Performance metrics 🚀

  Plain With Sentry Diff
Startup time 1238.24 ms 1237.67 ms -0.57 ms
Size 2.92 MiB 3.66 MiB 758.50 KiB

Baseline results on branch: main

Startup times

Revision Plain With Sentry Diff
ac41368+dirty 1226.69 ms 1229.96 ms 3.27 ms
62a750b+dirty 1228.12 ms 1230.53 ms 2.41 ms
baa882f+dirty 1235.48 ms 1229.02 ms -6.46 ms
d361d38+dirty 1272.96 ms 1291.70 ms 18.74 ms
4cc5c27+dirty 1220.43 ms 1215.13 ms -5.30 ms
148f924+dirty 1220.72 ms 1221.30 ms 0.58 ms
8ae23a7+dirty 1233.67 ms 1229.52 ms -4.15 ms
31fcca2+dirty 1222.04 ms 1226.51 ms 4.47 ms
0db0c72+dirty 1258.88 ms 1262.52 ms 3.64 ms
3ffcddd+dirty 1272.22 ms 1273.98 ms 1.76 ms

App size

Revision Plain With Sentry Diff
ac41368+dirty 2.92 MiB 3.69 MiB 794.29 KiB
62a750b+dirty 2.92 MiB 3.48 MiB 575.59 KiB
baa882f+dirty 2.92 MiB 3.64 MiB 738.56 KiB
d361d38+dirty 2.92 MiB 3.41 MiB 503.57 KiB
4cc5c27+dirty 2.92 MiB 3.61 MiB 705.47 KiB
148f924+dirty 2.92 MiB 3.60 MiB 701.88 KiB
8ae23a7+dirty 2.92 MiB 3.66 MiB 757.67 KiB
31fcca2+dirty 2.92 MiB 3.46 MiB 557.31 KiB
0db0c72+dirty 2.92 MiB 3.40 MiB 492.71 KiB
3ffcddd+dirty 2.92 MiB 3.40 MiB 494.39 KiB

Previous results on branch: fix/v6-fallback-main

Startup times

Revision Plain With Sentry Diff
505e572+dirty 1244.94 ms 1244.90 ms -0.04 ms

App size

Revision Plain With Sentry Diff
505e572+dirty 2.92 MiB 3.66 MiB 758.51 KiB

Copy link
Contributor

Android (legacy) Performance metrics 🚀

  Plain With Sentry Diff
Startup time 442.88 ms 455.37 ms 12.49 ms
Size 17.74 MiB 20.07 MiB 2.34 MiB

Baseline results on branch: main

Startup times

Revision Plain With Sentry Diff
34aba08 328.10 ms 342.84 ms 14.74 ms
8ae23a7 526.83 ms 513.38 ms -13.45 ms
abb7058 370.27 ms 389.58 ms 19.31 ms
e73f4ed+dirty 332.96 ms 354.33 ms 21.37 ms
62a750b 395.96 ms 423.36 ms 27.41 ms
31fcca2 391.22 ms 414.78 ms 23.56 ms
fe13591 478.92 ms 480.84 ms 1.92 ms
76d1baf+dirty 335.72 ms 355.52 ms 19.80 ms
5a22220 412.38 ms 447.35 ms 34.97 ms
8900e1a+dirty 430.68 ms 456.13 ms 25.44 ms

App size

Revision Plain With Sentry Diff
34aba08 17.73 MiB 19.80 MiB 2.07 MiB
8ae23a7 17.74 MiB 20.07 MiB 2.34 MiB
abb7058 17.73 MiB 19.83 MiB 2.10 MiB
e73f4ed+dirty 17.73 MiB 20.04 MiB 2.31 MiB
62a750b 17.73 MiB 19.93 MiB 2.20 MiB
31fcca2 17.73 MiB 19.90 MiB 2.17 MiB
fe13591 17.74 MiB 20.07 MiB 2.34 MiB
76d1baf+dirty 17.73 MiB 20.04 MiB 2.31 MiB
5a22220 17.73 MiB 19.93 MiB 2.20 MiB
8900e1a+dirty 17.73 MiB 19.75 MiB 2.01 MiB

Copy link
Contributor

Android (new) Performance metrics 🚀

  Plain With Sentry Diff
Startup time 379.47 ms 394.30 ms 14.83 ms
Size 7.15 MiB 8.35 MiB 1.20 MiB

Baseline results on branch: main

Startup times

Revision Plain With Sentry Diff
80b2ce3+dirty 271.29 ms 316.47 ms 45.18 ms
5446992+dirty 371.61 ms 390.00 ms 18.39 ms
31fcca2+dirty 366.64 ms 395.78 ms 29.14 ms
457e29f+dirty 591.49 ms 612.96 ms 21.47 ms
e73f4ed+dirty 262.98 ms 311.02 ms 48.04 ms
fe13591+dirty 539.51 ms 597.92 ms 58.40 ms
ad6c299+dirty 336.47 ms 362.89 ms 26.42 ms
148f924+dirty 347.36 ms 389.13 ms 41.77 ms
b1e8712+dirty 322.55 ms 331.84 ms 9.29 ms
6e8584e+dirty 383.37 ms 400.84 ms 17.47 ms

App size

Revision Plain With Sentry Diff
80b2ce3+dirty 7.15 MiB 8.04 MiB 911.02 KiB
5446992+dirty 7.15 MiB 8.12 MiB 999.45 KiB
31fcca2+dirty 7.15 MiB 8.18 MiB 1.03 MiB
457e29f+dirty 7.15 MiB 8.10 MiB 981.29 KiB
e73f4ed+dirty 7.15 MiB 8.09 MiB 965.94 KiB
fe13591+dirty 7.15 MiB 8.35 MiB 1.20 MiB
ad6c299+dirty 7.15 MiB 8.04 MiB 912.17 KiB
148f924+dirty 7.15 MiB 8.21 MiB 1.07 MiB
b1e8712+dirty 7.15 MiB 8.04 MiB 912.27 KiB
6e8584e+dirty 7.15 MiB 8.13 MiB 1002.18 KiB

@lucas-zimerman lucas-zimerman marked this pull request as ready for review October 18, 2024 02:01
@lucas-zimerman lucas-zimerman marked this pull request as draft October 18, 2024 02:35
@lucas-zimerman
Copy link
Collaborator Author

moving to draft until CI is fixed

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.

Manual TTID/TTFD API times out
1 participant