From fd4253991f9db2c12fa78324e41937bf4635d034 Mon Sep 17 00:00:00 2001 From: Andrey Lushnikov Date: Mon, 3 May 2021 11:25:01 -0700 Subject: [PATCH] devops: fix swiftshader on Chromium Windows (#6391) References #6390 --- browser_patches/chromium/archive.sh | 2 ++ browser_patches/chromium/fix_windows_swiftshader.js | 13 +++++++++++++ 2 files changed, 15 insertions(+) create mode 100644 browser_patches/chromium/fix_windows_swiftshader.js diff --git a/browser_patches/chromium/archive.sh b/browser_patches/chromium/archive.sh index 54d0881f7c..ad0ae21b3a 100755 --- a/browser_patches/chromium/archive.sh +++ b/browser_patches/chromium/archive.sh @@ -136,6 +136,8 @@ function archive_compiled_chromium() { if [[ $1 == "--compile-win"* ]]; then $COPY_COMMAND "${CR_CHECKOUT_PATH}/src/out/Default/"*.manifest "output/${CHROMIUM_FOLDER_NAME}/" + # See https://github.com/microsoft/playwright/issues/6390 + node "${SCRIPT_PATH}/fix_windows_swiftshader.js" "output/${CHROMIUM_FOLDER_NAME}/vk_swiftshader_icd.json" fi cd output diff --git a/browser_patches/chromium/fix_windows_swiftshader.js b/browser_patches/chromium/fix_windows_swiftshader.js new file mode 100644 index 0000000000..b2e8d85d89 --- /dev/null +++ b/browser_patches/chromium/fix_windows_swiftshader.js @@ -0,0 +1,13 @@ +// See https://github.com/microsoft/playwright/issues/6390 +const fs = require('fs'); + +const FILE_PATH = process.argv[2]; +if (!fs.existsSync(FILE_PATH) || !FILE_PATH.endsWith('.json')) + return; + +const json = JSON.parse(fs.readFileSync(FILE_PATH, 'utf8')); + +if (json.ICD && json.ICD.library_path && json.ICD.library_path.startsWith('.\\')) { + json.ICD.library_path = json.ICD.library_path.substring(2); + fs.writeFileSync(FILE_PATH, JSON.stringify(json), 'utf8'); +}