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

App hang leads to falsely reported OOM #1645

Closed
philipphofmann opened this issue Jan 25, 2022 · 9 comments · Fixed by #1695
Closed

App hang leads to falsely reported OOM #1645

philipphofmann opened this issue Jan 25, 2022 · 9 comments · Fixed by #1695

Comments

@philipphofmann
Copy link
Member

Platform

iOS

Installed

CocoaPods

Version

7.9.0

Steps to Reproduce

  1. Block the main thread with something like
var i = 0
for _ in 0...1_000_000 {
    for _ in 0...1_000_000 {
        i += Int.random(in: 0...10)
        i -= 1
    }
}
  1. Manually kill the app
  2. Launch the app again

Expected Result

No OOM, but instead an app hang, which the SDK doesn't support at the moment.

Actual Result

The SDK falsely reports an OOM.

@philipphofmann philipphofmann changed the title App App hang leads to falsely reported OOM Jan 25, 2022
@philipphofmann
Copy link
Member Author

We could use a CFRunLoopObserver to identify if the main thread hanged to create an event for app hangs and also to avoid reporting OOMs. It is worth noting the watchdog also terminates an app if it's not responsive for a while.

@philipphofmann
Copy link
Member Author

We have some code that could help us here from the private Specto GH repository. Worth noting that this didn't run in production yet.

@philipphofmann
Copy link
Member Author

This is related to #1052.

@philipphofmann
Copy link
Member Author

philipphofmann commented Jan 26, 2022

Please also update the docs added with this PR.

@philipphofmann philipphofmann self-assigned this Jan 26, 2022
@philipphofmann
Copy link
Member Author

Ideally, we need to add a feature for app hangs when fixing this bug. Not reporting app hangs as OOMs without an app hang feature is even worse, in my opinion. If you have a spike in app hangs now, you at least get OOMs. Otherwise, you wouldn't get any data in Sentry.

@owjsub
Copy link

owjsub commented Jan 28, 2022

Does sentry performance monitoring catch app hangs?

@bruno-garcia
Copy link
Member

@owjsub These hangs reported as OOM happened when the app is killed. OOM detection happens when the app start:

"Why did the app not close gracefully in the last run"? If the SDK believes it was due to OOM, it raises the event. But sometimes the app was hanging and got killed (for example, by the user swiping up).

So it's still an issue, and not really detected by the performance product since the app was killed and the transaction that was happening was lost. One potential feature is to store ongoing transactions to disk. And in the event of a crash, (due to OOM, hang, or anything else) we can capture that transaction to get an idea of what was happening. At least know what screen was loaded, and what span was open.

Persisting transactions might add in overhead so we need to investigate this further.

@github-actions
Copy link

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 label it Status: Backlog or Status: In Progress, I will leave it alone ... forever!


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

@bruno-garcia
Copy link
Member

As suggested by @souredoutlook, please add an opt-out such as enableAppHangTracking

philipphofmann added a commit that referenced this issue Mar 15, 2022
The OOM logic falsely detected ANRs as OOMs. This is fixed now by
adding a tracker for ANRs, which doesn't report ANR events to
Sentry yet.

Fixes GH-1645
philipphofmann added a commit that referenced this issue Mar 17, 2022
The OOM logic falsely detected ANRs as OOMs. This is fixed now by
adding a tracker for ANRs, which doesn't report ANR events to
Sentry yet.

Fixes GH-1645

Co-authored-by: Bruno Garcia <bruno@brunogarcia.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants