feat(performance): Add Time to Full Display and manual API for TTID
:loudspeaker: Type of change
- [x] New feature
:scroll: Description
This PR adds manual API for measuring TTID and TTFD.
TTID and TTFD use React Native Native Components, android.view.View on Android and UIView on iOS. This enables the SDK to reliably hook into the rendering loop and wait for the next frame after the native component is created.
Why the need for native components?
We tested exposing the hook for the next frame to JS runtime, which turned out unreliable. When waiting for the component to mount and receiving the mount event back JS and based on that starting listening for the next frame, depending on the JS loop, the listen for the next frame might be significantly (10s, 100s ms) delayed. This only works in ideal scenarios, when JS runtime starts the listen immediately after receiving the mount event.
What does the API look like?
When combined with auto instrumentation only the components are needed. The Time To Display is only measured when record=true, any consequent re-renders are ignored until a new activeSpan.
The Time To Display spans can be started manually.
const initialDisplaySpan = startTimeToInitialDisplaySpan();
const fullDisplaySpan = startTimeToFullDisplaySpan();
function MyComponent() {
return <View>
<TimeToInitialDisplay record={true} />
<TimeToFullDisplay record={false} />
</View>
}
:green_heart: How did you test it?
sample app, unit and integration tests
:pencil: Checklist
- [x] I reviewed submitted code
- [x] I added tests to verify changes
- [x] No new PII added or SDK only sends newly added PII if
sendDefaultPIIis enabled - [x] All tests passing
- [x] No breaking changes
:crystal_ball: Next steps
- [ ] Follow up PR with native implementation for new architecture
- [ ] Add the documentation
| 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 cbc51bfa93d7b28b25e3cf05de38bf4d654f6d61
Android (legacy) Performance metrics :rocket:
| Plain | With Sentry | Diff | |
|---|---|---|---|
| Startup time | 411.74 ms | 443.20 ms | 31.46 ms |
| Size | 17.73 MiB | 19.93 MiB | 2.19 MiB |
Baseline results on branch: main
Startup times
| Revision | Plain | With Sentry | Diff |
|---|---|---|---|
| abb7058e207628f7d3e5ebee6c410c2cf6c361f4 | 370.27 ms | 389.58 ms | 19.31 ms |
| 3ffcddd6248046202afca78f6b9af8e3f591202c | 302.92 ms | 315.80 ms | 12.88 ms |
| 8900e1acdc5e3dcbb40938d4ba5c2abad4cc86a4+dirty | 430.68 ms | 456.13 ms | 25.44 ms |
| d361d3886b2303280797f653160c781700570edf | 354.10 ms | 381.69 ms | 27.59 ms |
| 9a3ca655542f9224aa21b4838b439748a3043b4b+dirty | 326.93 ms | 330.14 ms | 3.21 ms |
| b1e87125f5dbad623a4e4293384e68e8f702cc19 | 462.11 ms | 465.71 ms | 3.60 ms |
| 25343377820b65409b646b44bc8e9bc9fbb51c8c | 394.15 ms | 415.12 ms | 20.97 ms |
| 34aba0802bf802288f91fada55c0b133252fe67f | 328.10 ms | 342.84 ms | 14.74 ms |
| 76d1bafa51ac0d20b127bc97b0f45201263636c3+dirty | 335.72 ms | 355.52 ms | 19.80 ms |
| 31fcca2b37834863733f6f21677efb4b7a490aa8 | 391.22 ms | 414.78 ms | 23.56 ms |
App size
| Revision | Plain | With Sentry | Diff |
|---|---|---|---|
| abb7058e207628f7d3e5ebee6c410c2cf6c361f4 | 17.73 MiB | 19.83 MiB | 2.10 MiB |
| 3ffcddd6248046202afca78f6b9af8e3f591202c | 17.73 MiB | 19.75 MiB | 2.02 MiB |
| 8900e1acdc5e3dcbb40938d4ba5c2abad4cc86a4+dirty | 17.73 MiB | 19.75 MiB | 2.01 MiB |
| d361d3886b2303280797f653160c781700570edf | 17.73 MiB | 19.81 MiB | 2.08 MiB |
| 9a3ca655542f9224aa21b4838b439748a3043b4b+dirty | 17.73 MiB | 20.04 MiB | 2.31 MiB |
| b1e87125f5dbad623a4e4293384e68e8f702cc19 | 17.73 MiB | 19.75 MiB | 2.02 MiB |
| 25343377820b65409b646b44bc8e9bc9fbb51c8c | 17.73 MiB | 19.84 MiB | 2.11 MiB |
| 34aba0802bf802288f91fada55c0b133252fe67f | 17.73 MiB | 19.80 MiB | 2.07 MiB |
| 76d1bafa51ac0d20b127bc97b0f45201263636c3+dirty | 17.73 MiB | 20.04 MiB | 2.31 MiB |
| 31fcca2b37834863733f6f21677efb4b7a490aa8 | 17.73 MiB | 19.90 MiB | 2.17 MiB |
Android (new) Performance metrics :rocket:
| Plain | With Sentry | Diff | |
|---|---|---|---|
| Startup time | 371.04 ms | 415.18 ms | 44.14 ms |
| Size | 7.15 MiB | 8.20 MiB | 1.05 MiB |
Baseline results on branch: main
Startup times
| Revision | Plain | With Sentry | Diff |
|---|---|---|---|
| 8900e1acdc5e3dcbb40938d4ba5c2abad4cc86a4+dirty | 371.40 ms | 377.70 ms | 6.31 ms |
| 80b2ce3d0ebe86bf1196944a2036912f6670295c+dirty | 271.29 ms | 316.47 ms | 45.18 ms |
| 9a3ca655542f9224aa21b4838b439748a3043b4b+dirty | 344.96 ms | 358.92 ms | 13.96 ms |
| d361d3886b2303280797f653160c781700570edf+dirty | 257.72 ms | 318.76 ms | 61.04 ms |
| 76d1bafa51ac0d20b127bc97b0f45201263636c3+dirty | 339.02 ms | 408.65 ms | 69.63 ms |
| 22e31b6ad7bd629bf078367aee82121c08977ded+dirty | 295.75 ms | 346.73 ms | 50.98 ms |
| d197b5c9ca10ac3f729d1b3ef805328665aa0895+dirty | 258.75 ms | 313.61 ms | 54.86 ms |
| 52a80311c249f8c654de5d063c8be172a2dc9e5a+dirty | 330.72 ms | 358.76 ms | 28.03 ms |
| dadc233f906b89b35cb320c3f7d1dfaf5db0cc5d+dirty | 363.19 ms | 370.37 ms | 7.18 ms |
| 31fcca2b37834863733f6f21677efb4b7a490aa8+dirty | 366.64 ms | 395.78 ms | 29.14 ms |
App size
| Revision | Plain | With Sentry | Diff |
|---|---|---|---|
| 8900e1acdc5e3dcbb40938d4ba5c2abad4cc86a4+dirty | 7.15 MiB | 8.03 MiB | 901.79 KiB |
| 80b2ce3d0ebe86bf1196944a2036912f6670295c+dirty | 7.15 MiB | 8.04 MiB | 911.02 KiB |
| 9a3ca655542f9224aa21b4838b439748a3043b4b+dirty | 7.15 MiB | 8.09 MiB | 962.83 KiB |
| d361d3886b2303280797f653160c781700570edf+dirty | 7.15 MiB | 8.08 MiB | 959.34 KiB |
| 76d1bafa51ac0d20b127bc97b0f45201263636c3+dirty | 7.15 MiB | 8.09 MiB | 964.41 KiB |
| 22e31b6ad7bd629bf078367aee82121c08977ded+dirty | 7.15 MiB | 8.10 MiB | 981.29 KiB |
| d197b5c9ca10ac3f729d1b3ef805328665aa0895+dirty | 7.15 MiB | 8.09 MiB | 962.72 KiB |
| 52a80311c249f8c654de5d063c8be172a2dc9e5a+dirty | 7.15 MiB | 8.09 MiB | 965.95 KiB |
| dadc233f906b89b35cb320c3f7d1dfaf5db0cc5d+dirty | 7.15 MiB | 8.04 MiB | 910.84 KiB |
| 31fcca2b37834863733f6f21677efb4b7a490aa8+dirty | 7.15 MiB | 8.18 MiB | 1.03 MiB |
iOS (legacy) Performance metrics :rocket:
| Plain | With Sentry | Diff | |
|---|---|---|---|
| Startup time | 1212.74 ms | 1218.19 ms | 5.45 ms |
| Size | 2.36 MiB | 2.92 MiB | 569.91 KiB |
iOS (new) Performance metrics :rocket:
| Plain | With Sentry | Diff | |
|---|---|---|---|
| Startup time | 1237.61 ms | 1239.88 ms | 2.27 ms |
| Size | 2.92 MiB | 3.48 MiB | 575.50 KiB |