[flutter_tools] stop using throttled print for service extensions (#76022)
This commit is contained in:
@@ -111,11 +111,13 @@ mixin RendererBinding on BindingBase, ServicesBinding, SchedulerBinding, Gesture
|
||||
return _forceRepaint();
|
||||
},
|
||||
);
|
||||
registerSignalServiceExtension(
|
||||
registerServiceExtension(
|
||||
name: 'debugDumpLayerTree',
|
||||
callback: () {
|
||||
debugDumpLayerTree();
|
||||
return debugPrintDone;
|
||||
callback: (Map<String, String> parameters) async {
|
||||
final String data = RendererBinding.instance?.renderView.debugLayer?.toStringDeep() ?? 'Layer tree unavailable.';
|
||||
return <String, Object>{
|
||||
'data': data,
|
||||
};
|
||||
},
|
||||
);
|
||||
return true;
|
||||
@@ -123,27 +125,35 @@ mixin RendererBinding on BindingBase, ServicesBinding, SchedulerBinding, Gesture
|
||||
|
||||
if (!kReleaseMode) {
|
||||
// these service extensions work in debug or profile mode
|
||||
registerSignalServiceExtension(
|
||||
registerServiceExtension(
|
||||
name: 'debugDumpRenderTree',
|
||||
callback: () {
|
||||
debugDumpRenderTree();
|
||||
return debugPrintDone;
|
||||
},
|
||||
callback: (Map<String, String> parameters) async {
|
||||
final String data = RendererBinding.instance?.renderView.toStringDeep() ?? 'Render tree unavailable.';
|
||||
return <String, Object>{
|
||||
'data': data,
|
||||
};
|
||||
}
|
||||
);
|
||||
|
||||
registerSignalServiceExtension(
|
||||
registerServiceExtension(
|
||||
name: 'debugDumpSemanticsTreeInTraversalOrder',
|
||||
callback: () {
|
||||
debugDumpSemanticsTree(DebugSemanticsDumpOrder.traversalOrder);
|
||||
return debugPrintDone;
|
||||
callback: (Map<String, String> parameters) async {
|
||||
final String data = RendererBinding.instance?.renderView.debugSemantics
|
||||
?.toStringDeep(childOrder: DebugSemanticsDumpOrder.traversalOrder) ?? 'Semantics not collected.';
|
||||
return <String, Object>{
|
||||
'data': data,
|
||||
};
|
||||
},
|
||||
);
|
||||
|
||||
registerSignalServiceExtension(
|
||||
registerServiceExtension(
|
||||
name: 'debugDumpSemanticsTreeInInverseHitTestOrder',
|
||||
callback: () {
|
||||
debugDumpSemanticsTree(DebugSemanticsDumpOrder.inverseHitTest);
|
||||
return debugPrintDone;
|
||||
callback: (Map<String, String> parameters) async {
|
||||
final String data = RendererBinding.instance?.renderView.debugSemantics
|
||||
?.toStringDeep(childOrder: DebugSemanticsDumpOrder.inverseHitTest) ?? 'Semantics not collected.';
|
||||
return <String, Object>{
|
||||
'data': data,
|
||||
};
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
@@ -11,7 +11,6 @@ import 'package:flutter/semantics.dart';
|
||||
|
||||
import 'package:vector_math/vector_math_64.dart';
|
||||
|
||||
import 'binding.dart';
|
||||
import 'box.dart';
|
||||
import 'layer.dart';
|
||||
import 'layout_helper.dart';
|
||||
|
||||
@@ -387,11 +387,13 @@ mixin WidgetsBinding on BindingBase, ServicesBinding, SchedulerBinding, GestureB
|
||||
super.initServiceExtensions();
|
||||
|
||||
if (!kReleaseMode) {
|
||||
registerSignalServiceExtension(
|
||||
registerServiceExtension(
|
||||
name: 'debugDumpApp',
|
||||
callback: () {
|
||||
debugDumpApp();
|
||||
return debugPrintDone;
|
||||
callback: (Map<String, String> parameters) async {
|
||||
final String data = _debugDumpAppString();
|
||||
return <String, Object>{
|
||||
'data': data,
|
||||
};
|
||||
},
|
||||
);
|
||||
|
||||
@@ -1027,20 +1029,23 @@ void runApp(Widget app) {
|
||||
..scheduleWarmUpFrame();
|
||||
}
|
||||
|
||||
String _debugDumpAppString() {
|
||||
assert(WidgetsBinding.instance != null);
|
||||
const String mode = kDebugMode ? 'DEBUG MODE' : 'PROFILE MODE';
|
||||
final StringBuffer buffer = StringBuffer();
|
||||
buffer.writeln('${WidgetsBinding.instance.runtimeType} - $mode');
|
||||
if (WidgetsBinding.instance!.renderViewElement != null) {
|
||||
buffer.writeln(WidgetsBinding.instance!.renderViewElement!.toStringDeep());
|
||||
} else {
|
||||
buffer.writeln('<no tree currently mounted>');
|
||||
}
|
||||
return buffer.toString();
|
||||
}
|
||||
|
||||
/// Print a string representation of the currently running app.
|
||||
void debugDumpApp() {
|
||||
assert(WidgetsBinding.instance != null);
|
||||
String mode = 'RELEASE MODE';
|
||||
assert(() {
|
||||
mode = 'CHECKED MODE';
|
||||
return true;
|
||||
}());
|
||||
debugPrint('${WidgetsBinding.instance.runtimeType} - $mode');
|
||||
if (WidgetsBinding.instance!.renderViewElement != null) {
|
||||
debugPrint(WidgetsBinding.instance!.renderViewElement!.toStringDeep());
|
||||
} else {
|
||||
debugPrint('<no tree currently mounted>');
|
||||
}
|
||||
final String value = _debugDumpAppString();
|
||||
debugPrint(value);
|
||||
}
|
||||
|
||||
/// A bridge from a [RenderObject] to an [Element] tree.
|
||||
|
||||
@@ -226,22 +226,19 @@ void main() {
|
||||
});
|
||||
|
||||
test('Service extensions - debugDumpApp', () async {
|
||||
Map<String, dynamic> result;
|
||||
final Map<String, dynamic> result = await binding.testExtension('debugDumpApp', <String, String>{});
|
||||
|
||||
result = await binding.testExtension('debugDumpApp', <String, String>{});
|
||||
expect(result, <String, String>{});
|
||||
expect(console, <String>['TestServiceExtensionsBinding - CHECKED MODE', '<no tree currently mounted>']);
|
||||
console.clear();
|
||||
expect(result, <String, dynamic>{
|
||||
'data': matches('TestServiceExtensionsBinding - DEBUG MODE\n<no tree currently mounted>'),
|
||||
});
|
||||
});
|
||||
|
||||
test('Service extensions - debugDumpRenderTree', () async {
|
||||
Map<String, dynamic> result;
|
||||
|
||||
await binding.doFrame();
|
||||
result = await binding.testExtension('debugDumpRenderTree', <String, String>{});
|
||||
expect(result, <String, String>{});
|
||||
expect(console, <Matcher>[
|
||||
matches(
|
||||
final Map<String, dynamic> result = await binding.testExtension('debugDumpRenderTree', <String, String>{});
|
||||
|
||||
expect(result, <String, dynamic>{
|
||||
'data': matches(
|
||||
r'^'
|
||||
r'RenderView#[0-9a-f]{5}\n'
|
||||
r' debug mode enabled - [a-zA-Z]+\n'
|
||||
@@ -250,18 +247,15 @@ void main() {
|
||||
r' configuration: Size\(800\.0, 600\.0\) at 3\.0x \(in logical pixels\)\n'
|
||||
r'$'
|
||||
),
|
||||
]);
|
||||
console.clear();
|
||||
});
|
||||
});
|
||||
|
||||
test('Service extensions - debugDumpLayerTree', () async {
|
||||
Map<String, dynamic> result;
|
||||
|
||||
await binding.doFrame();
|
||||
result = await binding.testExtension('debugDumpLayerTree', <String, String>{});
|
||||
expect(result, <String, String>{});
|
||||
expect(console, <Matcher>[
|
||||
matches(
|
||||
final Map<String, dynamic> result = await binding.testExtension('debugDumpLayerTree', <String, String>{});
|
||||
|
||||
expect(result, <String, dynamic>{
|
||||
'data': matches(
|
||||
r'^'
|
||||
r'TransformLayer#[0-9a-f]{5}\n'
|
||||
r' owner: RenderView#[0-9a-f]{5}\n'
|
||||
@@ -275,28 +269,25 @@ void main() {
|
||||
r' \[3] 0\.0,0\.0,0\.0,1\.0\n'
|
||||
r'$'
|
||||
),
|
||||
]);
|
||||
console.clear();
|
||||
});
|
||||
});
|
||||
|
||||
test('Service extensions - debugDumpSemanticsTreeInTraversalOrder', () async {
|
||||
Map<String, dynamic> result;
|
||||
|
||||
await binding.doFrame();
|
||||
result = await binding.testExtension('debugDumpSemanticsTreeInTraversalOrder', <String, String>{});
|
||||
expect(result, <String, String>{});
|
||||
expect(console, <String>['Semantics not collected.']);
|
||||
console.clear();
|
||||
final Map<String, dynamic> result = await binding.testExtension('debugDumpSemanticsTreeInTraversalOrder', <String, String>{});
|
||||
|
||||
expect(result, <String, String>{
|
||||
'data': 'Semantics not collected.'
|
||||
});
|
||||
});
|
||||
|
||||
test('Service extensions - debugDumpSemanticsTreeInInverseHitTestOrder', () async {
|
||||
Map<String, dynamic> result;
|
||||
|
||||
await binding.doFrame();
|
||||
result = await binding.testExtension('debugDumpSemanticsTreeInInverseHitTestOrder', <String, String>{});
|
||||
expect(result, <String, String>{});
|
||||
expect(console, <String>['Semantics not collected.']);
|
||||
console.clear();
|
||||
final Map<String, dynamic> result = await binding.testExtension('debugDumpSemanticsTreeInInverseHitTestOrder', <String, String>{});
|
||||
|
||||
expect(result, <String, String>{
|
||||
'data': 'Semantics not collected.'
|
||||
});
|
||||
});
|
||||
|
||||
test('Service extensions - debugPaint', () async {
|
||||
|
||||
@@ -400,45 +400,50 @@ class FlutterDevice {
|
||||
Future<void> debugDumpApp() async {
|
||||
final List<FlutterView> views = await vmService.getFlutterViews();
|
||||
for (final FlutterView view in views) {
|
||||
await vmService.flutterDebugDumpApp(
|
||||
final String data = await vmService.flutterDebugDumpApp(
|
||||
isolateId: view.uiIsolate.id,
|
||||
);
|
||||
globals.printStatus(data);
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> debugDumpRenderTree() async {
|
||||
final List<FlutterView> views = await vmService.getFlutterViews();
|
||||
for (final FlutterView view in views) {
|
||||
await vmService.flutterDebugDumpRenderTree(
|
||||
final String data = await vmService.flutterDebugDumpRenderTree(
|
||||
isolateId: view.uiIsolate.id,
|
||||
);
|
||||
globals.printStatus(data);
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> debugDumpLayerTree() async {
|
||||
final List<FlutterView> views = await vmService.getFlutterViews();
|
||||
for (final FlutterView view in views) {
|
||||
await vmService.flutterDebugDumpLayerTree(
|
||||
final String data = await vmService.flutterDebugDumpLayerTree(
|
||||
isolateId: view.uiIsolate.id,
|
||||
);
|
||||
globals.printStatus(data);
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> debugDumpSemanticsTreeInTraversalOrder() async {
|
||||
final List<FlutterView> views = await vmService.getFlutterViews();
|
||||
for (final FlutterView view in views) {
|
||||
await vmService.flutterDebugDumpSemanticsTreeInTraversalOrder(
|
||||
final String data = await vmService.flutterDebugDumpSemanticsTreeInTraversalOrder(
|
||||
isolateId: view.uiIsolate.id,
|
||||
);
|
||||
globals.printStatus(data);
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> debugDumpSemanticsTreeInInverseHitTestOrder() async {
|
||||
final List<FlutterView> views = await vmService.getFlutterViews();
|
||||
for (final FlutterView view in views) {
|
||||
await vmService.flutterDebugDumpSemanticsTreeInInverseHitTestOrder(
|
||||
final String data = await vmService.flutterDebugDumpSemanticsTreeInInverseHitTestOrder(
|
||||
isolateId: view.uiIsolate.id,
|
||||
);
|
||||
globals.printStatus(data);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -515,49 +515,55 @@ extension FlutterVmService on vm_service.VmService {
|
||||
await onRunnable;
|
||||
}
|
||||
|
||||
Future<Map<String, dynamic>> flutterDebugDumpApp({
|
||||
Future<String> flutterDebugDumpApp({
|
||||
@required String isolateId,
|
||||
}) {
|
||||
return invokeFlutterExtensionRpcRaw(
|
||||
}) async {
|
||||
final Map<String, Object> response = await invokeFlutterExtensionRpcRaw(
|
||||
'ext.flutter.debugDumpApp',
|
||||
isolateId: isolateId,
|
||||
);
|
||||
return response['data']?.toString();
|
||||
}
|
||||
|
||||
Future<Map<String, dynamic>> flutterDebugDumpRenderTree({
|
||||
Future<String> flutterDebugDumpRenderTree({
|
||||
@required String isolateId,
|
||||
}) {
|
||||
return invokeFlutterExtensionRpcRaw(
|
||||
}) async {
|
||||
final Map<String, Object> response = await invokeFlutterExtensionRpcRaw(
|
||||
'ext.flutter.debugDumpRenderTree',
|
||||
isolateId: isolateId,
|
||||
args: <String, Object>{}
|
||||
);
|
||||
return response['data']?.toString();
|
||||
}
|
||||
|
||||
Future<Map<String, dynamic>> flutterDebugDumpLayerTree({
|
||||
Future<String> flutterDebugDumpLayerTree({
|
||||
@required String isolateId,
|
||||
}) {
|
||||
return invokeFlutterExtensionRpcRaw(
|
||||
}) async {
|
||||
final Map<String, Object> response = await invokeFlutterExtensionRpcRaw(
|
||||
'ext.flutter.debugDumpLayerTree',
|
||||
isolateId: isolateId,
|
||||
);
|
||||
return response['data']?.toString();
|
||||
}
|
||||
|
||||
Future<Map<String, dynamic>> flutterDebugDumpSemanticsTreeInTraversalOrder({
|
||||
Future<String> flutterDebugDumpSemanticsTreeInTraversalOrder({
|
||||
@required String isolateId,
|
||||
}) {
|
||||
return invokeFlutterExtensionRpcRaw(
|
||||
}) async {
|
||||
final Map<String, Object> response = await invokeFlutterExtensionRpcRaw(
|
||||
'ext.flutter.debugDumpSemanticsTreeInTraversalOrder',
|
||||
isolateId: isolateId,
|
||||
);
|
||||
return response['data']?.toString();
|
||||
}
|
||||
|
||||
Future<Map<String, dynamic>> flutterDebugDumpSemanticsTreeInInverseHitTestOrder({
|
||||
Future<String> flutterDebugDumpSemanticsTreeInInverseHitTestOrder({
|
||||
@required String isolateId,
|
||||
}) {
|
||||
return invokeFlutterExtensionRpcRaw(
|
||||
}) async {
|
||||
final Map<String, Object> response = await invokeFlutterExtensionRpcRaw(
|
||||
'ext.flutter.debugDumpSemanticsTreeInInverseHitTestOrder',
|
||||
isolateId: isolateId,
|
||||
);
|
||||
return response['data']?.toString();
|
||||
}
|
||||
|
||||
Future<Map<String, dynamic>> _flutterToggle(String name, {
|
||||
|
||||
Reference in New Issue
Block a user