Skip to content

Commit 93c0c04

Browse files
authored
[devicelab] Web benchmarks now run on Chromium 89+ (flutter#98629)
1 parent e6b3095 commit 93c0c04

File tree

3 files changed

+176
-2
lines changed

3 files changed

+176
-2
lines changed

dev/devicelab/lib/framework/browser.dart

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -505,17 +505,34 @@ class BlinkTraceEvent {
505505
/// This event does not include non-UI thread scripting, such as web workers,
506506
/// service workers, and CSS Paint paintlets.
507507
///
508+
/// WebViewImpl::beginFrame was used in earlier versions of Chrome, kept
509+
/// for compatibility.
510+
///
508511
/// This event is a duration event that has its `tdur` populated.
509-
bool get isBeginFrame => ph == 'X' && name == 'WebViewImpl::beginFrame';
512+
bool get isBeginFrame {
513+
return ph == 'X' && (
514+
name == 'WebViewImpl::beginFrame' ||
515+
name == 'WebFrameWidgetBase::BeginMainFrame' ||
516+
name == 'WebFrameWidgetImpl::BeginMainFrame'
517+
);
518+
}
510519

511520
/// An "update all lifecycle phases" event contains UI thread computations
512521
/// related to an animation frame that's outside the scripting phase.
513522
///
514523
/// This event includes style recalculation, layer tree update, layout,
515524
/// painting, and parts of compositing work.
516525
///
526+
/// WebViewImpl::updateAllLifecyclePhases was used in earlier versions of
527+
/// Chrome, kept for compatibility.
528+
///
517529
/// This event is a duration event that has its `tdur` populated.
518-
bool get isUpdateAllLifecyclePhases => ph == 'X' && name == 'WebViewImpl::updateAllLifecyclePhases';
530+
bool get isUpdateAllLifecyclePhases {
531+
return ph == 'X' && (
532+
name == 'WebViewImpl::updateAllLifecyclePhases' ||
533+
name == 'WebFrameWidgetImpl::UpdateLifecycle'
534+
);
535+
}
519536

520537
/// Whether this is the beginning of a "measured_frame" event.
521538
///
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
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 'package:flutter_devicelab/framework/browser.dart';
6+
7+
import '../common.dart';
8+
import 'browser_test_json_samples.dart';
9+
10+
void main() {
11+
group('BlinkTraceEvent works with Chrome 89+', () {
12+
// Used to test 'false' results
13+
final BlinkTraceEvent unrelatedPhX =
14+
BlinkTraceEvent.fromJson(unrelatedPhXJson);
15+
final BlinkTraceEvent anotherUnrelated =
16+
BlinkTraceEvent.fromJson(anotherUnrelatedJson);
17+
18+
test('isBeginFrame', () {
19+
final BlinkTraceEvent event =
20+
BlinkTraceEvent.fromJson(beginMainFrameJson_89plus);
21+
22+
expect(event.isBeginFrame, isTrue);
23+
expect(unrelatedPhX.isBeginFrame, isFalse);
24+
expect(anotherUnrelated.isBeginFrame, isFalse);
25+
});
26+
27+
test('isUpdateAllLifecyclePhases', () {
28+
final BlinkTraceEvent event =
29+
BlinkTraceEvent.fromJson(updateLifecycleJson_89plus);
30+
31+
expect(event.isUpdateAllLifecyclePhases, isTrue);
32+
expect(unrelatedPhX.isUpdateAllLifecyclePhases, isFalse);
33+
expect(anotherUnrelated.isUpdateAllLifecyclePhases, isFalse);
34+
});
35+
36+
test('isBeginMeasuredFrame', () {
37+
final BlinkTraceEvent event =
38+
BlinkTraceEvent.fromJson(beginMeasuredFrameJson_89plus);
39+
40+
expect(event.isBeginMeasuredFrame, isTrue);
41+
expect(unrelatedPhX.isBeginMeasuredFrame, isFalse);
42+
expect(anotherUnrelated.isBeginMeasuredFrame, isFalse);
43+
});
44+
45+
test('isEndMeasuredFrame', () {
46+
final BlinkTraceEvent event =
47+
BlinkTraceEvent.fromJson(endMeasuredFrameJson_89plus);
48+
49+
expect(event.isEndMeasuredFrame, isTrue);
50+
expect(unrelatedPhX.isEndMeasuredFrame, isFalse);
51+
expect(anotherUnrelated.isEndMeasuredFrame, isFalse);
52+
});
53+
});
54+
}
Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
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:convert' show jsonDecode;
6+
7+
// JSON Event samples taken from running an instrumented version of the
8+
// integration tests of this package that dumped all the data as captured.
9+
10+
/// To test isBeginFrame. (Sampled from Chrome 89+)
11+
final Map<String, Object?> beginMainFrameJson_89plus = jsonDecode('''
12+
{
13+
"args": {
14+
"frameTime": 2338687248768
15+
},
16+
"cat": "blink",
17+
"dur": 6836,
18+
"name": "WebFrameWidgetImpl::BeginMainFrame",
19+
"ph": "X",
20+
"pid": 1367081,
21+
"tdur": 393,
22+
"tid": 1,
23+
"ts": 2338687258440,
24+
"tts": 375499
25+
}
26+
''') as Map<String, Object?>;
27+
28+
/// To test isUpdateAllLifecyclePhases. (Sampled from Chrome 89+)
29+
final Map<String, Object?> updateLifecycleJson_89plus = jsonDecode('''
30+
{
31+
"args": {},
32+
"cat": "blink",
33+
"dur": 103,
34+
"name": "WebFrameWidgetImpl::UpdateLifecycle",
35+
"ph": "X",
36+
"pid": 1367081,
37+
"tdur": 102,
38+
"tid": 1,
39+
"ts": 2338687265284,
40+
"tts": 375900
41+
}
42+
''') as Map<String, Object?>;
43+
44+
/// To test isBeginMeasuredFrame. (Sampled from Chrome 89+)
45+
final Map<String, Object?> beginMeasuredFrameJson_89plus = jsonDecode('''
46+
{
47+
"args": {},
48+
"cat": "blink.user_timing",
49+
"id": "0xea2a8b45",
50+
"name": "measured_frame",
51+
"ph": "b",
52+
"pid": 1367081,
53+
"scope": "blink.user_timing",
54+
"tid": 1,
55+
"ts": 2338687265932
56+
}
57+
''') as Map<String, Object?>;
58+
59+
/// To test isEndMeasuredFrame. (Sampled from Chrome 89+)
60+
final Map<String, Object?> endMeasuredFrameJson_89plus = jsonDecode('''
61+
{
62+
"args": {},
63+
"cat": "blink.user_timing",
64+
"id": "0xea2a8b45",
65+
"name": "measured_frame",
66+
"ph": "e",
67+
"pid": 1367081,
68+
"scope": "blink.user_timing",
69+
"tid": 1,
70+
"ts": 2338687440485
71+
}
72+
''') as Map<String, Object?>;
73+
74+
/// An unrelated data frame to test negative cases.
75+
final Map<String, Object?> unrelatedPhXJson = jsonDecode('''
76+
{
77+
"args": {},
78+
"cat": "blink,rail",
79+
"dur": 2,
80+
"name": "PageAnimator::serviceScriptedAnimations",
81+
"ph": "X",
82+
"pid": 1367081,
83+
"tdur": 2,
84+
"tid": 1,
85+
"ts": 2338691143317,
86+
"tts": 1685405
87+
}
88+
''') as Map<String, Object?>;
89+
90+
/// Another unrelated data frame to test negative cases.
91+
final Map<String, Object?> anotherUnrelatedJson = jsonDecode('''
92+
{
93+
"args": {
94+
"sort_index": -1
95+
},
96+
"cat": "__metadata",
97+
"name": "thread_sort_index",
98+
"ph": "M",
99+
"pid": 1367081,
100+
"tid": 1,
101+
"ts": 2338692906482
102+
}
103+
''') as Map<String, Object?>;

0 commit comments

Comments
 (0)