Skip to content

Session Replay crash: NSConcreteValue doubleValue in mapRedactRegion during RN navigation transitions #7810

Description

@NicholasJAlexander

Environment

  • @sentry/react-native: 7.11.0
  • sentry-cocoa (via Podfile.lock): 8.58.0
  • Expo SDK: 55
  • React Native: 0.83.x
  • iOS: 18.6.2
  • Device: iPhone 13 (iPhone13,2)
  • Architecture: New Architecture (Fabric)

Description

Fatal crash in SentryUIRedactBuilder.mapRedactRegion during Session Replay screenshot capture. The crash occurs when navigating between screens — specifically during the push transition animation from a search results screen to an event detail screen.

This appears to be the same class of bug as COCOA-1091 and #4558, but triggered by React Navigation transition animations rather than a specific view class like CameraUI or RCTVideo.

Stack Trace

NSInvalidArgumentException: -[NSConcreteValue doubleValue]: unrecognized selector sent to instance 0x12e68f150

SentrySessionReplay.newFrame (SentrySessionReplay.swift:237)
SentrySessionReplay.takeScreenshot (SentrySessionReplay.swift:378)
SentryViewPhotographer.image (SentryViewPhotographer.swift:41)
SentryUIRedactBuilder.redactRegionsFor (SentryUIRedactBuilder.swift:425)
SentryUIRedactBuilder.mapRedactRegion (SentryUIRedactBuilder.swift:588) [x30 recursive]
SentryUIRedactBuilder.mapRedactRegion (SentryUIRedactBuilder.swift:566)
CA::Layer::sublayers
CA::Layer::presentation_layer
-[CABasicAnimation applyForTime:presentationObject:modelObject:]
-[NSNumber(CAAnimatableValue) CA_interpolateValue:byFraction:]
__forwarding_prep_0___
___forwarding___
-[NSObject(NSObject) doesNotRecognizeSelector:]
objc_exception_throw

Root Cause

When mapRedactRegion traverses the view hierarchy via layer.sublayers, CoreAnimation resolves presentation layers. If any layer has an active CABasicAnimation whose fromValue/toValue is a boxed struct (NSConcreteValue wrapping CGRect, CGPoint, CATransform3D) instead of NSNumber, the interpolation code calls doubleValue on that value — which NSConcreteValue doesn't respond to.

This is a race condition: it only triggers when a non-scalar animation is actively running at the exact moment Session Replay captures a screenshot. Navigation push/pop transitions are the most common trigger since they animate position and transform properties (struct values).

Why excludedViewClasses doesn't help here

The excludedViewClasses API added in 8.58.0 (#7063) works for specific view classes like RCTVideo or CameraUI.ChromeSwiftUIView. But for navigation transitions, the offending animations are on RNSScreen / RNSNavigationController layers — excluding those would effectively disable replay for the entire app.

Suggested Fix

Wrap the layer.sublayers access (and/or the presentation layer resolution) in SentryUIRedactBuilder.mapRedactRegion with a @try/@catch for NSInvalidArgumentException. This would gracefully skip layers that crash during traversal without killing the app.

Something like:

@try {
    NSArray *sublayers = layer.sublayers;
    // ... traverse
} @catch (NSException *exception) {
    // Skip this layer — animation value type mismatch
}

Reproduction Context

  • User opens app → home feed
  • Navigates to search screen (keyboard appears)
  • Types a search query (incremental results load)
  • Taps a search result → push navigation to event detail screen
  • Crash during the push transition animation

Session Replay was active (replaysSessionSampleRate: 0.1, replaysOnErrorSampleRate: 1.0). The crash is handled: no, level: fatal — the app is force-killed by iOS.

Related Issues

  • COCOA-1091 — Same stack trace, same RN/Expo version, excludedViewClasses API added but doesn't generically fix it
  • #5647 — CameraUI variant, fixed by auto-excluding CameraUI.ChromeSwiftUIView
  • #4558SentryViewPhotographer crash during React Navigation transitions
  • RN-458 — Same NSConcreteValue doubleValue crash from RCTVideo

Metadata

Metadata

Assignees

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions