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

Know when slow and frozen frames occurred during a transaction

Open philipphofmann opened this issue 3 years ago • 4 comments

Description

Currently, the SDK attaches slow and frozen frames to transactions. The problem is that the users don't know when these slow and frozen occurred during the transaction. We could attach the slow and frozen frames to individual spans or we could add timing information as proposed in https://github.com/getsentry/sentry-cocoa/pull/1910, but then Sentry would need to do some work to add this somehow to the transactions. We could even add spans for slow and frozen frames.

Maybe only add to UI spans, because there could be two spans running at the same time. Furthermore, slow and frozen frames might not really make sense for file IO, DB, or network spans.

philipphofmann avatar Jun 22 '22 13:06 philipphofmann

We decided to create spans when a slow or frozen frame occurs.

brustolin avatar Jun 29 '22 13:06 brustolin

Wait for https://github.com/getsentry/sentry-cocoa/pull/1910 to get merged before tackling this PR because it tracks the timestamps of slow and frozen frames.

philipphofmann avatar Jul 04 '22 07:07 philipphofmann

FrameTimestamps are stored here https://github.com/getsentry/sentry-cocoa/blob/62ea01495e24ec722ebdf2aed5b95da89e3f1a73/Sources/Sentry/SentryFramesTracker.m#L31

Tracer adds them to the profile here https://github.com/getsentry/sentry-cocoa/blob/62ea01495e24ec722ebdf2aed5b95da89e3f1a73/Sources/Sentry/SentryTracer.m#L439-L441

philipphofmann avatar Jul 14 '22 13:07 philipphofmann

@philipphofmann You explained the thinking behind this last week but now that I am looking into this, I am not sure how you wanted this to work.

  • We want to add a span for every slow or frozen frame to the transaction, right?
  • frameTimestamps contains the start_timestamp and end_timestamp of any slow or frozen frame. But how do we know if the frame was slow or frozen? If I loop over frameTimestamps, I have no clue what kind of frame it was? Adding a span with the text "slow or frozen frame" seems a bit weird?
  • frameTimestamps doesn't seem to hold actual timestamps (as in, dates), but something different. So how can we create spans with timestamps, so that they are shown in the UI at the correct place?

Can we go over this together? Thanks!

kevinrenskers avatar Jul 20 '22 12:07 kevinrenskers

But how do we know if the frame was slow or frozen?

We talked about this in profiling but decided at the time we could compute this server-side, since we also send the expected framerates (as a time series since it can change on modern devices). But it would be easy to track them in separate arrays from each of these callsites: here and here.

And just so I understand what's ultimately being requested, I imagine we'd want to display something like this?

Screen Shot 2022-08-16 at 11 15 54 AM

armcknight avatar Aug 16 '22 19:08 armcknight

Check my PR where I had a working implementation using those callsites: https://github.com/getsentry/sentry-cocoa/pull/2028. But ultimately it doesn't result in a very useful thing in the Sentry UI, see comments in that PR as well.

kevinrenskers avatar Aug 16 '22 19:08 kevinrenskers

We're closing this based on the result of #2028.

brustolin avatar Aug 17 '22 07:08 brustolin

Reopened because of https://github.com/getsentry/sentry-cocoa/pull/2028#issuecomment-1231854727

philipphofmann avatar Aug 30 '22 15:08 philipphofmann

After investigating this feature, it turned out that it is not that useful. If a lifecycle method needs 200 ms to complete, and we put a slow frame span below it, it doesn't add extra value because you can assume that already if you see that you have one slow frame. By just looking at the raw numbers of slow and frozen frames, you know that you have to fix something, and you should keep an eye on the spans that took the longest time.

philipphofmann avatar Sep 22 '22 12:09 philipphofmann