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

Sentry.init locking up UI thread on launch

Open desmondmc opened this issue 1 year ago • 3 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.22.2

react-native version: 0.72.6

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/react-native)

Sentry.init({
  dsn: 'https://[email protected]/...'
  attachScreenshot: true, // Note removing this doesn't fix the issue.
});

I have the following issue:

When launching the app while in airplane mode, calling Sentry.init seems to lock up the UI thread. It doesn't happen every time. On my iPhone 14 Pro it's happening ~3-10 launches.

The issue started occurring when we updated from @sentry/react-native 5.17.0 to 5.22.2. We know it's definitely Sentry.init is causing the issue because when we remove it, the problem goes away.

We weren't able to reproduce the issue on debug versions of the app. We were only able to reproduce the issue on release versions.

Steps to reproduce:

  • Download and open our production iOS app
  • Put your phone in Airplane mode
  • Force close the app
  • Reopen it
  • Repeat until you see the app gets stuck on the Splash Screen.

Actual result:

The app locks up

Expected result:

The app launches as usual.

desmondmc avatar May 16 '24 12:05 desmondmc

Hi @desmondmc, thank you for the details,

would you be also able to reproduce it with a sample app for which you could share a source code?

Does it only happen on real device or also with Production build and Airplane/Offline mode on simulator?

krystofwoldrich avatar May 17 '24 10:05 krystofwoldrich

Thanks for the quick response @krystofwoldrich

would you be also able to reproduce it with a sample app for which you could share a source code?

I'll get back to you on this one, hopefully early next week. In the meantime, I'm sure you guys have a sample app internally, are you able to reproduce it?

Does it only happen on real device or also with Production build and Airplane/Offline mode on simulator?

I tested a release build on a simulator this morning and I wasn't able to reproduce it. Could be because (as far as I know) enabling Airplane mode isn't possible on the iOS simulator. Instead I disabled the wifi on my laptop and tried a bunch to see if I could get it to lock up, but it didn't.

desmondmc avatar May 17 '24 15:05 desmondmc

@krystofwoldrich

We were able to reproduce the issue with a release build of our app and the debugger attached. Looks like some kind of deadlock. You can see in this screenshot two threads are waiting on each other (one of which is the UI Thread). At a glance it looks like they're both accessing systemInfo? Maybe that NSURLSession never completes. Anyway, hope this helps get to the bottom of the issue:

deadlock

desmondmc avatar May 17 '24 15:05 desmondmc

@desmondmc thanks for the details! cc @brustolin @philipphofmann for some eyes from sentry-cocoa point of view. EDIT: possibly resolved by this PR for this issue on sentry-cocoa

kahest avatar May 27 '24 08:05 kahest

  • The cocoa changes will be included in https://github.com/getsentry/sentry-react-native/pull/3840

krystofwoldrich avatar May 27 '24 09:05 krystofwoldrich

5.22.3 fixed the issue! Thanks @kahest @krystofwoldrich

desmondmc avatar May 27 '24 15:05 desmondmc