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

Report JS Loop stalls as Errors (similar to App Hangs on iOS)

Open rodolfoBee opened this issue 1 year ago • 5 comments

Platform:

  • [x] iOS
  • [ ] Android

SDK:

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

SDK version: 5.15.1

react-native version: 0.72.7

Are you using Expo?

  • [ ] Yes
  • [x] No

Are you using sentry.io or on-premise?

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

(@sentry/react-native)

Sentry.init({
  dsn: 'MY_DSN',
  debug:true
})

I have the following issue:

A user reported the app hanging but not event was sent to Sentry. As per docs:

There are many reasons why an app may become unresponsive, such as long-running code, infinite loop bugs, and so on. With app hang tracking you can detect and fix them.

I created an infinite loop to test it and no app hang events were sent. The same infinite loop works fine with Cocoa SDK.

Steps to reproduce:

  • Create a base react-native app
  • Add Sentry to it
  • Add the following button anywhere:
<Button
     onPress={() => {
         var i = 1;
          while (i > 0){i++;}
      }}
      title="LeLoop"
      color="#841584"
  />
  • run the app on ios

It is still possible to scroll through the app, but all other buttons no longer work as the app is still on the loop. But no event is sent.

Under which conditions is it expected for an event to be sent?

rodolfoBee avatar Dec 11 '23 12:12 rodolfoBee

Based on our recent conversations, thanks for taking the time to create the issue here, Rodolfo. Will subscribe and follow up on this.

yogendrajs avatar Dec 11 '23 13:12 yogendrajs

@rodolfoBee and @yogendrajs Thank you for the message.

The SDK currently reports App Hangs when the native UI thread hangs (users can't interact with the app, even scrolling doesn't work).

The JS loop hangs (stalls) are currently reported as a metric with Sentry Transactions.

I've marked this issue as a feature request we will discuss internally if and how to report JS Loop stalls as Errors.

krystofwoldrich avatar Dec 13 '23 10:12 krystofwoldrich

@krystofwoldrich understood, thanks. We've also used the React Native Tracing option within the Performance, but having trouble understanding how this metric will be recorded in the dashboard. Can you provide a screenshot or a sample metric displaying the same? Thanks

yogendrajs avatar Dec 13 '23 13:12 yogendrajs

When you open Transaction Detail you will see the stalls on the right side. Transactions are created based on screen names defined in navigation library you use.

Stall times are displayed in milliseconds.

Screenshot 2023-12-13 at 16 58 29

krystofwoldrich avatar Dec 13 '23 16:12 krystofwoldrich

Okay, all the stall-related numbers are always zero for me, it seems like it is because we don't use any of the mentioned navigation libraries directly.

yogendrajs avatar Dec 15 '23 07:12 yogendrajs