Update script to install ANGLE binaries in installed Chromium

Useful when debugging a WebGL test, the script that installs ANGLE
binaries in Chrome Canary on Windows is updated to also allow installing
ANGLE binaries in Chrome Dev on Linux.  On Linux, the script needs to
run as root.

Bug: angleproject:6507
Change-Id: I812d3a85528217dab478b1e8a0f266ae231f10af
Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3202554
Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org>
Reviewed-by: Jamie Madill <jmadill@chromium.org>
This commit is contained in:
Shahbaz Youssefi
2021-10-04 14:09:53 -04:00
committed by Angle LUCI CQ
parent 69a91b3d78
commit bab0e7171f
4 changed files with 127 additions and 68 deletions

View File

@@ -321,8 +321,16 @@ Canary.
1. Download and install [Google Chrome Canary](https://www.google.com/chrome/canary/).
2. Build ANGLE x64, Release.
3. Run `python scripts\update_canary_angle.py` to replace Canary's ANGLE with your custom ANGLE
(note: Canary must be closed).
3. Run `python scripts\update_chrome_angle.py` to replace Canary's ANGLE with your custom ANGLE
(note: Canary must be closed).
#### Linux
1. Install Google Chrome Dev (via apt, or otherwise). Expected installation directory is
`/opt/google/chrome-unstable`.
2. Build ANGLE for the running platform. `is_component_build = false` is suggested in the GN args.
3. Run `python scripts/update_chrome_angle.py` to replace Dev's ANGLE with your custom ANGLE
4. Add ANGLE's build path to the `LD_LIBRARY_PATH` environment variable.
#### macOS
@@ -343,7 +351,14 @@ Canary.
### Usage
Run `%LOCALAPPDATA%\Google\Chrome SxS\chrome.exe` (Windows) or `./Google\ Chrome\ Canary.app/Contents/MacOS/Google\ Chrome\ Canary` (macOS) with the following command-line options:
Run Chrome:
- On Windows: `%LOCALAPPDATA%\Google\Chrome SxS\chrome.exe`
- On Linux: `/opt/google/chrome-unstable/google-chrome-unstable`
- On macOS: `./Google\ Chrome\ Canary.app/Contents/MacOS/Google\ Chrome\ Canary`
With the following command-line options:
* `--use-cmd-decoder=passthrough --use-gl=angle` and one of
* `--use-angle=d3d9` (Direct3D 9 renderer, Windows only)
* `--use-angle=d3d11` (Direct3D 11 renderer, Windows only)
@@ -353,3 +368,13 @@ Run `%LOCALAPPDATA%\Google\Chrome SxS\chrome.exe` (Windows) or `./Google\ Chrome
* `--use-angle=vulkan` (Vulkan renderer)
* `--use-angle=swiftshader` (SwiftShader renderer)
* `--use-angle=metal` (Metal renderer, macOS only)
Additional useful options:
* `--enable-logging`: To see logs
* `--disable-gpu-watchdog`: To disable Chromium's watchdog, killing the GPU process when slow (due
to a debug build for example)
* `--disable-gpu-sandbox`: To disable Chromium's sandboxing features, if it's getting in the way of
testing.
* `--disable-gpu-compositing`: To make sure only the WebGL test being debugged is run through ANGLE,
not the entirety of Chromium.

View File

@@ -99,7 +99,7 @@ A basic guide to get up and running fixing bugs and performance issues in ANGLE.
- Canary's install dir is usually `%APPDATA%/Local/Google/Chrome SxS/Application`
- Build ANGLE x64, Release, and run 'python scripts/update_canary_angle.py' to replace Canary's
- Build ANGLE x64, Release, and run 'python scripts/update_chrome_angle.py' to replace Canary's
ANGLE with your custom ANGLE. (Note: Canary must be closed)
- Start Canary with `--gpu-startup-dialog --disable-gpu-sandbox`, wait for the dialog.

View File

@@ -1,64 +0,0 @@
#!/usr/bin/python2
#
# Copyright 2016 The ANGLE Project Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
#
# update_canary_angle.py:
# Helper script that copies Windows ANGLE DLLs into the Canary
# application directory. Much faster than compiling Chrome from
# source. The script checks for the most recent DLLs in a set of
# search paths, and copies that into the most recent Canary
# binary folder. Only works on Windows.
import glob, sys, os, shutil
# Set of search paths.
script_dir = os.path.dirname(sys.argv[0])
os.chdir(os.path.join(script_dir, ".."))
source_paths = glob.glob('out/*')
# Default Canary installation path.
chrome_folder = os.path.join(os.environ['LOCALAPPDATA'], 'Google', 'Chrome SxS', 'Application')
# Find the most recent ANGLE DLLs
binary_name = 'libGLESv2.dll'
newest_folder = None
newest_mtime = None
for path in source_paths:
binary_path = os.path.join(path, binary_name)
if os.path.exists(binary_path):
binary_mtime = os.path.getmtime(binary_path)
if (newest_folder is None) or (binary_mtime > newest_mtime):
newest_folder = path
newest_mtime = binary_mtime
if newest_folder is None:
sys.exit("Could not find ANGLE DLLs!")
source_folder = newest_folder
# Is a folder a chrome binary directory?
def is_chrome_bin(str):
chrome_file = os.path.join(chrome_folder, str)
return os.path.isdir(chrome_file) and all([char.isdigit() or char == '.' for char in str])
sorted_chrome_bins = sorted(
[folder for folder in os.listdir(chrome_folder) if is_chrome_bin(folder)], reverse=True)
dest_folder = os.path.join(chrome_folder, sorted_chrome_bins[0])
print('Copying DLLs from ' + source_folder + ' to ' + dest_folder + '.')
for dll in ['libGLESv2.dll', 'libEGL.dll']:
src = os.path.join(source_folder, dll)
if os.path.exists(src):
# Make a backup of the original unmodified DLLs if they are present.
backup = os.path.join(source_folder, dll + '.backup')
if not os.path.exists(backup):
shutil.copyfile(src, backup)
shutil.copyfile(src, os.path.join(dest_folder, dll))
shutil.copyfile(src + ".pdb", os.path.join(dest_folder, dll + ".pdb"))

98
scripts/update_chrome_angle.py Executable file
View File

@@ -0,0 +1,98 @@
#!/usr/bin/python3
#
# Copyright 2016 The ANGLE Project Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
#
# update_chrome_angle.py:
# Helper script that copies ANGLE libraries into the Chromium Canary (on Windows) or Dev (on
# Linux) installed directory. Testing ANGLE this way is much faster than compiling Chromium from
# source. The script checks for the most recent build in a set of search paths, and copies that
# into:
#
# - /opt/google/chrome-unstable on Linux
# - the most recent Canary installation folder on Windows.
#
# Only works on Linux and Windows.
import glob, sys, os, shutil
# Set of search paths.
script_dir = os.path.dirname(sys.argv[0])
os.chdir(os.path.join(script_dir, ".."))
source_paths = glob.glob('out/*')
is_windows = sys.platform == 'cygwin' or sys.platform.startswith('win')
if is_windows:
# Default Canary installation path.
chrome_folder = os.path.join(os.environ['LOCALAPPDATA'], 'Google', 'Chrome SxS', 'Application')
libs_to_copy = ['libGLESv2.dll', 'libEGL.dll']
optional_libs_to_copy = []
else:
# Must be Linux
chrome_folder = '/opt/google/chrome-unstable'
libs_to_copy = ['libGLESv2.so', 'libEGL.so']
# Optionally copy the following, which are needed for a component build
# (i.e. is_component_build = true, which is the default)
optional_libs_to_copy = ['libchrome_zlib.so', 'libabsl.so', 'libc++.so']
# Find the most recent ANGLE DLLs
binary_name = libs_to_copy[0]
newest_folder = None
newest_mtime = None
for path in source_paths:
binary_path = os.path.join(path, binary_name)
if os.path.exists(binary_path):
binary_mtime = os.path.getmtime(binary_path)
if (newest_folder is None) or (binary_mtime > newest_mtime):
newest_folder = path
newest_mtime = binary_mtime
if newest_folder is None:
sys.exit("Could not find ANGLE binaries!")
source_folder = newest_folder
if is_windows:
# Is a folder a chrome binary directory?
def is_chrome_bin(str):
chrome_file = os.path.join(chrome_folder, str)
return os.path.isdir(chrome_file) and all([char.isdigit() or char == '.' for char in str])
sorted_chrome_bins = sorted(
[folder for folder in os.listdir(chrome_folder) if is_chrome_bin(folder)], reverse=True)
dest_folder = os.path.join(chrome_folder, sorted_chrome_bins[0])
else:
dest_folder = chrome_folder
print('Copying binaries from ' + source_folder + ' to ' + dest_folder + '.')
def copy_file(src, dst):
print(' - ' + src + ' --> ' + dst)
shutil.copyfile(src, dst)
def do_copy(filename, is_optional):
src = os.path.join(source_folder, filename)
if os.path.exists(src):
# No backup is made. Any backup becomes stale on the next update and could be a cause for
# confusion. Reintall Chromium if it needs to be recovered.
dst = os.path.join(dest_folder, filename)
copy_file(src, dst)
if is_windows:
copy_file(src + '.pdb', dst + '.pdb')
elif not is_optional:
print(' - COULD NOT FIND "' + src + '"')
for filename in libs_to_copy:
do_copy(filename, False)
for filename in optional_libs_to_copy:
do_copy(filename, True)