Skip to content

feat(replay): iOS: Adds enableExperimentalViewRenderer and enableFastViewRendering #4660

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
Mar 20, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,20 @@
- Add thread information to spans ([#4579](https://github.com/getsentry/sentry-react-native/pull/4579))
- Exposed `getDataFromUri` as a public API to retrieve data from a URI ([#4638](https://github.com/getsentry/sentry-react-native/pull/4638))
- Improve Warm App Start reporting on Android ([#4641](https://github.com/getsentry/sentry-react-native/pull/4641))
- Add experimental flags `enableExperimentalViewRenderer` and `enableFastViewRendering` to enable up to 5x times more performance in Session Replay on iOS ([#4660](https://github.com/getsentry/sentry-react-native/pull/4660))

```js
import * as Sentry from '@sentry/react-native';

Sentry.init({
integrations: [
Sentry.mobileReplayIntegration({
enableExperimentalViewRenderer: true,
enableFastViewRendering: true,
}),
],
});
```

### Fixes

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,15 @@ final class RNSentryReplayOptions: XCTestCase {
}

func assertAllDefaultReplayOptionsAreNotNil(replayOptions: [String: Any]) {
XCTAssertEqual(replayOptions.count, 6)
XCTAssertEqual(replayOptions.count, 8)
XCTAssertNotNil(replayOptions["sessionSampleRate"])
XCTAssertNotNil(replayOptions["errorSampleRate"])
XCTAssertNotNil(replayOptions["maskAllImages"])
XCTAssertNotNil(replayOptions["maskAllText"])
XCTAssertNotNil(replayOptions["maskedViewClasses"])
XCTAssertNotNil(replayOptions["sdkInfo"])
XCTAssertNotNil(replayOptions["enableExperimentalViewRenderer"])
XCTAssertNotNil(replayOptions["enableFastViewRendering"])
}

func testSessionSampleRate() {
Expand Down Expand Up @@ -164,5 +166,87 @@ final class RNSentryReplayOptions: XCTestCase {
XCTAssertEqual(actualOptions.sessionReplay.maskAllText, false)
XCTAssertEqual(actualOptions.sessionReplay.maskedViewClasses.count, 0)
}

func testEnableExperimentalViewRendererDefault() {
let optionsDict = ([
"dsn": "https://[email protected]/1234567",
"replaysOnErrorSampleRate": 0.75
] as NSDictionary).mutableCopy() as! NSMutableDictionary

RNSentryReplay.updateOptions(optionsDict)

let actualOptions = try! Options(dict: optionsDict as! [String: Any])

XCTAssertFalse(actualOptions.sessionReplay.enableExperimentalViewRenderer)
}

func testEnableExperimentalViewRendererTrue() {
let optionsDict = ([
"dsn": "https://[email protected]/1234567",
"replaysOnErrorSampleRate": 0.75,
"mobileReplayOptions": [ "enableExperimentalViewRenderer": true ]
] as NSDictionary).mutableCopy() as! NSMutableDictionary

RNSentryReplay.updateOptions(optionsDict)

let actualOptions = try! Options(dict: optionsDict as! [String: Any])

XCTAssertTrue(actualOptions.sessionReplay.enableExperimentalViewRenderer)
}

func testEnableExperimentalViewRendererFalse() {
let optionsDict = ([
"dsn": "https://[email protected]/1234567",
"replaysOnErrorSampleRate": 0.75,
"mobileReplayOptions": [ "enableExperimentalViewRenderer": false ]
] as NSDictionary).mutableCopy() as! NSMutableDictionary

RNSentryReplay.updateOptions(optionsDict)

let actualOptions = try! Options(dict: optionsDict as! [String: Any])

XCTAssertFalse(actualOptions.sessionReplay.enableExperimentalViewRenderer)
}

func testEnableFastViewRenderingDefault() {
let optionsDict = ([
"dsn": "https://[email protected]/1234567",
"replaysOnErrorSampleRate": 0.75
] as NSDictionary).mutableCopy() as! NSMutableDictionary

RNSentryReplay.updateOptions(optionsDict)

let actualOptions = try! Options(dict: optionsDict as! [String: Any])

XCTAssertFalse(actualOptions.sessionReplay.enableFastViewRendering)
}

func testEnableFastViewRenderingTrue() {
let optionsDict = ([
"dsn": "https://[email protected]/1234567",
"replaysOnErrorSampleRate": 0.75,
"mobileReplayOptions": [ "enableFastViewRendering": true ]
] as NSDictionary).mutableCopy() as! NSMutableDictionary

RNSentryReplay.updateOptions(optionsDict)

let actualOptions = try! Options(dict: optionsDict as! [String: Any])

XCTAssertTrue(actualOptions.sessionReplay.enableFastViewRendering)
}

func testEnableFastViewRenderingFalse() {
let optionsDict = ([
"dsn": "https://[email protected]/1234567",
"replaysOnErrorSampleRate": 0.75,
"mobileReplayOptions": [ "enableFastViewRendering": false ]
] as NSDictionary).mutableCopy() as! NSMutableDictionary

RNSentryReplay.updateOptions(optionsDict)

let actualOptions = try! Options(dict: optionsDict as! [String: Any])

XCTAssertFalse(actualOptions.sessionReplay.enableFastViewRendering)
}

}
3 changes: 3 additions & 0 deletions packages/core/ios/RNSentryReplay.mm
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ + (void)updateOptions:(NSMutableDictionary *)options
@"errorSampleRate" : options[@"replaysOnErrorSampleRate"] ?: [NSNull null],
@"maskAllImages" : replayOptions[@"maskAllImages"] ?: [NSNull null],
@"maskAllText" : replayOptions[@"maskAllText"] ?: [NSNull null],
@"enableExperimentalViewRenderer" : replayOptions[@"enableExperimentalViewRenderer"]
?: [NSNull null],
@"enableFastViewRendering" : replayOptions[@"enableFastViewRendering"] ?: [NSNull null],
@"maskedViewClasses" : [RNSentryReplay getReplayRNRedactClasses:replayOptions],
@"sdkInfo" :
@ { @"name" : REACT_NATIVE_SDK_NAME, @"version" : REACT_NATIVE_SDK_PACKAGE_VERSION }
Expand Down
27 changes: 27 additions & 0 deletions packages/core/src/js/replay/mobilereplay.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,39 @@ export interface MobileReplayOptions {
* @default true
*/
maskAllVectors?: boolean;

/**
* Enables the up to 5x faster experimental view renderer used by the Session Replay integration on iOS.
*
* Enabling this flag will reduce the amount of time it takes to render each frame of the session replay on the main thread, therefore reducing
* interruptions and visual lag.
*
* - Experiment: This is an experimental feature and is therefore disabled by default.
*
* @default false
*/
enableExperimentalViewRenderer?: boolean;

/**
* Enables up to 5x faster but incomplete view rendering used by the Session Replay integration on iOS.
*
* Enabling this flag will reduce the amount of time it takes to render each frame of the session replay on the main thread, therefore reducing
* interruptions and visual lag.
*
* - Note: This flag can only be used together with `enableExperimentalViewRenderer` with up to 20% faster render times.
* - Experiment: This is an experimental feature and is therefore disabled by default.
*
* @default false
*/
enableFastViewRendering?: boolean;
}

const defaultOptions: Required<MobileReplayOptions> = {
maskAllText: true,
maskAllImages: true,
maskAllVectors: true,
enableExperimentalViewRenderer: false,
enableFastViewRendering: false,
};

type MobileReplayIntegration = Integration & {
Expand Down
2 changes: 2 additions & 0 deletions samples/react-native/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,8 @@ Sentry.init({
maskAllImages: true,
maskAllVectors: true,
maskAllText: true,
enableExperimentalViewRenderer: true,
enableFastViewRendering: true,
}),
Sentry.appStartIntegration({
standalone: false,
Expand Down
Loading