Skip to content
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

tracesSampler becomes NSNull in iOS and the app cannot be started #1864

Closed
kitoko552 opened this issue Nov 1, 2021 · 1 comment · Fixed by #1872
Closed

tracesSampler becomes NSNull in iOS and the app cannot be started #1864

kitoko552 opened this issue Nov 1, 2021 · 1 comment · Fixed by #1872

Comments

@kitoko552
Copy link

kitoko552 commented Nov 1, 2021

Environment

How do you use Sentry?
Sentry SaaS (sentry.io)

Which SDK and version?
"@sentry/react-native": "^3.1.1"

Steps to Reproduce

  1. Sentry.init with tracesSampler and enable the automatic instrumentation of performance monitoring.
Sentry.init({
  dsn: Config.sentry.dns,
  tracesSampler: samplingContext => {
    return 0.2
  },
  integrations: [
    new Sentry.ReactNativeTracing({
      routingInstrumentation,
      enableAppStartTracking: false,
    }),
  ],
})
const navigationRef = createNavigationContainerRef()
const RootContents = React.memo(() => {
  return (
    <NavigationContainer
      ref={navigationRef}
      onReady={() => {
        routingInstrumentation.registerNavigationContainer(navigationRef)
      }}
      onStateChange={async state => {
        ...
      }}
    >
      ...
    </NavigationContainer>
  )
})
...
export default Sentry.wrap(Root) // Root uses RootContents
  1. Build the app on iOS

  2. The app crashes at here because _options.tracesSampler is NSNull

Expected Result

No Crashing and the app can be started correctly.

Actual Result

