Know when slow and frozen frames occurred during a transaction
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.
We decided to create spans when a slow or frozen frame occurs.
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.
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 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?
frameTimestampscontains thestart_timestampandend_timestampof any slow or frozen frame. But how do we know if the frame was slow or frozen? If I loop overframeTimestamps, I have no clue what kind of frame it was? Adding a span with the text "slow or frozen frame" seems a bit weird?frameTimestampsdoesn'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!
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?

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.
We're closing this based on the result of #2028.
Reopened because of https://github.com/getsentry/sentry-cocoa/pull/2028#issuecomment-1231854727
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.