Unverified Commit 8fa2a5e8 authored by Kenzie (Schmoll) Davisson's avatar Kenzie (Schmoll) Davisson Committed by GitHub

Add `profileRenderObjectPaints` and `profileRenderObjectLayouts` service extensions (#91822)

parent ccc82614
...@@ -153,7 +153,6 @@ mixin RendererBinding on BindingBase, ServicesBinding, SchedulerBinding, Gesture ...@@ -153,7 +153,6 @@ mixin RendererBinding on BindingBase, ServicesBinding, SchedulerBinding, Gesture
}; };
}, },
); );
registerServiceExtension( registerServiceExtension(
name: 'debugDumpSemanticsTreeInTraversalOrder', name: 'debugDumpSemanticsTreeInTraversalOrder',
callback: (Map<String, String> parameters) async { callback: (Map<String, String> parameters) async {
...@@ -164,7 +163,6 @@ mixin RendererBinding on BindingBase, ServicesBinding, SchedulerBinding, Gesture ...@@ -164,7 +163,6 @@ mixin RendererBinding on BindingBase, ServicesBinding, SchedulerBinding, Gesture
}; };
}, },
); );
registerServiceExtension( registerServiceExtension(
name: 'debugDumpSemanticsTreeInInverseHitTestOrder', name: 'debugDumpSemanticsTreeInInverseHitTestOrder',
callback: (Map<String, String> parameters) async { callback: (Map<String, String> parameters) async {
...@@ -175,6 +173,22 @@ mixin RendererBinding on BindingBase, ServicesBinding, SchedulerBinding, Gesture ...@@ -175,6 +173,22 @@ mixin RendererBinding on BindingBase, ServicesBinding, SchedulerBinding, Gesture
}; };
}, },
); );
registerBoolServiceExtension(
name: 'profileRenderObjectPaints',
getter: () async => debugProfilePaintsEnabled,
setter: (bool value) async {
if (debugProfilePaintsEnabled != value)
debugProfilePaintsEnabled = value;
},
);
registerBoolServiceExtension(
name: 'profileRenderObjectLayouts',
getter: () async => debugProfileLayoutsEnabled,
setter: (bool value) async {
if (debugProfileLayoutsEnabled != value)
debugProfileLayoutsEnabled = value;
},
);
} }
} }
......
...@@ -111,9 +111,8 @@ bool debugProfileLayoutsEnabled = false; ...@@ -111,9 +111,8 @@ bool debugProfileLayoutsEnabled = false;
/// Adds [dart:developer.Timeline] events for every [RenderObject] painted. /// Adds [dart:developer.Timeline] events for every [RenderObject] painted.
/// ///
/// This is only enabled in debug builds. The timing information this exposes is /// The timing information this flag exposes is not representative of actual
/// not representative of actual paints. However, it can expose unexpected /// paints. However, it can expose unexpected painting in the timeline.
/// painting in the timeline.
/// ///
/// For details on how to use [dart:developer.Timeline] events in the Dart /// For details on how to use [dart:developer.Timeline] events in the Dart
/// Observatory to optimize your app, see: /// Observatory to optimize your app, see:
......
...@@ -175,9 +175,9 @@ class PaintingContext extends ClipContext { ...@@ -175,9 +175,9 @@ class PaintingContext extends ClipContext {
/// into the layer subtree associated with this painting context. Otherwise, /// into the layer subtree associated with this painting context. Otherwise,
/// the child will be painted into the current PictureLayer for this context. /// the child will be painted into the current PictureLayer for this context.
void paintChild(RenderObject child, Offset offset) { void paintChild(RenderObject child, Offset offset) {
if (!kReleaseMode && debugProfilePaintsEnabled)
Timeline.startSync('${child.runtimeType}', arguments: timelineArgumentsIndicatingLandmarkEvent);
assert(() { assert(() {
if (debugProfilePaintsEnabled)
Timeline.startSync('${child.runtimeType}', arguments: timelineArgumentsIndicatingLandmarkEvent);
debugOnProfilePaint?.call(child); debugOnProfilePaint?.call(child);
return true; return true;
}()); }());
...@@ -189,11 +189,8 @@ class PaintingContext extends ClipContext { ...@@ -189,11 +189,8 @@ class PaintingContext extends ClipContext {
child._paintWithContext(this, offset); child._paintWithContext(this, offset);
} }
assert(() { if (!kReleaseMode && debugProfilePaintsEnabled)
if (debugProfilePaintsEnabled) Timeline.finishSync();
Timeline.finishSync();
return true;
}());
} }
void _compositeChild(RenderObject child, Offset offset) { void _compositeChild(RenderObject child, Offset offset) {
......
...@@ -173,7 +173,7 @@ void main() { ...@@ -173,7 +173,7 @@ void main() {
const int disabledExtensions = kIsWeb ? 2 : 0; const int disabledExtensions = kIsWeb ? 2 : 0;
// If you add a service extension... TEST IT! :-) // If you add a service extension... TEST IT! :-)
// ...then increment this number. // ...then increment this number.
expect(binding.extensions.length, 33 + widgetInspectorExtensionCount - disabledExtensions); expect(binding.extensions.length, 35 + widgetInspectorExtensionCount - disabledExtensions);
expect(console, isEmpty); expect(console, isEmpty);
debugPrint = debugPrintThrottled; debugPrint = debugPrintThrottled;
...@@ -442,6 +442,64 @@ void main() { ...@@ -442,6 +442,64 @@ void main() {
expect(binding.frameScheduled, isFalse); expect(binding.frameScheduled, isFalse);
}); });
test('Service extensions - profileRenderObjectPaints', () async {
Map<String, dynamic> result;
expect(binding.frameScheduled, isFalse);
expect(debugProfileBuildsEnabled, false);
result = await binding.testExtension('profileRenderObjectPaints', <String, String>{});
expect(result, <String, String>{'enabled': 'false'});
expect(debugProfilePaintsEnabled, false);
result = await binding.testExtension('profileRenderObjectPaints', <String, String>{'enabled': 'true'});
expect(result, <String, String>{'enabled': 'true'});
expect(debugProfilePaintsEnabled, true);
result = await binding.testExtension('profileRenderObjectPaints', <String, String>{});
expect(result, <String, String>{'enabled': 'true'});
expect(debugProfilePaintsEnabled, true);
result = await binding.testExtension('profileRenderObjectPaints', <String, String>{'enabled': 'false'});
expect(result, <String, String>{'enabled': 'false'});
expect(debugProfilePaintsEnabled, false);
result = await binding.testExtension('profileRenderObjectPaints', <String, String>{});
expect(result, <String, String>{'enabled': 'false'});
expect(debugProfilePaintsEnabled, false);
expect(binding.frameScheduled, isFalse);
});
test('Service extensions - profileRenderObjectLayouts', () async {
Map<String, dynamic> result;
expect(binding.frameScheduled, isFalse);
expect(debugProfileLayoutsEnabled, false);
result = await binding.testExtension('profileRenderObjectLayouts', <String, String>{});
expect(result, <String, String>{'enabled': 'false'});
expect(debugProfileLayoutsEnabled, false);
result = await binding.testExtension('profileRenderObjectLayouts', <String, String>{'enabled': 'true'});
expect(result, <String, String>{'enabled': 'true'});
expect(debugProfileLayoutsEnabled, true);
result = await binding.testExtension('profileRenderObjectLayouts', <String, String>{});
expect(result, <String, String>{'enabled': 'true'});
expect(debugProfileLayoutsEnabled, true);
result = await binding.testExtension('profileRenderObjectLayouts', <String, String>{'enabled': 'false'});
expect(result, <String, String>{'enabled': 'false'});
expect(debugProfileLayoutsEnabled, false);
result = await binding.testExtension('profileRenderObjectLayouts', <String, String>{});
expect(result, <String, String>{'enabled': 'false'});
expect(debugProfileLayoutsEnabled, false);
expect(binding.frameScheduled, isFalse);
});
test('Service extensions - evict', () async { test('Service extensions - evict', () async {
Map<String, dynamic> result; Map<String, dynamic> result;
bool completed; bool completed;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment