perf(editor): integrate native preview and prioritize timeline interaction
Gitea CI / Check code and tests (pull_request) Failing after 7m0s
Gitea CI / Gitea CI passed (pull_request) Failing after 5s
Gitea CI / Build Android APK (pull_request) Skipped
Gitea CI / Build Windows x64 app (pull_request) Skipped
Gitea CI / Audit and package Windows x64 (pull_request) Skipped
Gitea CI / Assemble and validate CI artifacts (pull_request) Skipped
Gitea CI / Check code and tests (pull_request) Failing after 7m0s
Gitea CI / Gitea CI passed (pull_request) Failing after 5s
Gitea CI / Build Android APK (pull_request) Skipped
Gitea CI / Build Windows x64 app (pull_request) Skipped
Gitea CI / Audit and package Windows x64 (pull_request) Skipped
Gitea CI / Assemble and validate CI artifacts (pull_request) Skipped
This commit is contained in:
1 parent
0ecf920669
commit
4f746be301
34 files changed
+3278
-145
No files matched your search
@@ -0,0 +1,62 @@
|
||||
import 'dart:async';
|
||||
import 'dart:io';
|
||||
|
||||
import 'config.dart';
|
||||
|
||||
/// Optional desktop capture process; its path is supplied explicitly.
|
||||
class BenchCapture {
|
||||
BenchCapture._(this.output, this.process);
|
||||
final Directory output;
|
||||
final Process process;
|
||||
|
||||
static Future<BenchCapture?> start(
|
||||
ViewportBenchConfig config,
|
||||
Directory output,
|
||||
) async {
|
||||
if (config.nativeOnly) return null;
|
||||
final helper = config.captureHelper!;
|
||||
final probe = await Process.run(helper, ['$pid']);
|
||||
if (probe.exitCode != 0) {
|
||||
throw StateError('Capture probe failed: ${probe.stderr}');
|
||||
}
|
||||
final line = probe.stdout
|
||||
.toString()
|
||||
.split('\n')
|
||||
.singleWhere((s) => s.startsWith('CutdexD3D11Preview 1 '));
|
||||
final rect = line.trim().split(' ').skip(2).map(int.parse).toList();
|
||||
final process = await Process.start(helper, [
|
||||
output.path,
|
||||
'$pid',
|
||||
'${rect[0] + 8}',
|
||||
'${rect[1] + 8}',
|
||||
'${rect[2] - 8}',
|
||||
'${rect[3] - 8}',
|
||||
]);
|
||||
unawaited(process.stdout.drain<void>());
|
||||
unawaited(process.stderr.drain<void>());
|
||||
final capture = BenchCapture._(output, process);
|
||||
for (
|
||||
var i = 0;
|
||||
!await File('${output.path}/capture-ready').exists() && i < 500;
|
||||
i++
|
||||
) {
|
||||
await Future<void>.delayed(const Duration(milliseconds: 10));
|
||||
}
|
||||
if (!await File('${output.path}/capture-ready').exists()) {
|
||||
await capture.stop();
|
||||
throw StateError('Capture not ready');
|
||||
}
|
||||
return capture;
|
||||
}
|
||||
|
||||
Future<void> stop() async {
|
||||
await File('${output.path}/capture-stop').writeAsString('stop');
|
||||
try {
|
||||
final code = await process.exitCode.timeout(const Duration(seconds: 10));
|
||||
if (code != 0) throw StateError('Capture exit $code');
|
||||
} on TimeoutException {
|
||||
process.kill();
|
||||
rethrow;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user