diff --git a/packages/flutter/lib/src/widgets/binding.dart b/packages/flutter/lib/src/widgets/binding.dart index 70f25ffc5d..0599fe0131 100644 --- a/packages/flutter/lib/src/widgets/binding.dart +++ b/packages/flutter/lib/src/widgets/binding.dart @@ -302,6 +302,16 @@ mixin WidgetsBinding on BindingBase, SchedulerBinding, GestureBinding, RendererB }; }, ); + + // Expose the ability to send Widget rebuilds as [Timeline] events. + registerBoolServiceExtension( + name: 'profileWidgetBuilds', + getter: () async => debugProfileBuildsEnabled, + setter: (bool value) async { + if (debugProfileBuildsEnabled != value) + debugProfileBuildsEnabled = value; + }, + ); } assert(() { @@ -316,16 +326,6 @@ mixin WidgetsBinding on BindingBase, SchedulerBinding, GestureBinding, RendererB }, ); - // Expose the ability to send Widget rebuilds as [Timeline] events. - registerBoolServiceExtension( - name: 'profileWidgetBuilds', - getter: () async => debugProfileBuildsEnabled, - setter: (bool value) async { - if (debugProfileBuildsEnabled != value) - debugProfileBuildsEnabled = value; - }, - ); - // This service extension is deprecated and will be removed by 12/1/2018. // Use ext.flutter.inspector.show instead. registerBoolServiceExtension( diff --git a/packages/flutter/lib/src/widgets/framework.dart b/packages/flutter/lib/src/widgets/framework.dart index aaf052721a..31d34f272d 100644 --- a/packages/flutter/lib/src/widgets/framework.dart +++ b/packages/flutter/lib/src/widgets/framework.dart @@ -3730,11 +3730,8 @@ abstract class ComponentElement extends Element { /// [rebuild] when the element needs updating. @override void performRebuild() { - assert(() { - if (debugProfileBuildsEnabled) - Timeline.startSync('${widget.runtimeType}', arguments: timelineWhitelistArguments); - return true; - }()); + if (!kReleaseMode && debugProfileBuildsEnabled) + Timeline.startSync('${widget.runtimeType}', arguments: timelineWhitelistArguments); assert(_debugSetAllowIgnoredCallsToMarkNeedsBuild(true)); Widget built; @@ -3757,11 +3754,8 @@ abstract class ComponentElement extends Element { _child = updateChild(null, built, slot); } - assert(() { - if (debugProfileBuildsEnabled) - Timeline.finishSync(); - return true; - }()); + if (!kReleaseMode && debugProfileBuildsEnabled) + Timeline.finishSync(); } /// Subclasses should override this function to actually call the appropriate diff --git a/packages/flutter_tools/lib/src/resident_runner.dart b/packages/flutter_tools/lib/src/resident_runner.dart index d6dea4b85a..2fd1b1952b 100644 --- a/packages/flutter_tools/lib/src/resident_runner.dart +++ b/packages/flutter_tools/lib/src/resident_runner.dart @@ -884,7 +884,7 @@ abstract class ResidentRunner { } return true; } else if (character == 'a') { - if (supportsServiceProtocol && isRunningDebug) { + if (supportsServiceProtocol) { await _debugToggleProfileWidgetBuilds(); } } else if (lower == 'o') { @@ -993,12 +993,12 @@ abstract class ResidentRunner { printStatus('To toggle the widget inspector (WidgetsApp.showWidgetInspectorOverride), press "i".'); printStatus('To toggle the display of construction lines (debugPaintSizeEnabled), press "p".'); printStatus('To simulate different operating systems, (defaultTargetPlatform), press "o".'); - printStatus('To enable timeline events for all widget build methods, (debugProfileWidgetBuilds), press "a"'); printStatus('To toggle the elevation checker, press "z".'); } else { printStatus('To dump the accessibility tree (debugDumpSemantics), press "S" (for traversal order) or "U" (for inverse hit test order).'); } printStatus('To display the performance overlay (WidgetsApp.showPerformanceOverlay), press "P".'); + printStatus('To enable timeline events for all widget build methods, (debugProfileWidgetBuilds), press "a"'); } if (flutterDevices.any((FlutterDevice d) => d.device.supportsScreenshot)) { printStatus('To save a screenshot to flutter.png, press "s".');