Skip to content

Freeze Time

Gleb edited this page Jan 23, 2024 · 3 revisions

Rendering performance (Freeze Time)

To ensure that a user's interaction with an app is smooth, the app should render frames in under 16ms to achieve 60 frames per second (on most of the devices). If the frame rendering time exceeds 16ms then the system is forced to skip frames and the user will perceive stuttering in the app. The state of rendering performance is defined by the key metric:

  • Freeze Time - is a total time of freezing UI due to rendering of the slow frames per screen (or app) session.

Freeze Time

There are 3 main factors that impact on how bad the rendering performance is:

  • Freeze duration - identifies how long it takes to render a single slow frame. The longer it takes, the more noticeable performance problem is (e.g. frame that renders for 500ms looks much worse than the frame that renders for 32ms).
  • Freezes count or freeze frequency - identifies how many or how often users experience slow frames. The more often users experience the same slow frame with the same freeze duration the worse it looks.

In the illustration above we see 6 frames: 3 frames are good and 3 frames have freezes. That means that 3 good frames were rendered within 16ms and 3 other frames have freezes of different durations (we calculate freeze duration as a difference between actual frame duration and 16ms of target frame duration). To calculate total freeze time we need to summarize durations of all freezes happen on the screen.

Freeze Time can be the same with the different patterns: 1 freeze with 1000ms, 100 freezes with 10ms. Also, freeze time can increase without any additional change just by increased session duration: if every cell on a screen generates some slow frame, when user scrolls more there is more freeze time generated.

To catch such situations we are also providing 2 additional metrics:

  • Freeze Count - total count of slow frames (slower than 16ms) during screen session. To see if the pattern of freezes changes.
  • Session Duration - screen session duration. To see if session duration changed which might cause freeze time changes.

Implementation

We have per-screen monitoring (RenderingMetricsReceiver) and app-level freeze time monitoring (AppRenderingMetricsReceiver). Both of them received the same structure RenderingMetrics. But screen level receives it after viewWillDisappear event, app level receives it few seconds after freeze time generated, with some throttling mechanism, not to receive it too often.

Clone this wiki locally