sentry-react-native icon indicating copy to clipboard operation
sentry-react-native copied to clipboard

Catching native app launch crashes - "Symbol not found: (_JSGlobalContextSetInspectable)"

Open ldabiralai opened this issue 1 year ago • 8 comments

OS:

  • [ ] Windows
  • [x] MacOS
  • [ ] Linux

Platform:

  • [x] iOS
  • [ ] Android

SDK:

  • [x] @sentry/react-native (>= 1.0.0)
  • [ ] react-native-sentry (<= 0.43.2)

SDK version: 5.19.3

react-native version: 0.72.13

Are you using Expo?

  • [ ] Yes
  • [x] No

Are you using sentry.io or on-premise?

  • [x] sentry.io (SaaS)
  • [ ] on-premise

If you are using sentry.io, please post a link to your issue so we can take a look:

N/A

Configuration:

Sentry.init({
  dsn: '...',
  environment: '...',
  enableOutOfMemoryTracking: false,
  tracesSampleRate: 0,
  debug: !!__DEV__,
  ignoreErrors: [...],
  beforeBreadcrumb: excludeGraphQLFetch,
  release: '...',
});

I have the following issue:

We had an incident a couple of months ago that was causing our app to crash on startup. Unfortunately, this wasn't reported to us by Sentry as we're initialising sentry on the React side of our app, this was a native crash before Sentry was initialised. We want to ensure that we capture these kinds of errors in Sentry in the future.

For clarity, this was the error we faced: https://github.com/facebook/react-native/issues/44077

I've instrumented Sentry natively for both iOS & Android following the documentation, and have confirmed it's working when firing captureMessage​ natively.

However, when I reintroduce the bug linked above (downgraded to react-native 0.72.13 and disabled hermes) and then open the app on a device using iOS 14 (any version 16.3 and lower should work) it crashes but this crash is not fired to Sentry. It seems like this error may be happening even before Sentry is initialised here and thus not firing?

Is it possible to capture this kind of error in Sentry, perhaps there a way we can initialise Sentry even earlier?

Steps to reproduce:

  • Use react-native 0.72.13
  • Disable hermes
  • Instrument sentry natively
  • Run app on real device using iOS 14 (version 16.3 and lower should be fine, but I've tried on iOS 14 and verified)

Actual result:

App crashes but error is not reported to Sentry

Expected result:

App crash but error is reported to Sentry

ldabiralai avatar Jul 10 '24 16:07 ldabiralai

Hi @ldabiralai, I'm not familiar with that exact error, but if it happened before the Sentry init, we can't capture it.

Just to confirm, do you initialize Sentry on iOS like this:

@import Sentry;

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {

    [SentrySDK startWithConfigureOptions:^(SentryOptions *options) {
        options.dsn = @"dsn...";
    }];

    return YES;
}

krystofwoldrich avatar Jul 11 '24 14:07 krystofwoldrich

Hi @krystofwoldrich, thank you. Yes, this is how we are now initialising Sentry.

ldabiralai avatar Jul 17 '24 09:07 ldabiralai

Let's reproduce the issue and investigate if the crash get capture in our sample. If not let investigate why and if we could capture it.

krystofwoldrich avatar Aug 02 '24 12:08 krystofwoldrich

do we have the ios version? Because I'm seeing this error with ios 16

jveronezi avatar Sep 03 '24 15:09 jveronezi

Hi @jveronezi, we have no updates to the issue at the moment.

krystofwoldrich avatar Sep 04 '24 10:09 krystofwoldrich

I think this error has been fixed on React native v0.74.1

jveronezi avatar Sep 04 '24 16:09 jveronezi

Yes, it's fixed in new versions of React Native, but it'd be great to clarify if Sentry could have captured this for us so we could alert on it more easily.

ldabiralai avatar Sep 04 '24 17:09 ldabiralai

Yes, the issue was fixed on the RN native side, but we will still investigate, why this was not reported.

Preliminary it seems like the error happens before the Sentry.init mentioned in https://github.com/getsentry/sentry-react-native/issues/3939#issuecomment-2223019428

krystofwoldrich avatar Sep 06 '24 14:09 krystofwoldrich

Hi @krystofwoldrich, any updates on this one? we are having the same issue Sentry not be able to capture app launch exeptions, in our case it was another exception related to the minimum iOS supported version.

mostafabrazi avatar Nov 27 '24 16:11 mostafabrazi

Hi @mostafabrazi, thank you for the message,

do you initialize Sentry on iOS manually as mentioned in https://github.com/getsentry/sentry-react-native/issues/3939#issuecomment-2223019428 or do you initialize it only throught JS?

krystofwoldrich avatar Nov 28 '24 10:11 krystofwoldrich

Hi @krystofwoldrich After I initialised it manually objective c side, i was able to capture an unhandled exception, i posted my question here because in my first testing i had a false result because i didn't re-open the app after the crash, now i confirm the manual setup is fine. Thanks!

mostafabrazi avatar Nov 28 '24 14:11 mostafabrazi

One more question, If I initialized with properties such as sampleRate and tracesSampleRate in react native JS code, do I need to re-do it native side in case I am going with manual initialization after disabling autoInitializeNativeSdk

JS
Sentry.init({
...
  sampleRate: 0.2,
  tracesSampleRate: 0.005,
  autoInitializeNativeSdk: false, // manual initialization is enabled native side
});

and in

Obj-c
[SentrySDK startWithConfigureOptions:^(SentryOptions *options) {
   ....
    options.sampleRate = @0.5;
    options.tracesSampleRate = @0.5;
  }];

mostafabrazi avatar Nov 29 '24 20:11 mostafabrazi

Yes @mostafabrazi, that's is correct, you have to specify the options in both JS and Obj-C.

You might also want to disable performance (not set tracesSampleRate) in Obj-C, otherwise you would receive duplicate transactions for the native view controllers and React Native screens.

krystofwoldrich avatar Dec 02 '24 11:12 krystofwoldrich

I've tried to reproduce the error during JSCRuntime(JSGlobalContextRef ctx) init, and when the Sentry Cocoa SDK is initialized manually, as described in https://github.com/getsentry/sentry-react-native/issues/3939#issuecomment-2223019428, the error is sent by the SDK to Sentry on the next application start.

Example https://sentry-sdks.sentry.io/share/issue/4c298e22cafb4d74aeb083be9dbf4705/

krystofwoldrich avatar Mar 28 '25 16:03 krystofwoldrich