Skip to content

chore(replay): Clarify network bandwidth and show how to reduce perf impact for mobile SDKs #12479

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

Merged
merged 8 commits into from
Jan 28, 2025
13 changes: 10 additions & 3 deletions docs/platforms/android/session-replay/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -116,12 +116,19 @@ Errors that happen while a replay is running will be linked to the replay, makin

## FAQ

Q: Why are parts of my replay not masked?
Q: **Why are parts of my replay not masked?**

A: Text fields, input fields, images, video players and webviews are all masked by default. Local assets, such as colors or vector drawables, aren't masked because the likelihood of these assets containing PII is low. If you encounter a view/component that should be masked by default, consider opening a [GitHub issue](https://github.com/getsentry/sentry-java/issues).

Q: Does Session Replay work with Jetpack Compose?
Q: **Does Session Replay work with Jetpack Compose?**

A: Yes, by default, text, input field, and image composables should be masked. Masking within embedded Android views (`AndroidView`)
in Compose isn't currently supported. If you encounter composables that aren't masked but should be, consider opening a [GitHub issue](https://github.com/getsentry/sentry-java/issues).

Q: What's the lowest version of Android supported?
Q: **What's the lowest version of Android supported?**

A: Recording only happens on Android 8 (API level 26) or newer. For devices running an older version, SDK features other than recording work normally.

Q: **Why is my issue missing a replay?**

A: An issue may be missing a replay because the user's device was [offline](/product/explore/session-replay/mobile#frequently-asked-questions) while `sessionSampleRate` specified, your project/organization was rate-limited, or (in rare cases) the device failed to capture the replay video.
33 changes: 31 additions & 2 deletions docs/platforms/android/session-replay/performance-overhead.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ notSupported:
description: "Learn about how enabling Session Replay impacts the performance of your application."
---

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.
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.

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.

Expand All @@ -29,7 +29,7 @@ Below are the results of the benchmarking tests, presented as median values to r
| CPU | 36% | 42% |
| App Startup Time (Cold) | 1533.35 ms | 1539.55 ms |
| Main Thread Time | n/a | 20ms |
| Network Bandwidth | n/a | 35 KB |
| Network Bandwidth | n/a | 7 KB/s of recording |



Expand All @@ -38,3 +38,32 @@ Below are the results of the benchmarking tests, presented as median values to r
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.

</Note>

## Reducing Performance Overhead

To minimize the performance impact of the Replay SDK, consider the following steps:

### Change Replay quality

Lowering the quality of captured screenshots and videos can significantly reduce CPU, memory, and network bandwidth usage. Here's how you can do it:

```kotlin
SentryAndroid.init(context) { options ->
// this will reduce screenshot compression to 10 and bitrate to 50kbps
options.sessionReplay.quality = SentryReplayQuality.LOW // defaults to MEDIUM
}
```

### Disable Replay for Low-End Devices

If the Replay SDK causes performance issues on lower-end devices (e.g., [this](https://github.com/getsentry/relay/blob/695b459e03481f7d799f07b2b901b140e5d5753d/relay-event-schema/src/protocol/device_class.rs#L21-L37) is how Sentry determines the device class), you can disable it specifically for those devices:

```kotlin
SentryAndroid.init(context) { options ->
options.dsn = "___PUBLIC_DSN___"
options.isDebug = true

options.sessionReplay.onErrorSampleRate = if (isLowEnd()) 0.0 else 1.0
options.sessionReplay.sessionSampleRate = if (isLowEnd()) 0.0 else 0.1
}
```
10 changes: 7 additions & 3 deletions docs/platforms/apple/guides/ios/session-replay/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -90,14 +90,18 @@ Errors that happen while a replay is running will be linked to the replay, makin

### FAQ

Q: Does Session Replay work with SwiftUI?
Q: **Does Session Replay work with SwiftUI?**

A: Yes. It works with both UIKit and SwiftUI.

Q: Why are parts of my replay not masked?
Q: **Why are parts of my replay not masked?**

A: Text views, input views, images, video players and webviews are all masked by default. Images with bundled assets aren't masked because the likelihood of these assets containing PII is low. If you encounter a view that should be masked by default, consider opening a [GitHub issue](https://github.com/getsentry/sentry-cocoa/issues).

Q: What's the lowest version of iOS supported?
Q: **What's the lowest version of iOS supported?**

A: Session Replay recording happens even on the lowest version supported by the Sentry SDK, which is aligend with appstore support.

Q: **Why is my issue missing a replay?**

A: An issue may be missing a replay because the user's device was [offline](/product/explore/session-replay/mobile#frequently-asked-questions) while `sessionSampleRate` specified, your project/organization was rate-limited, or (in rare cases) the device failed to capture the replay video.
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,33 @@ Below are the results of the benchmarking tests, presented as median values to r
| CPU | 4% | 13% |
| App Startup Time (Cold) | 1264.80 ms | 1265 ms |
| Main Thread Time | n/a | 43ms |
| Network Bandwidth | n/a | 50 KB |
| Network Bandwidth | n/a | 10 KB/s of recording|

## Reducing Performance Overhead

To minimize the performance impact of the Replay SDK, consider the following steps:

### Change Replay quality

Lowering the quality of captured screenshots and videos can significantly reduce CPU, memory, and network bandwidth usage. Here's how you can do it:

```swift
SentrySDK.start(configureOptions: { options in
// this will reduce screenshot compression to 10 and bitrate to 50kbps
options.sessionReplay.quality = .low // defaults to .medium
})
```

### Disable Replay for Low-End Devices

If the Replay SDK causes performance issues on lower-end devices, you can disable it specifically for those devices:

```kotlin
SentrySDK.start(configureOptions: { options in
options.dsn = "___PUBLIC_DSN___"
options.debug = true

options.sessionReplay.onErrorSampleRate = if isLowEnd() { 0.0 } else { 1.0 }
options.sessionReplay.sessionSampleRate = if isLowEnd() { 0.0 } else { 0.1 }
})
```
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ The benchmarks were run on an iPhone 14 Pro and a Pixel 2XL. Note that active Se
| CPU | 4% | 13% |
| App Startup Time (Cold) | 1264.80 ms | 1265 ms |
| Main Thread Time | n/a | 43ms |
| Network Bandwidth | n/a | 50 KB |
| Network Bandwidth | n/a | 10 KB/s of recording|



Expand All @@ -43,4 +43,4 @@ The benchmarks were run on an iPhone 14 Pro and a Pixel 2XL. Note that active Se
| CPU | 36% | 42% |
| App Startup Time (Cold) | 1533.35 ms | 1539.55 ms |
| Main Thread Time | n/a | 20ms |
| Network Bandwidth | n/a | 35 KB |
| Network Bandwidth | n/a | 7 KB/s of recording |
6 changes: 4 additions & 2 deletions docs/product/explore/session-replay/mobile/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,10 @@ Session Replay for Mobile is currently available for all plans. Check out our [p

**Are unhandled exceptions (for example, crashes) available as part of Session Replay for mobile?**

Currently, only handled exceptions will include a replay. We’re actively working on covering replays for crashes and ANRs and plan to support them for mobile in the coming weeks. Please refer to the SDK release notes for updates.
Yes, Session Replay for Mobile covers handled and unhandled exceptions as well as ANRs/App Hangs and native (NDK) crashes. Make sure to use the latest SDK version as mentioned in [SDKs Supported](#sdks-supported).

**How does Session Replay for mobile work if my app is offline?**

Session Replay for Mobile currently doesn’t work in offline mode. We plan on adding support for at least a few segments leading up to errors and crashes. Please subscribe to this [GitHub issue](https://github.com/getsentry/sentry/issues/68287) for updates.
Session Replay for Mobile currently supports offline mode only when `onErrorSampleRate` is specified. When an error happens, the SDK will capture the segment it recorded until that time (up to 30 seconds) and store it to disk. When the application comes back online, that segment will be sent to Sentry together with the error.

Currently `sessionSampleRate` is not supported in offline mode. Please subscribe to this [GitHub issue](https://github.com/getsentry/sentry/issues/68287) for updates.
Loading