diff --git a/packages/flutter/lib/src/rendering/debug.dart b/packages/flutter/lib/src/rendering/debug.dart index bc4ab422a7..fab2111071 100644 --- a/packages/flutter/lib/src/rendering/debug.dart +++ b/packages/flutter/lib/src/rendering/debug.dart @@ -121,8 +121,10 @@ bool debugPrintMarkNeedsPaintStacks = false; /// /// See also: /// -/// * [debugProfilePaintsEnabled], which does something similar for -/// painting but using the timeline view. +/// * [debugProfileLayoutsEnabled], which does something similar for layout +/// but using the timeline view. +/// * [debugProfilePaintsEnabled], which does something similar for painting +/// but using the timeline view. /// * [debugPrintRebuildDirtyWidgets], which does something similar for widgets /// being rebuilt. /// * The discussion at [RendererBinding.drawFrame]. @@ -134,6 +136,21 @@ bool debugPrintLayouts = false; /// enabled by the test framework. bool debugCheckIntrinsicSizes = false; +/// Adds [dart:developer.Timeline] events for every [RenderObject] layout. +/// +/// For details on how to use [dart:developer.Timeline] events in the Dart +/// Observatory to optimize your app, see: +/// +/// +/// See also: +/// +/// * [debugPrintLayouts], which does something similar for layout but using +/// console output. +/// * [debugProfileBuildsEnabled], which does something similar for widgets +/// being rebuilt. +/// * [debugProfilePaintsEnabled], which does something similar for painting. +bool debugProfileLayoutsEnabled = false; + /// Adds [dart:developer.Timeline] events for every [RenderObject] painted. /// /// This is only enabled in debug builds. The timing information this exposes is @@ -146,11 +163,11 @@ bool debugCheckIntrinsicSizes = false; /// /// See also: /// -/// * [debugPrintLayouts], which does something similar for layout but using -/// console output. /// * [debugProfileBuildsEnabled], which does something similar for widgets /// being rebuilt, and [debugPrintRebuildDirtyWidgets], its console /// equivalent. +/// * [debugProfileLayoutsEnabled], which does something similar for layout, +/// and [debugPrintLayouts], its console equivalent. /// * The discussion at [RendererBinding.drawFrame]. /// * [RepaintBoundary], which can be used to contain repaints when unchanged /// areas are being excessively repainted. diff --git a/packages/flutter/lib/src/rendering/object.dart b/packages/flutter/lib/src/rendering/object.dart index 05e64d97e2..b844620180 100644 --- a/packages/flutter/lib/src/rendering/object.dart +++ b/packages/flutter/lib/src/rendering/object.dart @@ -1674,6 +1674,9 @@ abstract class RenderObject extends AbstractNode with DiagnosticableTreeMixin im /// implemented here) to return early if the child does not need to do any /// work to update its layout information. void layout(Constraints constraints, { bool parentUsesSize = false }) { + if (!kReleaseMode && debugProfileLayoutsEnabled) + Timeline.startSync('$runtimeType', arguments: timelineArgumentsIndicatingLandmarkEvent); + assert(constraints != null); assert(constraints.debugAssertIsValid( isAppliedConstraint: true, @@ -1727,6 +1730,9 @@ abstract class RenderObject extends AbstractNode with DiagnosticableTreeMixin im _debugDoingThisResize = false; return true; }()); + + if (!kReleaseMode && debugProfileLayoutsEnabled) + Timeline.finishSync(); return; } _constraints = constraints; @@ -1789,6 +1795,9 @@ abstract class RenderObject extends AbstractNode with DiagnosticableTreeMixin im }()); _needsLayout = false; markNeedsPaint(); + + if (!kReleaseMode && debugProfileLayoutsEnabled) + Timeline.finishSync(); } /// If a subclass has a "size" (the state controlled by `parentUsesSize`, diff --git a/packages/flutter/lib/src/widgets/debug.dart b/packages/flutter/lib/src/widgets/debug.dart index 2c604d6f06..dd9839b00f 100644 --- a/packages/flutter/lib/src/widgets/debug.dart +++ b/packages/flutter/lib/src/widgets/debug.dart @@ -100,9 +100,11 @@ bool debugPrintGlobalKeyedWidgetLifecycle = false; /// /// See also: /// -/// * [debugProfilePaintsEnabled], which does something similar but for -/// painting, and [debugPrintRebuildDirtyWidgets], which does something similar -/// but reporting the builds to the console. +/// * [debugPrintRebuildDirtyWidgets], which does something similar but +/// reporting the builds to the console. +/// * [debugProfileLayoutsEnabled], which does something similar for layout, +/// and [debugPrintLayouts], its console equivalent. +/// * [debugProfilePaintsEnabled], which does something similar for painting. bool debugProfileBuildsEnabled = false; /// Show banners for deprecated widgets.