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
};
},
);
registerServiceExtension(
name: 'debugDumpSemanticsTreeInTraversalOrder',
callback: (Map<String, String> parameters) async {
......@@ -164,7 +163,6 @@ mixin RendererBinding on BindingBase, ServicesBinding, SchedulerBinding, Gesture
};
},
);
registerServiceExtension(
name: 'debugDumpSemanticsTreeInInverseHitTestOrder',
callback: (Map<String, String> parameters) async {
......@@ -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;
/// Adds [dart:developer.Timeline] events for every [RenderObject] painted.
///
/// This is only enabled in debug builds. The timing information this exposes is
/// not representative of actual paints. However, it can expose unexpected
/// painting in the timeline.
/// The timing information this flag exposes is not representative of actual
/// paints. However, it can expose unexpected painting in the timeline.
///
/// For details on how to use [dart:developer.Timeline] events in the Dart
/// Observatory to optimize your app, see:
......
......@@ -175,9 +175,9 @@ class PaintingContext extends ClipContext {
/// into the layer subtree associated with this painting context. Otherwise,
/// the child will be painted into the current PictureLayer for this context.
void paintChild(RenderObject child, Offset offset) {
assert(() {
if (debugProfilePaintsEnabled)
if (!kReleaseMode && debugProfilePaintsEnabled)
Timeline.startSync('${child.runtimeType}', arguments: timelineArgumentsIndicatingLandmarkEvent);
assert(() {
debugOnProfilePaint?.call(child);
return true;
}());
......@@ -189,11 +189,8 @@ class PaintingContext extends ClipContext {
child._paintWithContext(this, offset);
}
assert(() {
if (debugProfilePaintsEnabled)
if (!kReleaseMode && debugProfilePaintsEnabled)
Timeline.finishSync();
return true;
}());
}
void _compositeChild(RenderObject child, Offset offset) {
......
......@@ -173,7 +173,7 @@ void main() {
const int disabledExtensions = kIsWeb ? 2 : 0;
// If you add a service extension... TEST IT! :-)
// ...then increment this number.
expect(binding.extensions.length, 33 + widgetInspectorExtensionCount - disabledExtensions);
expect(binding.extensions.length, 35 + widgetInspectorExtensionCount - disabledExtensions);
expect(console, isEmpty);
debugPrint = debugPrintThrottled;
......@@ -442,6 +442,64 @@ void main() {
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 {
Map<String, dynamic> result;
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