Skip to content

Commit 7609dca

Browse files
romtsnjas-kaslizokm
authored
feat(replay): Mobile Replay performance overhead (#11989)
* feat(replay): Mobile Replay performance overhead * Fix links * Update docs/product/explore/session-replay/mobile/performance-overhead.mdx Co-authored-by: Jasmin <[email protected]> * Update docs/platforms/react-native/session-replay/performance-overhead.mdx Co-authored-by: Jasmin <[email protected]> * Update docs/product/explore/session-replay/mobile/performance-overhead.mdx Co-authored-by: Jasmin <[email protected]> * Update docs/product/explore/session-replay/mobile/performance-overhead.mdx Co-authored-by: Jasmin <[email protected]> * Update docs/product/explore/session-replay/mobile/performance-overhead.mdx Co-authored-by: Jasmin <[email protected]> * Update docs/platforms/apple/guides/ios/session-replay/performance-overhead.mdx Co-authored-by: Jasmin <[email protected]> * Update docs/product/explore/session-replay/mobile/performance-overhead.mdx Co-authored-by: Jasmin <[email protected]> * Update docs/product/explore/session-replay/mobile/performance-overhead.mdx Co-authored-by: Jasmin <[email protected]> * Update docs/product/explore/session-replay/mobile/performance-overhead.mdx Co-authored-by: Jasmin <[email protected]> * Update docs/product/explore/session-replay/mobile/performance-overhead.mdx Co-authored-by: Jasmin <[email protected]> * Update docs/product/explore/session-replay/mobile/performance-overhead.mdx Co-authored-by: Jasmin <[email protected]> * Update docs/product/explore/session-replay/mobile/performance-overhead.mdx * Address PR feedback * Address PR feedback * Update docs/platforms/android/session-replay/performance-overhead.mdx Co-authored-by: Liza Mock <[email protected]> * Update docs/product/explore/session-replay/mobile/performance-overhead.mdx Co-authored-by: Liza Mock <[email protected]> * Update docs/product/explore/session-replay/mobile/performance-overhead.mdx Co-authored-by: Liza Mock <[email protected]> * Update docs/product/explore/session-replay/mobile/performance-overhead.mdx Co-authored-by: Liza Mock <[email protected]> * Update docs/product/explore/session-replay/mobile/performance-overhead.mdx Co-authored-by: Liza Mock <[email protected]> * Update docs/product/explore/session-replay/mobile/performance-overhead.mdx Co-authored-by: Liza Mock <[email protected]> * Update docs/product/explore/session-replay/mobile/performance-overhead.mdx Co-authored-by: Liza Mock <[email protected]> * Update docs/product/explore/session-replay/mobile/performance-overhead.mdx Co-authored-by: Liza Mock <[email protected]> * Update docs/product/explore/session-replay/mobile/performance-overhead.mdx Co-authored-by: Liza Mock <[email protected]> * Update docs/platforms/react-native/session-replay/performance-overhead.mdx Co-authored-by: Liza Mock <[email protected]> * Update docs/platforms/react-native/session-replay/performance-overhead.mdx Co-authored-by: Liza Mock <[email protected]> * Update docs/platforms/react-native/session-replay/performance-overhead.mdx Co-authored-by: Liza Mock <[email protected]> * Update docs/platforms/react-native/session-replay/performance-overhead.mdx Co-authored-by: Liza Mock <[email protected]> * Update docs/platforms/apple/guides/ios/session-replay/performance-overhead.mdx Co-authored-by: Liza Mock <[email protected]> * Update docs/platforms/apple/guides/ios/session-replay/performance-overhead.mdx Co-authored-by: Liza Mock <[email protected]> * Update docs/platforms/apple/guides/ios/session-replay/performance-overhead.mdx Co-authored-by: Liza Mock <[email protected]> * Update docs/platforms/android/session-replay/performance-overhead.mdx Co-authored-by: Liza Mock <[email protected]> * Update docs/platforms/android/session-replay/performance-overhead.mdx Co-authored-by: Liza Mock <[email protected]> * Update docs/platforms/android/session-replay/performance-overhead.mdx Co-authored-by: Liza Mock <[email protected]> * Update docs/platforms/react-native/session-replay/performance-overhead.mdx --------- Co-authored-by: Jasmin <[email protected]> Co-authored-by: Liza Mock <[email protected]>
1 parent 3e71dad commit 7609dca

File tree

4 files changed

+179
-0
lines changed

4 files changed

+179
-0
lines changed
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
---
2+
title: Performance Overhead
3+
sidebar_order: 5502
4+
notSupported:
5+
description: "Learn about how enabling Session Replay impacts the performance of your application."
6+
---
7+
8+
If you're considering enabling Session Replay, it's important to first understand the potential performance impact to your app. While accurate metrics require realistic testing where you apply typical access patterns and correlate the results with your business metrics, to provide a baseline, we measured the overhead using the open-source [Pocket Casts](https://github.com/Automattic/pocket-casts-android) app.
9+
10+
You can learn more about the various optimizations implemented in the Android Replay SDK in the [Replay Performance Overhead](/product/explore/session-replay/mobile/performance-overhead/) docs.
11+
12+
## Benchmarking the Android Replay SDK
13+
14+
The Pocket Casts app offers a diverse mix of components, including Fragments, Activities, and Jetpack Compose screens, making it an ideal candidate for testing. Here's how the benchmarks were conducted:
15+
16+
- **Configuration:** Full masking was enabled, and optimized release builds were used.
17+
- **User Flow:** The same flow was executed 10 times to ensure consistency.
18+
- **Real-World Representation:** This approach closely mirrors performance in real-world scenarios.
19+
20+
The benchmarks were run on a Pixel 2XL with Android 11.
21+
22+
### Results
23+
Below are the results of the benchmarking tests, presented as median values to reflect typical overhead.
24+
25+
| Metric | Sentry SDK only | Sentry + Replay SDK |
26+
| -------------------------------- | --------------- | ------------------- |
27+
| FPS | 55 fps | 54 fps |
28+
| Memory | 255 MB | 265 MB |
29+
| CPU | 36% | 42% |
30+
| App Startup Time (Cold) | 1533.35 ms | 1539.55 ms |
31+
| Main Thread Time | n/a | 20ms |
32+
| Network Bandwidth | n/a | 35 KB |
33+
34+
35+
36+
<Note>
37+
38+
Jetpack Compose view hierarchies may be slower to snapshot initially due to ART optimizations, compared to the traditional Android View System. But their performance improves as execution progresses.
39+
40+
</Note>
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
---
2+
title: Performance Overhead
3+
sidebar_order: 5502
4+
notSupported:
5+
description: "Learn about how enabling Session Replay impacts the performance of your application."
6+
---
7+
8+
If you're considering enabling Session Replay, it's important to first understand the potential performance impact to your app. While accurate metrics require realistic testing where you apply typical access patterns and correlate the results with your business metrics, to provide a baseline, we measured the overhead using the open-source [Pocket Casts](https://github.com/Automattic/pocket-casts-ios) app.
9+
10+
You can learn more about the various performance overhead optimizations implemented in the iOS Replay SDK in the [Replay Performance Overhead](/product/explore/session-replay/mobile/performance-overhead/) docs.
11+
12+
## Benchmarking the iOS Replay SDK
13+
14+
The Pocket Casts app offers a diverse mix of components, including Fragments, Activities, and Jetpack Compose screens, making it an ideal candidate for testing. Here's how the benchmarks were conducted:
15+
- **Configuration:** Full masking was enabled, and optimized release builds were used.
16+
- **User Flow:** The same flow was executed 10 times to ensure consistency.
17+
- **Real-World Representation:** This approach closely mirrors performance in real-world scenarios.
18+
19+
The benchmarks were run on an iPhone 14 Pro.
20+
21+
### Results
22+
Below are the results of the benchmarking tests, presented as median values to reflect typical overhead.
23+
24+
25+
| Metric | Sentry SDK only | Sentry + Replay SDK |
26+
| -------------------------------- | --------------- | ------------------- |
27+
| FPS | 55 fps | 53 fps |
28+
| Memory | 102 MB | 121 MB |
29+
| CPU | 4% | 13% |
30+
| App Startup Time (Cold) | 1264.80 ms | 1265 ms |
31+
| Main Thread Time | n/a | 43ms |
32+
| Network Bandwidth | n/a | 50 KB |
33+
34+
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
---
2+
title: Performance Overhead
3+
sidebar_order: 5502
4+
notSupported:
5+
description: "Learn about how enabling Session Replay impacts the performance of your application."
6+
---
7+
8+
If you're considering enabling Session Replay, it's important to first understand the potential performance impact to your app. While accurate metrics require realistic testing where you apply typical access patterns and correlate the results with your business metrics, to provide a baseline, we measured the overhead using the open-source Pocket Casts app.
9+
10+
You can learn more about the various optimizations implemented in the React Native Replay SDK in the [Replay Performance Overhead](/product/explore/session-replay/mobile/performance-overhead/) docs.
11+
12+
The React Native Replay SDK is a lightweight wrapper for the native iOS and Android SDKs, so its overhead is minimal and doesn't require separate measurement. Below are the benchmark results for each platform.
13+
14+
We measured the overhead using the [Pocket Casts iOS](https://github.com/Automattic/pocket-casts-ios) and [Pocket Casts Android](https://github.com/Automattic/pocket-casts-android) open-source apps. Each includes a diverse set of components such as ViewControllers and SwiftUI screens.
15+
16+
Here's how the benchmarks were conducted:
17+
18+
- **Configuration:** Full masking was enabled, and optimized release builds were used.
19+
- **User Flow:** The same flow was executed 10 times to ensure consistency.
20+
- **Real-World Representation:** This approach closely mirrors performance in real-world scenarios.
21+
22+
The benchmarks were run on an iPhone 14 Pro and a Pixel 2XL.
23+
24+
## iOS
25+
26+
| Metric | Sentry SDK only | Sentry + Replay SDK |
27+
| -------------------------------- | --------------- | ------------------- |
28+
| FPS | 55 fps | 53 fps |
29+
| Memory | 102 MB | 121 MB |
30+
| CPU | 4% | 13% |
31+
| App Startup Time (Cold) | 1264.80 ms | 1265 ms |
32+
| Main Thread Time | n/a | 43ms |
33+
| Network Bandwidth | n/a | 50 KB |
34+
35+
36+
37+
## Android
38+
39+
| Metric | Sentry SDK only | Sentry + Replay SDK |
40+
| -------------------------------- | --------------- | ------------------- |
41+
| FPS | 55 fps | 54 fps |
42+
| Memory | 255 MB | 265 MB |
43+
| CPU | 36% | 42% |
44+
| App Startup Time (Cold) | 1533.35 ms | 1539.55 ms |
45+
| Main Thread Time | n/a | 20ms |
46+
| Network Bandwidth | n/a | 35 KB |
47+
48+
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
---
2+
title: "Replay Performance Overhead"
3+
sidebar_order: 30
4+
description: "Learn about how enabling Session Replay impacts the performance of your application."
5+
---
6+
7+
Session Replay for mobile captures snapshots of the view hierarchy as well as a screenshot within the same frame once per second. These are compressed into a video file representing parts of the user’s session, then streamed to Sentry with trace identifiers, breadcrumbs, and other debugging information to reconstruct the full session.
8+
9+
To avoid impacting the host's app performance, Sentry minimizes CPU and memory usage by recording screenshots and view hierarchy non-intrusively and only when necessary, sending only essential bytes, and using low-latency ingestion endpoints geographically close to your end-users.
10+
11+
**For most mobile applications, the performance overhead of our Session Replay SDK will be imperceptible to end-users.**
12+
13+
## How Is Session Replay Optimized?
14+
15+
Sentry's Session Replay SDK takes several measures to avoid negatively impacting the performance of the screen on which it's running.
16+
17+
- The Session Replay SDK works by capturing screenshots, encoding them into small video segments and transmitting the content to Sentry’s servers. To reduce the amount of data transferred, multiple optimization strategies are employed:
18+
- The SDK captures at most one screenshot per second at a 1:1 pixel density (commonly referred to as `@1x` on iOS and `mdpi` on Android). This significantly speeds up the screenshot capture process while maintaining acceptable quality.
19+
- Screenshots are compressed into lossy `jpeg` files to reduce disk space usage and enable recovering of the last frames of a replay in the event of a crash or an ANR.
20+
- When sending a replay segment, the screenshots are further compressed into an `mp4` video file using `h.264` compression with a 75 kbps bitrate (the default behavior). This ensures a small payload size while preserving video quality. We observed nearly 5x reduction in size when compressing five screenshots into a video segment.
21+
- The video segment, along with other debugging information (such as breadcrumbs), is gzip-compressed on the client before transmission over HTTP. This compression is performed on a background thread, ensuring the application's main thread remains unaffected.
22+
- To minimize disk space usage, screenshots and video segment files are deleted from the disk upon successful upload.
23+
- Sentry’s event ingestion infrastructure uses [distributed Points-of-Presence (PoPs)](https://blog.sentry.io/2022/03/31/sentry-points-of-presence-how-we-built-a-distributed-ingestion/) which place ingestion servers around the world and close to your users. When a Session Replay event is transmitted, the user’s device connects and transmits the event payload to the closest PoP available for their region. This greatly reduces end-to-end latency and minimizes the amount of networking overhead placed on the device.
24+
- The SDK is built to gracefully downgrade when needed. In the event of sending too many replay events and hitting Sentry's rate limit, the SDK will disable recording to make sure the rate limit is respected. Once the rate limit is lifted, the SDK will continue recording.
25+
26+
## Factors in Performance Overhead
27+
28+
While the performance overhead of our Session Replay SDK will be imperceptible to end-users most of the time, it can vary based on the complexity of your application. If an application has screens with a deeply-nested view tree, there will be higher overhead compared to simpler screens (for example, Settings).
29+
30+
If the default masking behavior is enabled, network overhead will be further reduced because the screenshots have fewer pixels, resulting in smaller file sizes.
31+
32+
There are different stages in the lifecycle of a mobile application. Each has different performance characteristics. Below is a list of lifecycle stages and the most important performance metrics you should be aware of.
33+
34+
### App Start
35+
36+
There is virtually no overhead from the SDK during application start up. It performs only a few lightweight tasks, such as registering the necessary listeners for system events and scheduling a background thread for capturing.
37+
38+
### Main Thread
39+
40+
The SDK performs only the bare minimum on the main thread to capture a new frame for the replay (a screenshot and a view hierarchy snapshot) before immediately switching to a background thread for post-processing tasks. These tasks include masking screenshots, storing them in the disk cache, or encoding a video segment. This process occurs at most once per second, and it can be even less frequent depending on the frame rate setting.
41+
42+
The SDK also monitors view tree changes. If no changes have occurred since the last frame capture, it reuses the previously captured data, completely avoiding any work on the main thread.
43+
44+
### Capturing Touch Events
45+
46+
- Click/touch, swipe, and scroll events are incredibly small and fast to log, making the overhead negligible.
47+
- We optimize touch event recording by debouncing (limiting the frequency of events) and smoothing move events. This ensures a clear, detailed debugging experience without capturing excessive or redundant data.
48+
49+
## Measuring Performance Overhead
50+
51+
The only way to get accurate metrics is to measure performance overhead yourself. You can apply realistic access patterns against your own application, and correlate that to your own topline business metrics.
52+
53+
We measured the overhead of the Replay SDK on various open-source apps that have millions of users in production. For example, real-world apps that have a large set of different components and features such as [Bluesky](https://github.com/bluesky-social/social-app) and [Pocket Casts](https://github.com/Automattic/pocket-casts-android). You can check the results by going to the SDK docs below:
54+
55+
- [iOS](/platforms/apple/guides/ios/session-replay/performance-overhead/)
56+
- [Android](/platforms/android/session-replay/performance-overhead/)
57+
- [React Native](/platforms/react-native/session-replay/performance-overhead/)

0 commit comments

Comments
 (0)