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

Sentry Watchdog causes a crashes writing to disk on the main thread #3770

Closed
4 of 9 tasks
sena-mike opened this issue Apr 20, 2024 · 5 comments
Closed
4 of 9 tasks

Sentry Watchdog causes a crashes writing to disk on the main thread #3770

sena-mike opened this issue Apr 20, 2024 · 5 comments

Comments

@sena-mike
Copy link

OS:

  • Windows
  • MacOS
  • Linux

Platform:

  • iOS
  • Android

SDK:

  • [X ] react-native-sentry (<= 0.43.2)

SDK version: 5.6.0

react-native version: 0.71.8

Are you using Expo?

  • Yes
  • No

Are you using sentry.io or on-premise?

  • sentry.io (SaaS)
  • on-premise

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

[Link to issue]

Configuration:

(@sentry/react-native)

Sentry.init({
  dsn: 'https://...@sentry.io/...'
  // other options
});

or

(react-native-sentry)

Sentry.config(
  'https://...@sentry.io/...'
  // other options
 ).install();

I have the following issue:

[Description]

We get sentry crashes coming to the foreground due to the iOS watchdog. It seems the root cause of this is that Sentry writes to SentryWatchdogTerminationScopeObserver on the main queue:

Exception Type:  EXC_CRASH (SIGKILL)
Exception Codes: 0x0000000000000000, 0x0000000000000000
Termination Reason: FRONTBOARD 2343432205 
<RBSTerminateContext| domain:10 code:0x8BADF00D explanation:scene-update watchdog transgression: app<com.teslamotors.TeslaApp(D7971437-C6F2-4AD9-8635-802AF30D96D7)>:6951 exhausted real (wall clock) time allowance of 10.00 seconds
ProcessVisibility: Background
ProcessState: Running
WatchdogEvent: scene-update
WatchdogVisibility: Background
WatchdogCPUStatistics: (
"Elapsed total CPU time (seconds): 34.040 (user 19.730, system 14.310), 57% CPU",
"Elapsed application CPU time (seconds): 18.800, 31% CPU"
) reportType:CrashLog maxTerminationResistance:Interactive>
Screenshot 2024-04-19 at 5 07 43 PM

This is because the RNSentry native module uses the main queue and no dispatches to a background queue or background thread happens.

Writing to the main thread while transitioning to the background may cause crashes.

@sena-mike
Copy link
Author

Other times the crash is in removeFileAtPath:
Screenshot 2024-04-19 at 5 12 26 PM

@kahest
Copy link
Member

kahest commented Apr 23, 2024

Hey @sena-mike thanks for the report and the context, we'll investigate! Does this happen randomly or do you have a specific way to reproduce this?

@philipphofmann
Copy link
Member

FYI, why the Cocoa SDK writes breadcrumbs to disk on the calling thread, which can be the main thread (SDK docs):

The SDK adds breadcrumbs to watchdog termination events by appending the breadcrumbs to an open file, which should have a marginal impact on your app's performance. Still, it skips adding some frequently changing context to avoid extra I/O, such as free memory, free storage, device orientation, charging status, battery level, etc.

@sena-mike
Copy link
Author

Hey @sena-mike thanks for the report and the context, we'll investigate! Does this happen randomly or do you have a specific way to reproduce this?

We see this crash happen mostly in TestFlight distribution, however it doesn't happen consistently for all users. Notably TestFlight will alert users that the crash occurred with a system notification even when the app is terminated by the CPU watch dog in the background.

If you'd like to opt out of this feature, you can do so using options:
options.enableWatchdogTerminationTracking = false

Re the docs, it seems like opting out of watchdog termination tracking might prevent this from happening. Will investigate opting out on our end.

@getsantry
Copy link

getsantry bot commented May 22, 2024

This issue has gone three weeks without activity. In another week, I will close it.

But! If you comment or otherwise update it, I will reset the clock, and if you remove the label Waiting for: Community, I will leave it alone ... forever!


"A weed is but an unloved flower." ― Ella Wheeler Wilcox 🥀

@getsantry getsantry bot closed this as not planned Won't fix, can't repro, duplicate, stale May 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Archived in project
Archived in project
Development

No branches or pull requests

4 participants