The stack trace is here.

  * thread #1, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=2, address=0x1e3dfa8e8)
    frame #0: 0x00000001e3dfa8e8 CoreFoundation`__kCFNull
  * frame #1: 0x0000000101b62134 {our_app_name}`-[SentryTracesSampler sample:](self=0x000000028187f9e0, _cmd="sample:", context=0x0000000281f03c00) at SentryTracesSampler.m:34:38
    frame #2: 0x0000000101b3ce14 {our_app_name}`-[SentryHub startTransactionWithContext:bindToScope:waitForChildren:customSamplingContext:](self=0x0000000283c7d630, _cmd="startTransactionWithContext:bindToScope:waitForChildren:customSamplingContext:", transactionContext=0x0000000283b24e40, bindToScope=YES, waitForChildren=YES, customSamplingContext=0 key/value pairs) at SentryHub.m:312:34
    frame #3: 0x0000000101b49cac {our_app_name}`-[SentryPerformanceTracker startSpanWithName:operation:](self=0x0000000281f038e0, _cmd="startSpanWithName:operation:", name=@"RNScreensViewController", operation=@"ui.load") at SentryPerformanceTracker.m:56:13
    frame #4: 0x0000000101b64e0c {our_app_name}`-[SentryUIViewControllerPerformanceTracker createTransaction:](self=0x0000000281d24b50, _cmd="createTransaction:", controller=0x0000000141215df0) at SentryUIViewControllerPerformanceTracker.m:78:18
    frame #5: 0x0000000101b64d34 {our_app_name}`__87-[SentryUIViewControllerPerformanceTracker viewControllerViewDidLoad:callbackToOrigin:]_block_invoke(.block_descriptor=0x000000016f33fb88) at SentryUIViewControllerPerformanceTracker.m:61:24
    frame #6: 0x0000000101b66008 {our_app_name}`-[SentryUIViewControllerPerformanceTracker limitOverride:target:callbackToOrigin:block:](self=0x0000000281d24b50, _cmd="limitOverride:target:callbackToOrigin:block:", description=@"viewDidLoad", viewController=0x0000000141215df0, callbackToOrigin=0x0000000101b676cc, block=0x0000000101b64d04) at SentryUIViewControllerPerformanceTracker.m:288:9
    frame #7: 0x0000000101b64cbc {our_app_name}`-[SentryUIViewControllerPerformanceTracker viewControllerViewDidLoad:callbackToOrigin:](self=0x0000000281d24b50, _cmd="viewControllerViewDidLoad:callbackToOrigin:", controller=0x0000000141215df0, callbackToOrigin=0x0000000101b676cc) at SentryUIViewControllerPerformanceTracker.m:57:5
    frame #8: 0x0000000101b676a8 {our_app_name}`__55-[SentryUIViewControllerSwizziling swizzleViewDidLoad:]_block_invoke_2(.block_descriptor=0x0000000281191080, self=0x0000000141215df0) at SentryUIViewControllerSwizziling.m:207:5
    frame #9: 0x000000019345f3a4 UIKitCore`-[UIViewController _sendViewDidLoadWithAppearanceProxyObjectTaggingEnabled] + 104
    frame #10: 0x000000019346395c UIKitCore`-[UIViewController loadViewIfRequired] + 928
    frame #11: 0x0000000193463d3c UIKitCore`-[UIViewController view] + 28
    frame #12: 0x000000010175cd70 {our_app_name}`-[RNSScreenContainerView setupController](self=0x00000001412139f0, _cmd="setupController") at RNSScreenContainer.m:60:32
    frame #13: 0x000000010175cca4 {our_app_name}`-[RNSScreenContainerView init](self=0x00000001412139f0, _cmd="init") at RNSScreenContainer.m:51:5
    frame #14: 0x000000010175e400 {our_app_name}`-[RNSScreenContainerManager view](self=0x0000000281d360c0, _cmd="view") at RNSScreenContainer.m:241:10
    frame #15: 0x0000000101790568 {our_app_name}`-[RCTComponentData createViewWithTag:rootTag:](self=0x0000000283c62080, _cmd="createViewWithTag:rootTag:", tag=0x948ae92eb8cd1839, rootTag=0x948ae92eb8cd0d39) at RCTComponentData.m:70:18
    frame #16: 0x0000000101880884 {our_app_name}`__50-[RCTUIManager createView:viewName:rootTag:props:]_block_invoke(.block_descriptor=0x0000000283c7f750) at RCTUIManager.m:998:30
    frame #17: 0x0000000101889f30 {our_app_name}`__RCTExecuteOnMainQueue_block_invoke(.block_descriptor=0x000000028118f5a0) at RCTUtils.m:261:7
    frame #18: 0x000000011068fae8 libdispatch.dylib`_dispatch_call_block_and_release + 24
    frame #19: 0x000000011069132c libdispatch.dylib`_dispatch_client_callout + 16
    frame #20: 0x000000011069f76c libdispatch.dylib`_dispatch_main_queue_callback_4CF + 972
    frame #21: 0x0000000191202998 CoreFoundation`__CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 12
    frame #22: 0x00000001911fcdf8 CoreFoundation`__CFRunLoopRun + 2528
    frame #23: 0x00000001911fbed0 CoreFoundation`CFRunLoopRunSpecific + 572
    frame #24: 0x0000000192459e64 Foundation`-[NSRunLoop(NSRunLoop) runMode:beforeDate:] + 228
    frame #25: 0x0000000192459d44 Foundation`-[NSRunLoop(NSRunLoop) runUntilDate:] + 88
    frame #26: 0x0000000101d2e6b8 {our_app_name}`+[RNSplashScreen show](self=RNSplashScreen, _cmd="show") at RNSplashScreen.m:31:9
    frame #27: 0x0000000100ac410c {our_app_name}`-[AppDelegate application:didFinishLaunchingWithOptions:](self=0x0000000281f6e940, _cmd="application:didFinishLaunchingWithOptions:", application=0x000000013ff05c60, launchOptions=0x0000000000000000) at AppDelegate.m:61:3
    frame #28: 0x0000000193b257b0 UIKitCore`-[UIApplication _handleDelegateCallbacksWithOptions:isSuspended:restoreState:] + 356
    frame #29: 0x0000000193b27150 UIKitCore`-[UIApplication _callInitializationDelegatesWithActions:forCanvas:payload:fromOriginatingProcess:] + 3432
    frame #30: 0x0000000193b2cf24 UIKitCore`-[UIApplication _runWithMainScene:transitionContext:completion:] + 1244
    frame #31: 0x00000001931ff8c0 UIKitCore`-[_UISceneLifecycleMultiplexer completeApplicationLaunchWithFBSScene:transitionContext:] + 148
    frame #32: 0x00000001937242c8 UIKitCore`_UIScenePerformActionsWithLifecycleActionMask + 96
    frame #33: 0x00000001932003a8 UIKitCore`__101-[_UISceneLifecycleMultiplexer _evalTransitionToSettings:fromSettings:forceExit:withTransitionStore:]_block_invoke + 196
    frame #34: 0x00000001931ffeb0 UIKitCore`-[_UISceneLifecycleMultiplexer _performBlock:withApplicationOfDeactivationReasons:fromReasons:] + 472
    frame #35: 0x00000001932001d4 UIKitCore`-[_UISceneLifecycleMultiplexer _evalTransitionToSettings:fromSettings:forceExit:withTransitionStore:] + 740
    frame #36: 0x00000001931ffa90 UIKitCore`-[_UISceneLifecycleMultiplexer uiScene:transitionedFromState:withTransitionContext:] + 336
    frame #37: 0x000000019320772c UIKitCore`__186-[_UIWindowSceneFBSSceneTransitionContextDrivenLifecycleSettingsDiffAction _performActionsForUIScene:withUpdatedFBSScene:settingsDiff:fromSettings:transitionContext:lifecycleActionType:]_block_invoke + 188
    frame #38: 0x000000019363e38c UIKitCore`+[BSAnimationSettings(UIKit) tryAnimatingWithSettings:actions:completion:] + 812
    frame #39: 0x000000019373c184 UIKitCore`_UISceneSettingsDiffActionPerformChangesWithTransitionContext + 248
    frame #40: 0x0000000193207420 UIKitCore`-[_UIWindowSceneFBSSceneTransitionContextDrivenLifecycleSettingsDiffAction _performActionsForUIScene:withUpdatedFBSScene:settingsDiff:fromSettings:transitionContext:lifecycleActionType:] + 356
    frame #41: 0x0000000193046ae4 UIKitCore`__64-[UIScene scene:didUpdateWithDiff:transitionContext:completion:]_block_invoke + 772
    frame #42: 0x0000000193045590 UIKitCore`-[UIScene _emitSceneSettingsUpdateResponseForCompletion:afterSceneUpdateWork:] + 248
    frame #43: 0x0000000193046730 UIKitCore`-[UIScene scene:didUpdateWithDiff:transitionContext:completion:] + 220
    frame #44: 0x0000000193b2b0fc UIKitCore`-[UIApplication workspace:didCreateScene:withTransitionContext:completion:] + 548
    frame #45: 0x0000000193664a84 UIKitCore`-[UIApplicationSceneClientAgent scene:didInitializeWithEvent:completion:] + 360
    frame #46: 0x000000019fd65d00 FrontBoardServices`-[FBSScene _callOutQueue_agent_didCreateWithTransitionContext:completion:] + 412
    frame #47: 0x000000019fd8d4fc FrontBoardServices`__94-[FBSWorkspaceScenesClient createWithSceneID:groupID:parameters:transitionContext:completion:]_block_invoke.176 + 100
    frame #48: 0x000000019fd73420 FrontBoardServices`-[FBSWorkspace _calloutQueue_executeCalloutFromSource:withBlock:] + 232
    frame #49: 0x000000019fd8d214 FrontBoardServices`__94-[FBSWorkspaceScenesClient createWithSceneID:groupID:parameters:transitionContext:completion:]_block_invoke + 312
    frame #50: 0x000000011069132c libdispatch.dylib`_dispatch_client_callout + 16
    frame #51: 0x00000001106947e4 libdispatch.dylib`_dispatch_block_invoke_direct + 232
    frame #52: 0x000000019fdb1e04 FrontBoardServices`__FBSSERIALQUEUE_IS_CALLING_OUT_TO_A_BLOCK__ + 40
    frame #53: 0x000000019fdb1acc FrontBoardServices`-[FBSSerialQueue _targetQueue_performNextIfPossible] + 404
    frame #54: 0x000000019fdb1fa0 FrontBoardServices`-[FBSSerialQueue _performNextFromRunLoopSource] + 28
    frame #55: 0x0000000191202fa8 CoreFoundation`__CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 24
    frame #56: 0x0000000191202ea8 CoreFoundation`__CFRunLoopDoSource0 + 204
    frame #57: 0x00000001912021fc CoreFoundation`__CFRunLoopDoSources0 + 256
    frame #58: 0x00000001911fc718 CoreFoundation`__CFRunLoopRun + 768
    frame #59: 0x00000001911fbed0 CoreFoundation`CFRunLoopRunSpecific + 572
    frame #60: 0x00000001a7945570 GraphicsServices`GSEventRunModal + 160
    frame #61: 0x0000000193b292d0 UIKitCore`-[UIApplication _run] + 1052
    frame #62: 0x0000000193b2e84c UIKitCore`UIApplicationMain + 164
    frame #63: 0x0000000100ac4980 {our_app_name}`main(argc=1, argv=0x000000016f343730) at main.m:7:12
    frame #64: 0x0000000190eda140 libdyld.dylib`start + 4

Screenshot 2021-11-01 18 29 36

Maybe the function type like tracesSampler can't be passed from React Native to the iOS module.

@kitoko552 kitoko552 changed the title tracesSampler becomes NSNULL in iOS and the app cannot be started tracesSampler becomes NSNull in iOS and the app cannot be started Nov 1, 2021
@marandaneto
Copy link
Contributor

@kitoko552 thanks for reporting, I've raised this issue on the Cocoa SDK getsentry/sentry-cocoa#1441

for now, a workaround is to avoid tracesSampler and instead use the tracesSampleRate, sorry about that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants