Slow and Frozen Frames and Frames Delay Instrumentation

Learn about slow and frozen frames and frame delay and how to track them using Sentry's Flutter SDK.

Unresponsive UI and animation hitches annoy users and degrade the user experience. This integration can help. Set it up and identify these problems in your app by tracking and showing slow frames, frozen frames, and frame delay metrics for spans. Learn more about frame delay here.

Frames tracking instrumentation is available on iOS, macOS and Android.

The frames tracking instrumentation measures frame metrics (slow frames, frozen frames, and frame delay) for each span. To calculate these metrics, we use a custom WidgetsFlutterBinding that measures the duration between handleBeginFrame and handleDrawFrame to determine each frame's render time.

Frame duration tracking begins automatically when a span starts. The integration continuously measures frame durations until the span finishes, then calculates and attaches the frame metrics to the completed span.

Before starting, ensure:

  1. The Sentry Flutter SDK is initialized. Learn more here.
  2. Tracing is set up. Learn more here.

This instrumentation is automatically enabled through two integrations:

  • The WidgetsFlutterBindingIntegration which provides the custom binding for frame tracking
  • The FramesTrackingIntegration which processes and attaches the frame metrics to spans

In most cases, no additional configuration is required.

If you need to initialize the widgets binding earlier than SentryFlutter.init(), you must call SentryWidgetsFlutterBinding.ensureInitialized() manually. Note that using a different custom binding will prevent this instrumentation from working properly.

Example:

Copied
void main() {
  SentryWidgetsFlutterBinding.ensureInitialized();
  // ... rest of your initialization code
}

Set enableFramesTracking to false in the options to disable the instrumentation.

Copied
await SentryFlutter.init(
  (options) {
    options.enableFramesTracking = false
  },
);
Help improve this content
Our documentation is open source and available on GitHub. Your contributions are welcome, whether fixing a typo (drat!) or suggesting an update ("yeah, this would be better").