[Impeller] expose renderer choice in service extensions (flutter/engine#36103)

This commit is contained in:
Jonah Williams
2022-09-12 16:24:19 -07:00
committed by GitHub
parent 9454c0743d
commit 8f1cb92a04
2 changed files with 55 additions and 0 deletions

View File

@@ -73,6 +73,16 @@ Future<developer.ServiceExtensionResponse> _reinitializeShader(
}));
}
Future<developer.ServiceExtensionResponse> _getImpellerEnabled(
String method,
Map<String, String> parameters,
) async {
return developer.ServiceExtensionResponse.result(json.encode(<String, Object>{
'type': 'Success',
'enabled': _impellerEnabled,
}));
}
@pragma('vm:entry-point')
void _setupHooks() {
assert(() {
@@ -86,8 +96,18 @@ void _setupHooks() {
);
return true;
}());
// In debug and profile mode, allow tools to display the current rendering backend.
if (!_kReleaseMode) {
developer.registerExtension(
'ext.ui.window.impellerEnabled',
_getImpellerEnabled,
);
}
}
const bool _kReleaseMode = bool.fromEnvironment('dart.vm.product');
/// Returns runtime Dart compilation trace as a UTF-8 encoded memory buffer.
///
/// The buffer contains a list of symbols compiled by the Dart JIT at runtime up

View File

@@ -41,6 +41,30 @@ void main() {
}
});
test('Can return whether or not impeller is enabled', () async {
vms.VmService? vmService;
try {
final developer.ServiceProtocolInfo info = await developer.Service.getInfo();
if (info.serverUri == null) {
fail('This test must not be run with --disable-observatory.');
}
vmService = await vmServiceConnectUri(
'ws://localhost:${info.serverUri!.port}${info.serverUri!.path}ws',
);
final String? isolateId = await getIsolateId(vmService);
final vms.Response response = await vmService.callServiceExtension(
'ext.ui.window.impellerEnabled',
isolateId: isolateId,
);
expect(response.json!['enabled'], false);
} finally {
await vmService?.dispose();
}
});
test('Reload fonts request sends font change notification', () async {
vms.VmService? vmService;
try {
@@ -87,6 +111,17 @@ Future<String> getViewId(vms.VmService vmService) async {
return (rawViews![0]! as Map<String, Object?>?)!['id']! as String;
}
Future<String?> getIsolateId(vms.VmService vmService) async {
final vms.VM vm = await vmService.getVM();
for (final vms.IsolateRef isolate in vm.isolates!) {
if (isolate.isSystemIsolate ?? false) {
continue;
}
return isolate.id;
}
return null;
}
class PlatformResponse {
const PlatformResponse({
required this.name,