Unverified Commit 3001d6ab authored by joshualitt's avatar joshualitt Committed by GitHub

Revert "Migrate benchmarks to package:web" (#127207)

Reverts flutter/flutter#126848

Triggered some kind of measuring discrepancy / performance regression.
parent 972b4474
...@@ -2,12 +2,10 @@ ...@@ -2,12 +2,10 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
import 'dart:js_interop'; import 'dart:html' as html;
import 'dart:typed_data'; import 'dart:typed_data';
import 'dart:ui' as ui; import 'dart:ui' as ui;
import 'package:web/web.dart' as web;
import 'recorder.dart'; import 'recorder.dart';
// Measures the performance of image decoding. // Measures the performance of image decoding.
...@@ -45,11 +43,8 @@ class BenchImageDecoding extends RawRecorder { ...@@ -45,11 +43,8 @@ class BenchImageDecoding extends RawRecorder {
return; return;
} }
for (final String imageUrl in _imageUrls) { for (final String imageUrl in _imageUrls) {
final Future<JSAny?> fetchFuture = web.window.fetch(imageUrl.toJS).toDart; final html.Body image = await html.window.fetch(imageUrl) as html.Body;
final web.Body image = (await fetchFuture)! as web.Body; _imageData.add((await image.arrayBuffer() as ByteBuffer).asUint8List());
final Future<JSAny?> imageFuture = image.arrayBuffer().toDart;
final JSArrayBuffer imageBuffer = (await imageFuture)! as JSArrayBuffer;
_imageData.add(imageBuffer.toDart.asUint8List());
} }
} }
......
...@@ -3,32 +3,30 @@ ...@@ -3,32 +3,30 @@
// found in the LICENSE file. // found in the LICENSE file.
import 'dart:async'; import 'dart:async';
import 'dart:js_interop'; import 'dart:html' as html;
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:web/web.dart' as web;
// TODO(mdebbar): flutter/flutter#55000 Remove this conditional import once // TODO(mdebbar): flutter/flutter#55000 Remove this conditional import once
// web-only dart:ui_web APIs are exposed from a dedicated place. // web-only dart:ui_web APIs are exposed from a dedicated place.
import 'platform_views/non_web.dart' import 'platform_views/non_web.dart'
if (dart.library.js_interop) 'platform_views/web.dart'; if (dart.library.html) 'platform_views/web.dart';
import 'recorder.dart'; import 'recorder.dart';
const String benchmarkViewType = 'benchmark_element'; const String benchmarkViewType = 'benchmark_element';
void _registerFactory() { void _registerFactory() {
platformViewRegistry.registerViewFactory(benchmarkViewType, (int viewId) { platformViewRegistry.registerViewFactory(benchmarkViewType, (int viewId) {
final web.HTMLElement htmlElement = web.document.createElement('div'.toJS) final html.Element htmlElement = html.DivElement();
as web.HTMLDivElement; htmlElement.id = '${benchmarkViewType}_$viewId';
htmlElement.id = '${benchmarkViewType}_$viewId'.toJS; htmlElement.innerText = 'Google';
htmlElement.innerText = 'Google'.toJS;
htmlElement.style htmlElement.style
..setProperty('width'.toJS, '100%'.toJS) ..width = '100%'
..setProperty('height'.toJS, '100%'.toJS) ..height = '100%'
..setProperty('color'.toJS, 'black'.toJS) ..color = 'black'
..setProperty('backgroundColor'.toJS, 'rgba(0, 255, 0, .5)'.toJS) ..backgroundColor = 'rgba(0, 255, 0, .5)'
..setProperty('textAlign'.toJS, 'center'.toJS) ..textAlign = 'center'
..setProperty('border'.toJS, '1px solid black'.toJS); ..border = '1px solid black';
return htmlElement; return htmlElement;
}); });
} }
......
...@@ -3,11 +3,8 @@ ...@@ -3,11 +3,8 @@
// found in the LICENSE file. // found in the LICENSE file.
import 'dart:async'; import 'dart:async';
import 'dart:js_interop'; import 'dart:html' as html;
// The analyzer currently thinks `js_interop_unsafe` is unused, but it is used import 'dart:js_util' as js_util;
// for `JSObject.[]=`.
// ignore: unused_import
import 'dart:js_interop_unsafe';
import 'dart:math' as math; import 'dart:math' as math;
import 'dart:ui'; import 'dart:ui';
...@@ -18,7 +15,6 @@ import 'package:flutter/scheduler.dart'; ...@@ -18,7 +15,6 @@ import 'package:flutter/scheduler.dart';
import 'package:flutter/services.dart'; import 'package:flutter/services.dart';
import 'package:flutter/widgets.dart'; import 'package:flutter/widgets.dart';
import 'package:meta/meta.dart'; import 'package:meta/meta.dart';
import 'package:web/web.dart' as web;
/// The default number of samples from warm-up iterations. /// The default number of samples from warm-up iterations.
/// ///
...@@ -1257,7 +1253,7 @@ void startMeasureFrame(Profile profile) { ...@@ -1257,7 +1253,7 @@ void startMeasureFrame(Profile profile) {
if (!profile.isWarmingUp) { if (!profile.isWarmingUp) {
// Tell the browser to mark the beginning of the frame. // Tell the browser to mark the beginning of the frame.
web.window.performance.mark('measured_frame_start#$_currentFrameNumber'.toJS); html.window.performance.mark('measured_frame_start#$_currentFrameNumber');
_isMeasuringFrame = true; _isMeasuringFrame = true;
} }
...@@ -1280,11 +1276,11 @@ void endMeasureFrame() { ...@@ -1280,11 +1276,11 @@ void endMeasureFrame() {
if (_isMeasuringFrame) { if (_isMeasuringFrame) {
// Tell the browser to mark the end of the frame, and measure the duration. // Tell the browser to mark the end of the frame, and measure the duration.
web.window.performance.mark('measured_frame_end#$_currentFrameNumber'.toJS); html.window.performance.mark('measured_frame_end#$_currentFrameNumber');
web.window.performance.measure( html.window.performance.measure(
'measured_frame'.toJS, 'measured_frame',
'measured_frame_start#$_currentFrameNumber'.toJS, 'measured_frame_start#$_currentFrameNumber',
'measured_frame_end#$_currentFrameNumber'.toJS, 'measured_frame_end#$_currentFrameNumber',
); );
// Increment the current frame number. // Increment the current frame number.
...@@ -1314,10 +1310,7 @@ void registerEngineBenchmarkValueListener(String name, EngineBenchmarkValueListe ...@@ -1314,10 +1310,7 @@ void registerEngineBenchmarkValueListener(String name, EngineBenchmarkValueListe
if (_engineBenchmarkListeners.isEmpty) { if (_engineBenchmarkListeners.isEmpty) {
// The first listener is being registered. Register the global listener. // The first listener is being registered. Register the global listener.
web.window['_flutter_internal_on_benchmark'.toJS] = js_util.setProperty(html.window, '_flutter_internal_on_benchmark', _dispatchEngineBenchmarkValue);
// Upcast to [Object] to export.
// ignore: unnecessary_cast
(_dispatchEngineBenchmarkValue as Object).toJS;
} }
_engineBenchmarkListeners[name] = listener; _engineBenchmarkListeners[name] = listener;
...@@ -1328,7 +1321,7 @@ void stopListeningToEngineBenchmarkValues(String name) { ...@@ -1328,7 +1321,7 @@ void stopListeningToEngineBenchmarkValues(String name) {
_engineBenchmarkListeners.remove(name); _engineBenchmarkListeners.remove(name);
if (_engineBenchmarkListeners.isEmpty) { if (_engineBenchmarkListeners.isEmpty) {
// The last listener unregistered. Remove the global listener. // The last listener unregistered. Remove the global listener.
web.window['_flutter_internal_on_benchmark'.toJS] = null; js_util.setProperty(html.window, '_flutter_internal_on_benchmark', null);
} }
} }
......
...@@ -18,8 +18,6 @@ dependencies: ...@@ -18,8 +18,6 @@ dependencies:
# flutter update-packages --force-upgrade # flutter update-packages --force-upgrade
flutter_gallery_assets: 1.0.2 flutter_gallery_assets: 1.0.2
web: 0.1.2-beta
async: 2.11.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" async: 2.11.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
boolean_selector: 2.1.1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" boolean_selector: 2.1.1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
characters: 1.3.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" characters: 1.3.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
...@@ -211,4 +209,4 @@ flutter: ...@@ -211,4 +209,4 @@ flutter:
fonts: fonts:
- asset: packages/flutter_gallery_assets/fonts/GalleryIcons.ttf - asset: packages/flutter_gallery_assets/fonts/GalleryIcons.ttf
# PUBSPEC CHECKSUM: fdda # PUBSPEC CHECKSUM: 1586
...@@ -21,7 +21,6 @@ dependencies: ...@@ -21,7 +21,6 @@ dependencies:
shelf_static: 1.1.2 shelf_static: 1.1.2
stack_trace: 1.11.0 stack_trace: 1.11.0
vm_service: 11.6.0 vm_service: 11.6.0
web: 0.1.2-beta
webkit_inspection_protocol: 1.2.0 webkit_inspection_protocol: 1.2.0
_discoveryapis_commons: 1.0.5 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" _discoveryapis_commons: 1.0.5 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
...@@ -70,4 +69,4 @@ dev_dependencies: ...@@ -70,4 +69,4 @@ dev_dependencies:
watcher: 1.1.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" watcher: 1.1.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
web_socket_channel: 2.4.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" web_socket_channel: 2.4.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
# PUBSPEC CHECKSUM: f681 # PUBSPEC CHECKSUM: 022d
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment