Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
[web_benchmarks] Removes deprecated APIs.
  • Loading branch information
ditman committed Feb 21, 2024
commit c599a913014f2e7529a2da72b1a6dfea7f6bb5a1
7 changes: 7 additions & 0 deletions packages/web_benchmarks/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
## 1.2.1

* Removes usages of the following deprecated APIs:
* `window` from `dart:ui` (replaced by `PlatformDispatcher.instance.implicitView`)
* `HttpRequest` from `package:web` (reimplemented with an internal method)
* Removes unused dependency on `package:http`.

## 1.2.0

* Updates to web code to package `web: ^0.5.0`.
Expand Down
16 changes: 10 additions & 6 deletions packages/web_benchmarks/lib/client.dart
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,7 @@ class LocalBenchmarkServerClient {
/// DevTools Protocol.
Future<void> startPerformanceTracing(String? benchmarkName) async {
_checkNotManualMode();
await HttpRequest.request(
await _requestXhr(
'/start-performance-tracing?label=$benchmarkName',
method: 'POST',
mimeType: 'application/json',
Expand All @@ -328,7 +328,7 @@ class LocalBenchmarkServerClient {
/// Stops the performance tracing session started by [startPerformanceTracing].
Future<void> stopPerformanceTracing() async {
_checkNotManualMode();
await HttpRequest.request(
await _requestXhr(
'/stop-performance-tracing',
method: 'POST',
mimeType: 'application/json',
Expand Down Expand Up @@ -356,7 +356,7 @@ class LocalBenchmarkServerClient {
/// The server will halt the devicelab task and log the error.
Future<void> reportError(dynamic error, StackTrace stackTrace) async {
_checkNotManualMode();
await HttpRequest.request(
await _requestXhr(
'/on-error',
method: 'POST',
mimeType: 'application/json',
Expand All @@ -370,7 +370,7 @@ class LocalBenchmarkServerClient {
/// Reports a message about the demo to the benchmark server.
Future<void> printToConsole(String report) async {
_checkNotManualMode();
await HttpRequest.request(
await _requestXhr(
'/print-to-console',
method: 'POST',
mimeType: 'text/plain',
Expand All @@ -384,7 +384,7 @@ class LocalBenchmarkServerClient {
String url, {
required String method,
required String mimeType,
required String sendData,
String? sendData,
}) {
final Completer<XMLHttpRequest> completer = Completer<XMLHttpRequest>();
final XMLHttpRequest xhr = XMLHttpRequest();
Expand All @@ -394,7 +394,11 @@ class LocalBenchmarkServerClient {
completer.complete(xhr);
});
xhr.onError.listen(completer.completeError);
xhr.send(sendData.toJS);
if (sendData != null) {
xhr.send(sendData.toJS);
} else {
xhr.send();
}
return completer.future;
}
}
Expand Down
5 changes: 4 additions & 1 deletion packages/web_benchmarks/lib/src/recorder.dart
Original file line number Diff line number Diff line change
Expand Up @@ -248,14 +248,17 @@ abstract class SceneBuilderRecorder extends Recorder {
}
};
PlatformDispatcher.instance.onDrawFrame = () {
final FlutterView? view = PlatformDispatcher.instance.implicitView;
try {
_profile.record('drawFrameDuration', () {
final SceneBuilder sceneBuilder = SceneBuilder();
onDrawFrame(sceneBuilder);
_profile.record('sceneBuildDuration', () {
final Scene scene = sceneBuilder.build();
_profile.record('windowRenderDuration', () {
window.render(scene);
assert(view != null,
'Cannot profile windowRenderDuration on a null View.');
view!.render(scene);
}, reported: false);
}, reported: false);
}, reported: true);
Expand Down
3 changes: 1 addition & 2 deletions packages/web_benchmarks/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: web_benchmarks
description: A benchmark harness for performance-testing Flutter apps in Chrome.
repository: https://github.com/flutter/packages/tree/main/packages/web_benchmarks
issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+web_benchmarks%22
version: 1.2.0
version: 1.2.1

environment:
sdk: ^3.3.0
Expand All @@ -14,7 +14,6 @@ dependencies:
sdk: flutter
flutter_test:
sdk: flutter
http: ^1.0.0
logging: ^1.0.2
meta: ^1.7.0
path: ^1.8.0
Expand Down