Skip to content

Commit 57ad4ff

Browse files
authored
Added a devicelab test for vulkan validation layers (flutter#134685)
This makes sure validation layers are being used and that there are no validation errors fixes flutter#134175 ## Pre-launch Checklist - [x] I read the [Contributor Guide] and followed the process outlined there for submitting PRs. - [x] I read the [Tree Hygiene] wiki page, which explains my responsibilities. - [x] I read and followed the [Flutter Style Guide], including [Features we expect every widget to implement]. - [x] I signed the [CLA]. - [x] I listed at least one issue that this PR fixes in the description above. - [x] I updated/added relevant documentation (doc comments with `///`). - [x] I added new tests to check the change I am making, or this PR is [test-exempt]. - [x] All existing and new tests are passing. If you need help, consider asking for advice on the #hackers-new channel on [Discord]. <!-- Links --> [Contributor Guide]: https://github.com/flutter/flutter/wiki/Tree-hygiene#overview [Tree Hygiene]: https://github.com/flutter/flutter/wiki/Tree-hygiene [test-exempt]: https://github.com/flutter/flutter/wiki/Tree-hygiene#tests [Flutter Style Guide]: https://github.com/flutter/flutter/wiki/Style-guide-for-Flutter-repo [Features we expect every widget to implement]: https://github.com/flutter/flutter/wiki/Style-guide-for-Flutter-repo#features-we-expect-every-widget-to-implement [CLA]: https://cla.developers.google.com/ [flutter/tests]: https://github.com/flutter/tests [breaking change policy]: https://github.com/flutter/flutter/wiki/Tree-hygiene#handling-breaking-changes [Discord]: https://github.com/flutter/flutter/wiki/Chat
1 parent 58ba6c2 commit 57ad4ff

File tree

3 files changed

+92
-0
lines changed

3 files changed

+92
-0
lines changed

.ci.yaml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1567,6 +1567,16 @@ targets:
15671567
- bin/**
15681568
- .ci.yaml
15691569

1570+
- name: Linux_android hello_world_impeller
1571+
recipe: devicelab/devicelab_drone
1572+
presubmit: false
1573+
bringup: true
1574+
timeout: 60
1575+
properties:
1576+
tags: >
1577+
["devicelab", "android", "linux"]
1578+
task_name: hello_world_impeller
1579+
15701580
- name: Linux_android android_defines_test
15711581
recipe: devicelab/devicelab_drone
15721582
presubmit: true

TESTOWNERS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,7 @@
135135
/dev/devicelab/bin/tasks/fullscreen_textfield_perf__timeline_summary.dart @zanderso @flutter/engine
136136
/dev/devicelab/bin/tasks/hello_world__memory.dart @zanderso @flutter/engine
137137
/dev/devicelab/bin/tasks/hello_world_android__compile.dart @zanderso @flutter/tool
138+
/dev/devicelab/bin/tasks/hello_world_impeller.dart @gaaclarke @flutter/engine
138139
/dev/devicelab/bin/tasks/home_scroll_perf__timeline_summary.dart @zanderso @flutter/engine
139140
/dev/devicelab/bin/tasks/hot_mode_dev_cycle__benchmark.dart @eliasyishak @flutter/tool
140141
/dev/devicelab/bin/tasks/hybrid_android_views_integration_test.dart @stuartmorgan @flutter/plugin
Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
// Copyright 2014 The Flutter Authors. All rights reserved.
2+
// Use of this source code is governed by a BSD-style license that can be
3+
// found in the LICENSE file.
4+
5+
import 'dart:async' show Completer, StreamSubscription;
6+
import 'dart:io' show Directory, Process;
7+
8+
import 'package:flutter_devicelab/framework/devices.dart'
9+
show Device, DeviceOperatingSystem, deviceOperatingSystem, devices;
10+
import 'package:flutter_devicelab/framework/framework.dart' show task;
11+
import 'package:flutter_devicelab/framework/task_result.dart' show TaskResult;
12+
import 'package:flutter_devicelab/framework/utils.dart'
13+
show dir, flutter, flutterDirectory, inDirectory, startFlutter;
14+
import 'package:path/path.dart' as path;
15+
16+
Future<TaskResult> run() async {
17+
deviceOperatingSystem = DeviceOperatingSystem.android;
18+
final Device device = await devices.workingDevice;
19+
await device.unlock();
20+
final Directory appDir =
21+
dir(path.join(flutterDirectory.path, 'examples/hello_world'));
22+
23+
bool isUsingValidationLayers = false;
24+
bool hasValidationErrors = false;
25+
int impellerBackendCount = 0;
26+
final Completer<void> didReceiveBackendMessage = Completer<void>();
27+
28+
await inDirectory(appDir, () async {
29+
await flutter('packages', options: <String>['get']);
30+
31+
final StreamSubscription<String> adb = device.logcat.listen(
32+
(String data) {
33+
if (data.contains('Using the Impeller rendering backend')) {
34+
// Sometimes more than one of these will be printed out if there is a
35+
// fallback.
36+
if (!didReceiveBackendMessage.isCompleted) {
37+
didReceiveBackendMessage.complete();
38+
}
39+
impellerBackendCount += 1;
40+
}
41+
if (data.contains(
42+
'Using the Impeller rendering backend (Vulkan with Validation Layers)')) {
43+
isUsingValidationLayers = true;
44+
}
45+
// "ImpellerValidationBreak" comes from the engine:
46+
// https://github.com/flutter/engine/blob/4160ebacdae2081d6f3160432f5f0dd87dbebec1/impeller/base/validation.cc#L40
47+
if (data.contains('ImpellerValidationBreak')) {
48+
hasValidationErrors = true;
49+
}
50+
},
51+
);
52+
53+
final Process process = await startFlutter(
54+
'run',
55+
options: <String>[
56+
'--enable-impeller',
57+
'-d',
58+
device.deviceId,
59+
],
60+
);
61+
62+
await didReceiveBackendMessage.future;
63+
// Since we are waiting for the lack of errors, there is no determinate
64+
// amount of time we can wait.
65+
await Future<void>.delayed(const Duration(seconds: 30));
66+
process.stdin.write('q');
67+
await adb.cancel();
68+
});
69+
70+
if (!isUsingValidationLayers || impellerBackendCount != 1) {
71+
return TaskResult.failure('Not using Vulkan validation layers.');
72+
}
73+
if (hasValidationErrors){
74+
return TaskResult.failure('Impeller validation errors detected.');
75+
}
76+
return TaskResult.success(null);
77+
}
78+
79+
Future<void> main() async {
80+
await task(run);
81+
}

0 commit comments

Comments
 (0)