1 | // Copyright 2014 The Flutter Authors. All rights reserved. |
2 | // Use of this source code is governed by a BSD-style license that can be |
3 | // found in the LICENSE file. |
4 | |
5 | /// @docImport 'package:flutter/rendering.dart'; |
6 | /// @docImport 'package:flutter/widgets.dart'; |
7 | /// |
8 | /// @docImport 'binding.dart'; |
9 | /// @docImport 'ticker.dart'; |
10 | library; |
11 | |
12 | import 'package:flutter/foundation.dart'; |
13 | |
14 | // Any changes to this file should be reflected in the debugAssertAllSchedulerVarsUnset() |
15 | // function below. |
16 | |
17 | /// Print a banner at the beginning of each frame. |
18 | /// |
19 | /// Frames triggered by the engine and handler by the scheduler binding will |
20 | /// have a banner giving the frame number and the time stamp of the frame. |
21 | /// |
22 | /// Frames triggered eagerly by the widget framework (e.g. when calling |
23 | /// [runApp]) will have a label saying "warm-up frame" instead of the time stamp |
24 | /// (the time stamp sent to frame callbacks in that case is the time of the last |
25 | /// frame, or 0:00 if it is the first frame). |
26 | /// |
27 | /// To include a banner at the end of each frame as well, to distinguish |
28 | /// intra-frame output from inter-frame output, set [debugPrintEndFrameBanner] |
29 | /// to true as well. |
30 | /// |
31 | /// See also: |
32 | /// |
33 | /// * [debugProfilePaintsEnabled], which does something similar for |
34 | /// painting but using the timeline view. |
35 | /// * [debugPrintLayouts], which does something similar for layout but using |
36 | /// console output. |
37 | /// * The discussions at [WidgetsBinding.drawFrame] and at |
38 | /// [SchedulerBinding.handleBeginFrame]. |
39 | bool debugPrintBeginFrameBanner = false; |
40 | |
41 | /// Print a banner at the end of each frame. |
42 | /// |
43 | /// Combined with [debugPrintBeginFrameBanner], this can be helpful for |
44 | /// determining if code is running during a frame or between frames. |
45 | bool debugPrintEndFrameBanner = false; |
46 | |
47 | /// Log the call stacks that cause a frame to be scheduled. |
48 | /// |
49 | /// This is called whenever [SchedulerBinding.scheduleFrame] schedules a frame. This |
50 | /// can happen for various reasons, e.g. when a [Ticker] or |
51 | /// [AnimationController] is started, or when [RenderObject.markNeedsLayout] is |
52 | /// called, or when [State.setState] is called. |
53 | /// |
54 | /// To get a stack specifically when widgets are scheduled to be built, see |
55 | /// [debugPrintScheduleBuildForStacks]. |
56 | bool debugPrintScheduleFrameStacks = false; |
57 | |
58 | /// Record timeline trace events for post-frame callbacks. |
59 | /// |
60 | /// When this flag is set to false (the default), the developer timeline |
61 | /// records when post-frame callbacks are running, but it does not tell you any |
62 | /// information about how that time is spent within specific callbacks: |
63 | /// |
64 | ///  |
65 | /// |
66 | /// When this flag is set to true, timeline events will be recorded for each |
67 | /// post-frame callback that runs, like so: |
68 | /// |
69 | ///  |
70 | bool debugTracePostFrameCallbacks = false; |
71 | |
72 | /// Returns true if none of the scheduler library debug variables have been changed. |
73 | /// |
74 | /// This function is used by the test framework to ensure that debug variables |
75 | /// haven't been inadvertently changed. |
76 | /// |
77 | /// See [the scheduler library](scheduler/scheduler-library.html) for a complete |
78 | /// list. |
79 | bool debugAssertAllSchedulerVarsUnset(String reason) { |
80 | assert(() { |
81 | if (debugPrintBeginFrameBanner || debugPrintEndFrameBanner) { |
82 | throw FlutterError(reason); |
83 | } |
84 | return true; |
85 | }()); |
86 | return true; |
87 | } |
88 | |