Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 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 @@ -12,6 +12,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))

### 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.44.0 ([#4804](https://github.com/getsentry/sentry-react-native/pull/4804))
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,35 +177,35 @@ final class RNSentryReplayOptions: XCTestCase {

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

XCTAssertFalse(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() {
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"] ?: @YES,

@krystofwoldrich krystofwoldrich May 8, 2025

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would keep here ?: [NSNull null], to avoid baking as little logic as possible in here.

If null cocoa uses its default if not values is coming from RN (user or default).

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see sentry-cocoa set's it to false. That was an oversight, I've talked to @philprime and we will update this in cocoa.

So I would hold off this PR until cocoa hotfix release.

@antonis antonis May 8, 2025

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So I would hold off this PR until cocoa hotfix release.

Sounds good @krystofwoldrich 👍

I would keep here ?: [NSNull null], to avoid baking as little logic as possible in here.

Updated with 88280eb (The failing Native Tests / ios should pass when Cocoa is updated)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Related PR to fix the inconsistency in sentry-cocoa:
getsentry/sentry-cocoa#5210

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Cocoa change was merged with 8.50.2 #4830

@"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 @@ -100,7 +100,7 @@ Sentry.init({
maskAllImages: true,
maskAllVectors: true,
maskAllText: true,
enableExperimentalViewRenderer: true,
enableViewRendererV2: true,
enableFastViewRendering: true,
}),
Sentry.appStartIntegration({
Expand Down