Skip to content

ref(session-replay): iOS: Use enableViewRendererV2 instead of the dep… #4815

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 7 commits into from
May 15, 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
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@
- Expo Updates Context is passed to native after native init to be available for crashes ([#4808](https://github.com/getsentry/sentry-react-native/pull/4808))
- Expo Updates Context values should all be lowercase ([#4809](https://github.com/getsentry/sentry-react-native/pull/4809))

### Changes

- Renames `enableExperimentalViewRenderer` to `enableViewRendererV2` which is enabled by default for up to 5x times more performance in Session Replay on iOS ([#4815](https://github.com/getsentry/sentry-react-native/pull/4815))

### Dependencies

- Bump CLI from v2.43.1 to v2.45.0 ([#4804](https://github.com/getsentry/sentry-react-native/pull/4804), [#4818](https://github.com/getsentry/sentry-react-native/pull/4818))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ final class RNSentryReplayOptions: XCTestCase {
XCTAssertNotNil(replayOptions["maskAllText"])
XCTAssertNotNil(replayOptions["maskedViewClasses"])
XCTAssertNotNil(replayOptions["sdkInfo"])
XCTAssertNotNil(replayOptions["enableExperimentalViewRenderer"])
XCTAssertNotNil(replayOptions["enableViewRendererV2"])
XCTAssertNotNil(replayOptions["enableFastViewRendering"])
}

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

func testEnableViewRendererV2Default() {
let optionsDict = ([
"dsn": "https://abc@def.ingest.sentry.io/1234567",
"replaysOnErrorSampleRate": 0.75
Expand All @@ -177,37 +177,37 @@ final class RNSentryReplayOptions: XCTestCase {

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

XCTAssertTrue(actualOptions.sessionReplay.enableExperimentalViewRenderer)
XCTAssertTrue(actualOptions.sessionReplay.enableViewRendererV2)
}
func testEnableExperimentalViewRendererTrue() {

func testEnableViewRendererV2True() {
let optionsDict = ([
"dsn": "https://abc@def.ingest.sentry.io/1234567",
"replaysOnErrorSampleRate": 0.75,
"mobileReplayOptions": [ "enableExperimentalViewRenderer": true ]
"mobileReplayOptions": [ "enableViewRendererV2": true ]
] as NSDictionary).mutableCopy() as! NSMutableDictionary

RNSentryReplay.updateOptions(optionsDict)

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

XCTAssertTrue(actualOptions.sessionReplay.enableExperimentalViewRenderer)
XCTAssertTrue(actualOptions.sessionReplay.enableViewRendererV2)
}
func testEnableExperimentalViewRendererFalse() {

func testEnableViewRendererV2False() {
let optionsDict = ([
"dsn": "https://abc@def.ingest.sentry.io/1234567",
"replaysOnErrorSampleRate": 0.75,
"mobileReplayOptions": [ "enableExperimentalViewRenderer": false ]
"mobileReplayOptions": [ "enableViewRendererV2": false ]
] as NSDictionary).mutableCopy() as! NSMutableDictionary

RNSentryReplay.updateOptions(optionsDict)

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

XCTAssertFalse(actualOptions.sessionReplay.enableExperimentalViewRenderer)
XCTAssertFalse(actualOptions.sessionReplay.enableViewRendererV2)
}

func testEnableFastViewRenderingDefault() {
let optionsDict = ([
"dsn": "https://abc@def.ingest.sentry.io/1234567",
Expand All @@ -220,7 +220,7 @@ final class RNSentryReplayOptions: XCTestCase {

XCTAssertFalse(actualOptions.sessionReplay.enableFastViewRendering)
}

func testEnableFastViewRenderingTrue() {
let optionsDict = ([
"dsn": "https://abc@def.ingest.sentry.io/1234567",
Expand All @@ -234,7 +234,7 @@ final class RNSentryReplayOptions: XCTestCase {

XCTAssertTrue(actualOptions.sessionReplay.enableFastViewRendering)
}

func testEnableFastViewRenderingFalse() {
let optionsDict = ([
"dsn": "https://abc@def.ingest.sentry.io/1234567",
Expand Down
3 changes: 1 addition & 2 deletions packages/core/ios/RNSentryReplay.mm
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,7 @@ + (void)updateOptions:(NSMutableDictionary *)options
@"errorSampleRate" : options[@"replaysOnErrorSampleRate"] ?: [NSNull null],
@"maskAllImages" : replayOptions[@"maskAllImages"] ?: [NSNull null],
@"maskAllText" : replayOptions[@"maskAllText"] ?: [NSNull null],
@"enableExperimentalViewRenderer" : replayOptions[@"enableExperimentalViewRenderer"]
?: [NSNull null],
@"enableViewRendererV2" : replayOptions[@"enableViewRendererV2"] ?: [NSNull null],
@"enableFastViewRendering" : replayOptions[@"enableFastViewRendering"] ?: [NSNull null],
@"maskedViewClasses" : [RNSentryReplay getReplayRNRedactClasses:replayOptions],
@"sdkInfo" :
Expand Down
32 changes: 30 additions & 2 deletions packages/core/src/js/replay/mobilereplay.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,24 @@ export interface MobileReplayOptions {
*
* - Experiment: This is an experimental feature and is therefore disabled by default.
*
* @default false
* @deprecated Use `enableViewRendererV2` instead.
*/
enableExperimentalViewRenderer?: boolean;

/**
* Enables up to 5x faster new 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. [Our benchmarks](https://github.com/getsentry/sentry-cocoa/pull/4940) have shown a significant improvement of
* **up to 4-5x faster rendering** (reducing `~160ms` to `~36ms` per frame) on older devices.
*
* - Experiment: In case you are noticing issues with the new view renderer, please report the issue on [GitHub](https://github.com/getsentry/sentry-cocoa).
* Eventually, we will remove this feature flag and use the new view renderer by default.
*
* @default true
*/
enableViewRendererV2?: boolean;

/**
* Enables up to 5x faster but incomplete view rendering used by the Session Replay integration on iOS.
*
Expand All @@ -63,9 +77,23 @@ const defaultOptions: Required<MobileReplayOptions> = {
maskAllImages: true,
maskAllVectors: true,
enableExperimentalViewRenderer: false,
enableViewRendererV2: true,
enableFastViewRendering: false,
};

function mergeOptions(initOptions: Partial<MobileReplayOptions>): Required<MobileReplayOptions> {
const merged = {
...defaultOptions,
...initOptions,
};

if (initOptions.enableViewRendererV2 === undefined && initOptions.enableExperimentalViewRenderer !== undefined) {
merged.enableViewRendererV2 = initOptions.enableExperimentalViewRenderer;
}

return merged;
}

type MobileReplayIntegration = Integration & {
options: Required<MobileReplayOptions>;
};
Expand Down Expand Up @@ -100,7 +128,7 @@ export const mobileReplayIntegration = (initOptions: MobileReplayOptions = defau
return mobileReplayIntegrationNoop();
}

const options = { ...defaultOptions, ...initOptions };
const options = mergeOptions(initOptions);

async function processEvent(event: Event): Promise<Event> {
const hasException = event.exception && event.exception.values && event.exception.values.length > 0;
Expand Down
2 changes: 1 addition & 1 deletion samples/react-native/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ Sentry.init({
maskAllImages: true,
maskAllVectors: true,
maskAllText: true,
enableExperimentalViewRenderer: true,
enableViewRendererV2: true,
enableFastViewRendering: true,
}),
Sentry.appStartIntegration({
Expand Down
Loading