Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all 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
20 changes: 20 additions & 0 deletions lib/web_ui/dev/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ flutter/goldens updating the screenshots. Then update this file pointing to
the new revision.

## Developing the `felt` tool

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.

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`:
Expand All @@ -155,3 +156,22 @@ FELT_USE_SNAPSHOT=0 felt <command>
```

_**Note**: if `FELT_USE_SNAPSHOT` is omitted or has any value other than "false" or "0", the snapshot mode will be enabled._

## Upgrade Browser Version

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.

1. Dowload the binaries for the new browser/driver for each operaing system (macOS, linux, windows).
2. Create CIPD packages for these packages. (More documentation is available for Googlers. go/cipd-flutter-web)
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.
4. Update the version in this repo. Do this by changing the related fields in `browser_lock.yaml` file.
5. After a few days don't forget to remove the old version from the LUCI recipe.

Note that for LUCI builders, both unit and integration tests are using the same browser.

Some useful links:

1. For Chrome downloads [link](https://commondatastorage.googleapis.com/chromium-browser-snapshots/index.html)
2. Browser and driver CIPD [packages](https://chrome-infra-packages.appspot.com/p/flutter_internal) (Note: Access rights are restricted for these packages.)
3. LUCI web [recipe](https://flutter.googlesource.com/recipes/+/refs/heads/master/recipes/web_engine.py)
4. More general reading on CIPD packages [link](https://chromium.googlesource.com/chromium/src.git/+/master/docs/cipd.md#What-is-CIPD)
20 changes: 15 additions & 5 deletions lib/web_ui/dev/browser_lock.yaml
Original file line number Diff line number Diff line change
@@ -1,11 +1,21 @@
## Driver version in use.
## For an integration test to run, the browser's major version and the driver's
## major version should be equal. Please make sure the major version of
## the binary for `chrome` is the same with `required_driver_version`.
## (Major version meaning: For a browser that has version 13.0.5, the major
## version is 13.)
## Please refer to README's `Upgrade Browser Version` section for more details
## on how to update the version number.
required_driver_version:
## Make sure the major version of the binary in `browser_lock.yaml` is the
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This no longer needs to refer to browser_lock.yaml as everything is in the same file. Instead it should point to the relevant keys in this file that need to be in sync with this value.

## same for Chrome.
chrome: '84'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For consistency with geckodriver we should either move geckodriver under required_driver_version, or put chromedriver next to geckodriver without required_driver_version. The former is simpler than the latter.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As discussed offline, reviewer will address the changes in a separate PR.

chrome:
# It seems Chrome can't always release from the same build for all operating
# systems, so we specify per-OS build number.
# Note: 741412 binary is for Chrome Version 82. Driver for Chrome version 83
# is not working with chrome.binary option.
Linux: 741412
Mac: 735194
Win: 768975
Linux: 768968 # Major version 84
Mac: 768985 # Major version 84
Win: 768975 # Major version 84
firefox:
version: '72.0'
edge:
Expand Down
54 changes: 40 additions & 14 deletions lib/web_ui/dev/driver_manager.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

// @dart = 2.6
import 'dart:io' as io;

import 'package:meta/meta.dart';
Expand All @@ -20,19 +21,44 @@ import 'utils.dart';
///
/// This manager can be used for both macOS and Linux.
class ChromeDriverManager extends DriverManager {
ChromeDriverManager(String browser) : super(browser);
/// Directory which contains the Chrome's major version.
///
/// On LUCI we are using the CIPD packages to control Chrome binaries we use.
/// There will be multiple CIPD packages loaded at the same time. Yaml file
/// `driver_version.yaml` contains the version number we want to use.
///
/// Initialized to the current first to avoid the `Non-nullable` error.
// TODO: https://github.com/flutter/flutter/issues/53179. Local integration
// tests are still using the system Chrome.
io.Directory _browserDriverDirWithVersion;

ChromeDriverManager(String browser) : super(browser) {
final io.File lockFile = io.File(pathlib.join(
environment.webUiRootDir.path, 'dev', 'browser_lock.yaml'));
final YamlMap _configuration =
loadYaml(lockFile.readAsStringSync()) as YamlMap;
final String requiredChromeDriverVersion =
_configuration['required_driver_version']['chrome'] as String;
print('INFO: Major version for Chrome Driver $requiredChromeDriverVersion');
_browserDriverDirWithVersion = io.Directory(pathlib.join(
environment.webUiDartToolDir.path,
'drivers',
browser,
requiredChromeDriverVersion,
'${browser}driver-${io.Platform.operatingSystem.toString()}'));
}

@override
Future<void> _installDriver() async {
if (_browserDriverDir.existsSync()) {
_browserDriverDir.deleteSync(recursive: true);
if (_browserDriverDirWithVersion.existsSync()) {
_browserDriverDirWithVersion.deleteSync(recursive: true);
}

_browserDriverDir.createSync(recursive: true);
_browserDriverDirWithVersion.createSync(recursive: true);
temporaryDirectories.add(_drivers);

final io.Directory temp = io.Directory.current;
io.Directory.current = _browserDriverDir;
io.Directory.current = _browserDriverDirWithVersion;

try {
// TODO(nurhan): https://github.com/flutter/flutter/issues/53179
Expand All @@ -50,17 +76,17 @@ class ChromeDriverManager extends DriverManager {
/// Driver should already exist on LUCI as a CIPD package.
@override
Future<void> _verifyDriverForLUCI() {
if (!_browserDriverDir.existsSync()) {
if (!_browserDriverDirWithVersion.existsSync()) {
throw StateError('Failed to locate Chrome driver on LUCI on path:'
'${_browserDriverDir.path}');
'${_browserDriverDirWithVersion.path}');
}
return Future<void>.value();
}

@override
Future<void> _startDriver(String driverPath) async {
Future<void> _startDriver() async {
await startProcess('./chromedriver/chromedriver', ['--port=4444'],
workingDirectory: driverPath);
workingDirectory: _browserDriverDirWithVersion.path);
print('INFO: Driver started');
}
}
Expand Down Expand Up @@ -106,9 +132,9 @@ class FirefoxDriverManager extends DriverManager {
}

@override
Future<void> _startDriver(String driverPath) async {
Future<void> _startDriver() async {
await startProcess('./firefoxdriver/geckodriver', ['--port=4444'],
workingDirectory: driverPath);
workingDirectory: _browserDriverDir.path);
print('INFO: Driver started');
}

Expand Down Expand Up @@ -144,7 +170,7 @@ class SafariDriverManager extends DriverManager {
}

@override
Future<void> _startDriver(String driverPath) async {
Future<void> _startDriver() async {
final SafariDriverRunner safariDriverRunner = SafariDriverRunner();

final io.Process process =
Expand Down Expand Up @@ -184,7 +210,7 @@ abstract class DriverManager {
} else {
await _verifyDriverForLUCI();
}
await _startDriver(_browserDriverDir.path);
await _startDriver();
}

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

@protected
Future<void> _startDriver(String driverPath);
Future<void> _startDriver();

static DriverManager chooseDriver(String browser) {
if (browser == 'chrome') {
Expand Down
1 change: 0 additions & 1 deletion lib/web_ui/dev/driver_version.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

## Map for driver versions to use for each browser version.
## See: https://chromedriver.chromium.org/downloads
chrome:
Expand Down
2 changes: 2 additions & 0 deletions lib/web_ui/dev/macos_info.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
// 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.

// @dart = 2.6
import 'dart:convert';

import 'utils.dart';
Expand Down