sentry-cocoa icon indicating copy to clipboard operation
sentry-cocoa copied to clipboard

Measure how long an app hang lasts

Open philipphofmann opened this issue 3 years ago • 4 comments

Description

The SDK doesn't track the duration of an app hang. The ANRTrackingIntegration immediately reports an app hang when it occurs. To get the exact duration, the SDK would need to write the app hang to disk first because the watchdog could kill the app anytime when it is blocking the main thread. When the ANR stops, which we detect here https://github.com/getsentry/sentry-cocoa/blob/b86953665ea253dabe1dced60d438f1a11f8934f/Sources/Sentry/SentryANRTrackingIntegration.m#L83-L86 the SDK could calculate the exact duration. When the watchdog kills the process cause of the app hang, the SDK would need to pick up the stored error and send it.

See also information in duplicate issue: https://github.com/getsentry/sentry-cocoa/issues/3556.

philipphofmann avatar Sep 23 '22 13:09 philipphofmann

I think we can't calculate the exact duration if the OS kills the app, but then we could report crash because of app hangs, which is also very nice.

To improve the calculation of duration we can look into the last frame from the frame tracker to now when the hang began.

brustolin avatar Sep 26 '22 13:09 brustolin

Yes, we can't calculate it when the OS kills the app, but we can calculate it if it doesn't.

philipphofmann avatar Sep 26 '22 14:09 philipphofmann

Maybe we could also detect if the user terminates the app because it kept hanging, and report this as a special type of app hang.

philipphofmann avatar Oct 05 '22 13:10 philipphofmann

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 🥀

github-actions[bot] avatar Oct 27 '22 00:10 github-actions[bot]