You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/platforms/flutter/integrations/slow-and-frozen-frames-instrumentation.mdx
+30-12Lines changed: 30 additions & 12 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -12,9 +12,15 @@ Unresponsive UI and animation hitches annoy users and degrade the user experienc
12
12
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.
13
13
Learn more about frame delay [here](https://develop.sentry.dev/sdk/performance/frames-delay/).
14
14
15
+
<Note>
16
+
17
+
Frames tracking instrumentation is available on **iOS**, **macOS** and **Android**.
18
+
19
+
</Note>
20
+
15
21
## Instrumentation Behaviour
16
22
17
-
Frame metrics are manually calculated using the [addPersistentFrameCallback](https://api.flutter.dev/flutter/scheduler/SchedulerBinding/addPersistentFrameCallback.html)API from the Flutter SDK.
23
+
Frame metrics are manually calculated by implementing a custom `WidgetsFlutterBinding` which allows us to measure the duration between [handleBeginFrame](https://api.flutter.dev/flutter/scheduler/SchedulerBinding/handleBeginFrame.html)and [handleDrawFrame](https://api.flutter.dev/flutter/scheduler/SchedulerBinding/handleDrawFrame.html).
18
24
Frame duration tracking in Sentry's Flutter SDK begins automatically when a span starts. It continuously measures each frame's render time until the span finishes, then calculates and attaches frame metrics to the completed span.
19
25
20
26
## Prerequisite
@@ -26,22 +32,34 @@ Before starting, ensure:
26
32
27
33
## Configure
28
34
29
-
This type of instrumentation is automatically enabled. There is no need for further configuration.
35
+
This instrumentation is automatically enabled through two integrations:
36
+
- The `WidgetsFlutterBindingIntegration` which provides the custom binding for frame tracking
37
+
- The `FramesTrackingIntegration` which processes and attaches the frame metrics to spans
38
+
39
+
In most cases, no additional configuration is required.
40
+
41
+
### Early Widgets Binding Initialization
42
+
43
+
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.
44
+
45
+
Example:
46
+
```dart {2}
47
+
void main() {
48
+
SentryWidgetsFlutterBinding.ensureInitialized();
49
+
// ... rest of your initialization code
50
+
}
51
+
```
30
52
31
53
## Additional Configuration
32
54
33
55
### Disabling the Instrumentation
34
56
35
57
Set `enableFramesTracking` to `false` in the options to disable the instrumentation.
0 commit comments