Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[web_benchmarks] Make package compatible with Chromium v89+ #518

Merged
merged 15 commits into from
Feb 17, 2022
Merged
Changes from 7 commits
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
1 change: 1 addition & 0 deletions packages/web_benchmarks/AUTHORS
Original file line number Diff line number Diff line change
@@ -5,3 +5,4 @@

Google Inc.
The Chromium Authors
Aman Verma verma1090aman@gmail.com
4 changes: 4 additions & 0 deletions packages/web_benchmarks/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 0.0.7

* Updated BlinkTraceEvents to match with changes in chromium v84+
amanv8060 marked this conversation as resolved.
Show resolved Hide resolved

## 0.0.6

* Update implementation of `_RecordingWidgetsBinding` to match the [new Binding API](https://github.com/flutter/flutter/blob/master/packages/flutter/lib/src/foundation/binding.dart#L96-L128)
7 changes: 5 additions & 2 deletions packages/web_benchmarks/lib/src/browser.dart
Original file line number Diff line number Diff line change
@@ -554,7 +554,8 @@ class BlinkTraceEvent {
bool get isBeginFrame =>
ph == 'X' &&
(name == 'WebViewImpl::beginFrame' ||
name == 'WebFrameWidgetBase::BeginMainFrame');
name == 'WebFrameWidgetBase::BeginMainFrame' ||
name == 'WebFrameWidgetImpl::BeginMainFrame');

/// An "update all lifecycle phases" event contains UI thread computations
/// related to an animation frame that's outside the scripting phase.
@@ -564,7 +565,9 @@ class BlinkTraceEvent {
///
/// This event is a duration event that has its `tdur` populated.
bool get isUpdateAllLifecyclePhases =>
ph == 'X' && name == 'WebViewImpl::updateAllLifecyclePhases';
ph == 'X' &&
(name == 'WebViewImpl::updateAllLifecyclePhases' ||
name == 'WebFrameWidgetImpl::UpdateLifecycle');

/// Whether this is the beginning of a "measured_frame" event.
///
2 changes: 1 addition & 1 deletion packages/web_benchmarks/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -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: 0.0.6
version: 0.0.7

environment:
sdk: ">=2.7.0 <3.0.0"
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// Copyright 2013 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

import 'package:flutter_test/flutter_test.dart';

void main() {
test('Tell the user how to run tests within "testing" directory', () {
print('---');
print('This package also has client-server tests.');
print('Run `dart testing/web_benchmarks_test.dart` to run those.');
print('---');
});
}
55 changes: 55 additions & 0 deletions packages/web_benchmarks/test/src/browser_test.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
// Copyright 2013 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

import 'package:flutter_test/flutter_test.dart';

import 'package:web_benchmarks/src/browser.dart';

import 'browser_test_json_samples.dart';

void main() {
group('BlinkTraceEvent works with Chrome 89+', () {
ditman marked this conversation as resolved.
Show resolved Hide resolved
// Used to test 'false' results
final BlinkTraceEvent unrelatedPhX =
BlinkTraceEvent.fromJson(unrelatedPhXJson);
final BlinkTraceEvent anotherUnrelated =
BlinkTraceEvent.fromJson(anotherUnrelatedJson);

test('isBeginFrame', () {
final BlinkTraceEvent event =
BlinkTraceEvent.fromJson(beginMainFrameJson);

expect(event.isBeginFrame, isTrue);
expect(unrelatedPhX.isBeginFrame, isFalse);
expect(anotherUnrelated.isBeginFrame, isFalse);
});

test('isUpdateAllLifecyclePhases', () {
final BlinkTraceEvent event =
BlinkTraceEvent.fromJson(updateLifecycleJson);

expect(event.isUpdateAllLifecyclePhases, isTrue);
expect(unrelatedPhX.isUpdateAllLifecyclePhases, isFalse);
expect(anotherUnrelated.isUpdateAllLifecyclePhases, isFalse);
});

test('isBeginMeasuredFrame', () {
final BlinkTraceEvent event =
BlinkTraceEvent.fromJson(beginMeasuredFrameJson);

expect(event.isBeginMeasuredFrame, isTrue);
expect(unrelatedPhX.isBeginMeasuredFrame, isFalse);
expect(anotherUnrelated.isBeginMeasuredFrame, isFalse);
});

test('isEndMeasuredFrame', () {
final BlinkTraceEvent event =
BlinkTraceEvent.fromJson(endMeasuredFrameJson);

expect(event.isEndMeasuredFrame, isTrue);
expect(unrelatedPhX.isEndMeasuredFrame, isFalse);
expect(anotherUnrelated.isEndMeasuredFrame, isFalse);
});
});
}
101 changes: 101 additions & 0 deletions packages/web_benchmarks/test/src/browser_test_json_samples.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
// Copyright 2013 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

import 'dart:convert' show jsonDecode;

// JSON Event samples taken from running an instrumented version of the
// integration tests of this package that dumped all the data as captured.

/// To test isBeginFrame.
final Map<String, dynamic> beginMainFrameJson = jsonDecode('''
ditman marked this conversation as resolved.
Show resolved Hide resolved
{
"args": {
"frameTime": 2338687248768
},
"cat": "blink",
"dur": 6836,
"name": "WebFrameWidgetImpl::BeginMainFrame",
"ph": "X",
"pid": 1367081,
"tdur": 393,
"tid": 1,
"ts": 2338687258440,
"tts": 375499
}
''');

/// To test isUpdateAllLifecyclePhases.
final Map<String, dynamic> updateLifecycleJson = jsonDecode('''
{
"args": {},
"cat": "blink",
"dur": 103,
"name": "WebFrameWidgetImpl::UpdateLifecycle",
"ph": "X",
"pid": 1367081,
"tdur": 102,
"tid": 1,
"ts": 2338687265284,
"tts": 375900
}
''');

/// To test isBeginMeasuredFrame.
final Map<String, dynamic> beginMeasuredFrameJson = jsonDecode('''
{
"args": {},
"cat": "blink.user_timing",
"id": "0xea2a8b45",
"name": "measured_frame",
"ph": "b",
"pid": 1367081,
"scope": "blink.user_timing",
"tid": 1,
"ts": 2338687265932
}
''');

/// To test isEndMeasuredFrame.
final Map<String, dynamic> endMeasuredFrameJson = jsonDecode('''
{
"args": {},
"cat": "blink.user_timing",
"id": "0xea2a8b45",
"name": "measured_frame",
"ph": "e",
"pid": 1367081,
"scope": "blink.user_timing",
"tid": 1,
"ts": 2338687440485
}
''');

final Map<String, dynamic> unrelatedPhXJson = jsonDecode('''
{
"args": {},
"cat": "blink,rail",
"dur": 2,
"name": "PageAnimator::serviceScriptedAnimations",
"ph": "X",
"pid": 1367081,
"tdur": 2,
"tid": 1,
"ts": 2338691143317,
"tts": 1685405
}
''');

final Map<String, dynamic> anotherUnrelatedJson = jsonDecode('''
{
"args": {
"sort_index": -1
},
"cat": "__metadata",
"name": "thread_sort_index",
"ph": "M",
"pid": 1367081,
"tid": 1,
"ts": 2338692906482
}
''');
32 changes: 32 additions & 0 deletions packages/web_benchmarks/testing/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# `testing` README

## How to run the `testing` directory tests

The tests contained in this directory use a client-server model, similar to what
the integration_test package does. In order to run the tests inside `testing`,
do the following:

* Install Chrome in a way that [tests can find it](https://github.com/flutter/packages/blob/a5a4479e176c5e909dd5d961c2c79b61ce1bf1bd/packages/web_benchmarks/lib/src/browser.dart#L216).

* Fetch dependencies for the `test_app` directory inside `testing`:

```bash
cd testing/test_app
flutter pub get
```

* Fetch dependencies for the `web_benchmarks` directory:

```bash
cd ../..
flutter pub get
```

* Run the tests with `dart`:

```bash
dart testing/web_benchmarks_test.dart
```

_(If the above stops working, take a look at what the [`web_benchmarks_test` Cirrus step](https://github.com/flutter/packages/blob/a5a4479e176c5e909dd5d961c2c79b61ce1bf1bd/.cirrus.yml#L102-L113)
is currently doing, and update this document accordingly!)_