From 3f0819240d95d863b52551ec16dbc1098c90b07c Mon Sep 17 00:00:00 2001 From: Archish Date: Tue, 3 Nov 2026 15:50:54 +0530 Subject: [PATCH 1/3] feat: add slowRenderingDetection config option Let React Native apps turn off native slowRenders and frozenRenders spans on iOS and Android. Leaving it unset keeps the current behaviour. --- CHANGELOG.md | 5 +++++ README.md | 11 ++++++++++ .../ConfigMapReader.java | 5 +++++ .../MiddlewareReactNativeModule.java | 3 +++ ios/MiddlewareReactNative.swift | 3 +++ src/__tests__/tracePropagation.test.ts | 21 +++++++++++++++++++ src/middlewareRum.ts | 9 ++++++++ src/native.ts | 1 + 8 files changed, 58 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 42731b6..5515e38 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,6 +16,11 @@ Maintaining this file: ## [Unreleased] +### Added + +- `slowRenderingDetection` configuration option. Set it to `false` to stop + `slowRenders` and `frozenRenders` spans on iOS and Android. + ## [2.3.1] - 2026-10-28 ### Fixed diff --git a/README.md b/README.md index c77760e..bd0d1f3 100644 --- a/README.md +++ b/README.md @@ -376,6 +376,17 @@ Views will get blurred hiding sensitive information in session recording. ``` +### Slow rendering detection + +The native SDK reports `slowRenders` and `frozenRenders` spans. To turn them off, pass `slowRenderingDetection: false`. Relaunch the app for the change to apply, because a JS reload keeps the native settings. + +```js +const MiddlewareConfig: ReactNativeConfiguration = { + // ... + slowRenderingDetection: false, +}; +``` + ## Contributing See the [contributing guide](CONTRIBUTING.md) to learn how to contribute to the repository and the development workflow. diff --git a/android/src/main/java/com/middlewarereactnative/ConfigMapReader.java b/android/src/main/java/com/middlewarereactnative/ConfigMapReader.java index d8494c7..68d5bf3 100644 --- a/android/src/main/java/com/middlewarereactnative/ConfigMapReader.java +++ b/android/src/main/java/com/middlewarereactnative/ConfigMapReader.java @@ -64,6 +64,10 @@ public boolean getCaptureResponseBodies() { return Boolean.TRUE.equals(Keys.CAPTURE_RESPONSE_BODIES.get(map)); } + public boolean isSlowRenderingDetectionEnabled() { + return !Boolean.FALSE.equals(Keys.SLOW_RENDERING_DETECTION.get(map)); + } + /** Lowercase header names; empty when unset. */ public List getIgnoreHeaders() { final List headers = new ArrayList<>(); @@ -97,5 +101,6 @@ private interface Keys { MapKey RECORDING_OPTIONS = new MapKey("recordingOptions"); BooleanKey CAPTURE_NETWORK_HEADERS = new BooleanKey("captureNetworkHeaders"); BooleanKey CAPTURE_RESPONSE_BODIES = new BooleanKey("captureResponseBodies"); + BooleanKey SLOW_RENDERING_DETECTION = new BooleanKey("slowRenderingDetection"); } } diff --git a/android/src/main/java/com/middlewarereactnative/MiddlewareReactNativeModule.java b/android/src/main/java/com/middlewarereactnative/MiddlewareReactNativeModule.java index 8a79aa6..beea328 100644 --- a/android/src/main/java/com/middlewarereactnative/MiddlewareReactNativeModule.java +++ b/android/src/main/java/com/middlewarereactnative/MiddlewareReactNativeModule.java @@ -140,6 +140,9 @@ public void initialize(ReadableMap configMap, Promise promise) { .setCaptureNetworkHeaders(mapReader.getCaptureNetworkHeaders()) .setCaptureResponseBodies(mapReader.getCaptureResponseBodies()) .setIgnoreHeaders(mapReader.getIgnoreHeaders()); + if (!mapReader.isSlowRenderingDetectionEnabled()) { + builder.disableSlowRenderingDetection(); + } final ReadableMap recordingOptionsMap = mapReader.getRecordingOptions(); if (recordingOptionsMap != null) { builder.setRecordingOptions(recordingOptionsFromMap(recordingOptionsMap)); diff --git a/ios/MiddlewareReactNative.swift b/ios/MiddlewareReactNative.swift index 3ce095a..a9cd679 100644 --- a/ios/MiddlewareReactNative.swift +++ b/ios/MiddlewareReactNative.swift @@ -65,6 +65,9 @@ class MiddlewareReactNative: NSObject { if let recordingOptions = config["recordingOptions"] as? [String: Any] { _ = builder.recordingOptions(mapRecordingOptions(recordingOptions)) } + if (config["slowRenderingDetection"] as? Bool) == false { + _ = builder.disableSlowRenderingDetection() + } // sysctl-derived, so it is unaffected by the dispatch below. let appStart = ((try? processStartTime()) ?? Date()).timeIntervalSince1970 * 1000 diff --git a/src/__tests__/tracePropagation.test.ts b/src/__tests__/tracePropagation.test.ts index f44477b..0e28192 100644 --- a/src/__tests__/tracePropagation.test.ts +++ b/src/__tests__/tracePropagation.test.ts @@ -182,3 +182,24 @@ describe('network capture options', () => { expect(native[0].ignoreHeaders).toEqual(['cookie']); }); }); + +describe('slowRenderingDetection', () => { + const nativeConfig = (config: Record) => { + const { rum, captured } = loadRum(); + rum.init({ ...CONFIG, ...config }); + return captured.native[0]; + }; + + it('leaves the native default in place when unset', () => { + expect(nativeConfig({})).not.toHaveProperty('slowRenderingDetection'); + }); + + it('passes an explicit value to native', () => { + expect(nativeConfig({ slowRenderingDetection: false })).toMatchObject({ + slowRenderingDetection: false, + }); + expect(nativeConfig({ slowRenderingDetection: true })).toMatchObject({ + slowRenderingDetection: true, + }); + }); +}); diff --git a/src/middlewareRum.ts b/src/middlewareRum.ts index 88dcac0..9edbd36 100644 --- a/src/middlewareRum.ts +++ b/src/middlewareRum.ts @@ -125,6 +125,12 @@ export interface ReactNativeConfiguration { * `captureNetworkHeaders` on. */ ignoreHeaders?: Set | string[]; + /** + * Set to `false` to stop the native SDK reporting `slowRenders` and + * `frozenRenders` spans. Enabled by default. Native settings are read once per + * process, so a JS reload does not change this; relaunch the app. + */ + slowRenderingDetection?: boolean; } export interface MiddlewareRumType { @@ -297,6 +303,9 @@ export const MiddlewareRum: MiddlewareRumType = { ...(config.recordingOptions !== undefined && { recordingOptions: config.recordingOptions, }), + ...(config.slowRenderingDetection !== undefined && { + slowRenderingDetection: config.slowRenderingDetection, + }), }; setGlobalAttributes(attributes); diff --git a/src/native.ts b/src/native.ts index 60108df..1d13e8e 100644 --- a/src/native.ts +++ b/src/native.ts @@ -105,6 +105,7 @@ export interface NativeSdKConfiguration { maskAllTextInputs?: boolean; maskAllImages?: boolean; }; + slowRenderingDetection?: boolean; } export type AppStartInfo = { From 4b8248e8ed8155ae39b1912b62d10d8c3fca11c4 Mon Sep 17 00:00:00 2001 From: Archish Date: Tue, 3 Nov 2026 17:19:16 +0530 Subject: [PATCH 2/3] chore: release 2.4.0 --- CHANGELOG.md | 2 ++ example/ios/Podfile.lock | 4 ++-- package.json | 2 +- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ddaae1e..a810051 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,6 +16,8 @@ Maintaining this file: ## [Unreleased] +## [2.4.0] - 2026-11-03 + ### Added - `slowRenderingDetection` configuration option. Set it to `false` to stop diff --git a/example/ios/Podfile.lock b/example/ios/Podfile.lock index e891af0..8fb6969 100644 --- a/example/ios/Podfile.lock +++ b/example/ios/Podfile.lock @@ -13,7 +13,7 @@ PODS: - ReactCommon/turbomodule/core (= 0.73.1) - fmt (6.2.1) - glog (0.3.5) - - middleware-react-native (2.3.1): + - middleware-react-native (2.4.0): - glog - MiddlewareRum (~> 2.3.1) - RCT-Folly (= 2022.05.16.00) @@ -1267,7 +1267,7 @@ SPEC CHECKSUMS: FBReactNativeSpec: df0ebe69acd14ce0be0269cf75b6e338a727259b fmt: ff9d55029c625d3757ed641535fd4a75fedc7ce9 glog: c5d68082e772fa1c511173d6b30a9de2c05a69a2 - middleware-react-native: e00b9051ee939e646dd44c58dc64dde55992ca1a + middleware-react-native: 7d9673e8864203e3091acee4f5220ed70bb6c4c5 MiddlewareRum: 90091571a8a411f82016ac5f98a228f9f9949fa5 PLCrashReporter: db59ef96fa3d25f3650040d02ec2798cffee75f2 RCT-Folly: cd21f1661364f975ae76b3308167ad66b09f53f5 diff --git a/package.json b/package.json index 47fd3f7..12358ac 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@middleware.io/middleware-react-native", - "version": "2.3.1", + "version": "2.4.0", "description": "Middleware React Native real user monitoring SDK", "main": "lib/commonjs/index", "module": "lib/module/index", From 0514c4d4c53bab60b067ec28d2c006c76550f47c Mon Sep 17 00:00:00 2001 From: Archish Date: Tue, 3 Nov 2026 17:21:07 +0530 Subject: [PATCH 3/3] chore: release 2.3.2 instead of 2.4.0 --- CHANGELOG.md | 2 +- example/ios/Podfile.lock | 4 ++-- package.json | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a810051..abce977 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,7 +16,7 @@ Maintaining this file: ## [Unreleased] -## [2.4.0] - 2026-11-03 +## [2.3.2] - 2026-11-03 ### Added diff --git a/example/ios/Podfile.lock b/example/ios/Podfile.lock index 8fb6969..d88c4e3 100644 --- a/example/ios/Podfile.lock +++ b/example/ios/Podfile.lock @@ -13,7 +13,7 @@ PODS: - ReactCommon/turbomodule/core (= 0.73.1) - fmt (6.2.1) - glog (0.3.5) - - middleware-react-native (2.4.0): + - middleware-react-native (2.3.2): - glog - MiddlewareRum (~> 2.3.1) - RCT-Folly (= 2022.05.16.00) @@ -1267,7 +1267,7 @@ SPEC CHECKSUMS: FBReactNativeSpec: df0ebe69acd14ce0be0269cf75b6e338a727259b fmt: ff9d55029c625d3757ed641535fd4a75fedc7ce9 glog: c5d68082e772fa1c511173d6b30a9de2c05a69a2 - middleware-react-native: 7d9673e8864203e3091acee4f5220ed70bb6c4c5 + middleware-react-native: e669eab32b32f3f798ba150e043a92b719e7776b MiddlewareRum: 90091571a8a411f82016ac5f98a228f9f9949fa5 PLCrashReporter: db59ef96fa3d25f3650040d02ec2798cffee75f2 RCT-Folly: cd21f1661364f975ae76b3308167ad66b09f53f5 diff --git a/package.json b/package.json index 12358ac..45696f4 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@middleware.io/middleware-react-native", - "version": "2.4.0", + "version": "2.3.2", "description": "Middleware React Native real user monitoring SDK", "main": "lib/commonjs/index", "module": "lib/module/index",