Skip to content

Commit 74d32ec

Browse files
author
nturgut
authored
[web] update chrome version (flutter#20470)
* update chrome version, should be merged after recipe changes * changing directory to use chrome driver in LUCI * changing directory path's order * add cipd packages's chrome version for mac * addressing reviewer comments * more documentation. update readme * remove late since it didn't build. remove distinction in paths for local and LUCI. * addressing reviewer comments. (non-null fields needs rechanging) * addressing reviewer comments. adding 2.6 on files missing the notation
1 parent 8540e00 commit 74d32ec

File tree

5 files changed

+77
-20
lines changed

5 files changed

+77
-20
lines changed

lib/web_ui/dev/README.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,7 @@ flutter/goldens updating the screenshots. Then update this file pointing to
140140
the new revision.
141141

142142
## Developing the `felt` tool
143+
143144
If you are making changes in the `felt` tool itself, you need to be aware of Dart snapshots. We create a Dart snapshot of the `felt` tool to make the startup faster.
144145

145146
To make sure you are running the `felt` tool with your changes included, you would need to stop using the snapshot. This can be achived through the environment variable `FELT_USE_SNAPSHOT`:
@@ -155,3 +156,22 @@ FELT_USE_SNAPSHOT=0 felt <command>
155156
```
156157

157158
_**Note**: if `FELT_USE_SNAPSHOT` is omitted or has any value other than "false" or "0", the snapshot mode will be enabled._
159+
160+
## Upgrade Browser Version
161+
162+
Since the engine code and infra recipes do not live in the same repository there are few steps to follow in order to upgrade a browser's version. For now these instructins are most relevant to Chrome.
163+
164+
1. Dowload the binaries for the new browser/driver for each operaing system (macOS, linux, windows).
165+
2. Create CIPD packages for these packages. (More documentation is available for Googlers. go/cipd-flutter-web)
166+
3. Add the new browser version to the recipe. Do not remove the old one. This recipe will apply to all PRs as soon as it is merged. However, not all PRs will have the up to date code for a while.
167+
4. Update the version in this repo. Do this by changing the related fields in `browser_lock.yaml` file.
168+
5. After a few days don't forget to remove the old version from the LUCI recipe.
169+
170+
Note that for LUCI builders, both unit and integration tests are using the same browser.
171+
172+
Some useful links:
173+
174+
1. For Chrome downloads [link](https://commondatastorage.googleapis.com/chromium-browser-snapshots/index.html)
175+
2. Browser and driver CIPD [packages](https://chrome-infra-packages.appspot.com/p/flutter_internal) (Note: Access rights are restricted for these packages.)
176+
3. LUCI web [recipe](https://flutter.googlesource.com/recipes/+/refs/heads/master/recipes/web_engine.py)
177+
4. More general reading on CIPD packages [link](https://chromium.googlesource.com/chromium/src.git/+/master/docs/cipd.md#What-is-CIPD)

lib/web_ui/dev/browser_lock.yaml

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,21 @@
1+
## Driver version in use.
2+
## For an integration test to run, the browser's major version and the driver's
3+
## major version should be equal. Please make sure the major version of
4+
## the binary for `chrome` is the same with `required_driver_version`.
5+
## (Major version meaning: For a browser that has version 13.0.5, the major
6+
## version is 13.)
7+
## Please refer to README's `Upgrade Browser Version` section for more details
8+
## on how to update the version number.
9+
required_driver_version:
10+
## Make sure the major version of the binary in `browser_lock.yaml` is the
11+
## same for Chrome.
12+
chrome: '84'
113
chrome:
214
# It seems Chrome can't always release from the same build for all operating
315
# systems, so we specify per-OS build number.
4-
# Note: 741412 binary is for Chrome Version 82. Driver for Chrome version 83
5-
# is not working with chrome.binary option.
6-
Linux: 741412
7-
Mac: 735194
8-
Win: 768975
16+
Linux: 768968 # Major version 84
17+
Mac: 768985 # Major version 84
18+
Win: 768975 # Major version 84
919
firefox:
1020
version: '72.0'
1121
edge:

lib/web_ui/dev/driver_manager.dart

Lines changed: 40 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
// Use of this source code is governed by a BSD-style license that can be
33
// found in the LICENSE file.
44

5+
// @dart = 2.6
56
import 'dart:io' as io;
67

78
import 'package:meta/meta.dart';
@@ -20,19 +21,44 @@ import 'utils.dart';
2021
///
2122
/// This manager can be used for both macOS and Linux.
2223
class ChromeDriverManager extends DriverManager {
23-
ChromeDriverManager(String browser) : super(browser);
24+
/// Directory which contains the Chrome's major version.
25+
///
26+
/// On LUCI we are using the CIPD packages to control Chrome binaries we use.
27+
/// There will be multiple CIPD packages loaded at the same time. Yaml file
28+
/// `driver_version.yaml` contains the version number we want to use.
29+
///
30+
/// Initialized to the current first to avoid the `Non-nullable` error.
31+
// TODO: https://github.com/flutter/flutter/issues/53179. Local integration
32+
// tests are still using the system Chrome.
33+
io.Directory _browserDriverDirWithVersion;
34+
35+
ChromeDriverManager(String browser) : super(browser) {
36+
final io.File lockFile = io.File(pathlib.join(
37+
environment.webUiRootDir.path, 'dev', 'browser_lock.yaml'));
38+
final YamlMap _configuration =
39+
loadYaml(lockFile.readAsStringSync()) as YamlMap;
40+
final String requiredChromeDriverVersion =
41+
_configuration['required_driver_version']['chrome'] as String;
42+
print('INFO: Major version for Chrome Driver $requiredChromeDriverVersion');
43+
_browserDriverDirWithVersion = io.Directory(pathlib.join(
44+
environment.webUiDartToolDir.path,
45+
'drivers',
46+
browser,
47+
requiredChromeDriverVersion,
48+
'${browser}driver-${io.Platform.operatingSystem.toString()}'));
49+
}
2450

2551
@override
2652
Future<void> _installDriver() async {
27-
if (_browserDriverDir.existsSync()) {
28-
_browserDriverDir.deleteSync(recursive: true);
53+
if (_browserDriverDirWithVersion.existsSync()) {
54+
_browserDriverDirWithVersion.deleteSync(recursive: true);
2955
}
3056

31-
_browserDriverDir.createSync(recursive: true);
57+
_browserDriverDirWithVersion.createSync(recursive: true);
3258
temporaryDirectories.add(_drivers);
3359

3460
final io.Directory temp = io.Directory.current;
35-
io.Directory.current = _browserDriverDir;
61+
io.Directory.current = _browserDriverDirWithVersion;
3662

3763
try {
3864
// TODO(nurhan): https://github.com/flutter/flutter/issues/53179
@@ -50,17 +76,17 @@ class ChromeDriverManager extends DriverManager {
5076
/// Driver should already exist on LUCI as a CIPD package.
5177
@override
5278
Future<void> _verifyDriverForLUCI() {
53-
if (!_browserDriverDir.existsSync()) {
79+
if (!_browserDriverDirWithVersion.existsSync()) {
5480
throw StateError('Failed to locate Chrome driver on LUCI on path:'
55-
'${_browserDriverDir.path}');
81+
'${_browserDriverDirWithVersion.path}');
5682
}
5783
return Future<void>.value();
5884
}
5985

6086
@override
61-
Future<void> _startDriver(String driverPath) async {
87+
Future<void> _startDriver() async {
6288
await startProcess('./chromedriver/chromedriver', ['--port=4444'],
63-
workingDirectory: driverPath);
89+
workingDirectory: _browserDriverDirWithVersion.path);
6490
print('INFO: Driver started');
6591
}
6692
}
@@ -106,9 +132,9 @@ class FirefoxDriverManager extends DriverManager {
106132
}
107133

108134
@override
109-
Future<void> _startDriver(String driverPath) async {
135+
Future<void> _startDriver() async {
110136
await startProcess('./firefoxdriver/geckodriver', ['--port=4444'],
111-
workingDirectory: driverPath);
137+
workingDirectory: _browserDriverDir.path);
112138
print('INFO: Driver started');
113139
}
114140

@@ -144,7 +170,7 @@ class SafariDriverManager extends DriverManager {
144170
}
145171

146172
@override
147-
Future<void> _startDriver(String driverPath) async {
173+
Future<void> _startDriver() async {
148174
final SafariDriverRunner safariDriverRunner = SafariDriverRunner();
149175

150176
final io.Process process =
@@ -184,7 +210,7 @@ abstract class DriverManager {
184210
} else {
185211
await _verifyDriverForLUCI();
186212
}
187-
await _startDriver(_browserDriverDir.path);
213+
await _startDriver();
188214
}
189215

190216
/// Always re-install since driver can change frequently.
@@ -198,7 +224,7 @@ abstract class DriverManager {
198224
Future<void> _verifyDriverForLUCI();
199225

200226
@protected
201-
Future<void> _startDriver(String driverPath);
227+
Future<void> _startDriver();
202228

203229
static DriverManager chooseDriver(String browser) {
204230
if (browser == 'chrome') {

lib/web_ui/dev/driver_version.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
## Map for driver versions to use for each browser version.
32
## See: https://chromedriver.chromium.org/downloads
43
chrome:

lib/web_ui/dev/macos_info.dart

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
// Copyright 2013 The Flutter Authors. All rights reserved.
22
// Use of this source code is governed by a BSD-style license that can be
33
// found in the LICENSE file.
4+
5+
// @dart = 2.6
46
import 'dart:convert';
57

68
import 'utils.dart';

0 commit comments

Comments
 (0)