@@ -9,12 +9,56 @@ export PLAYWRIGHT_SKIP_BROWSER_GC=1
99
1010pushd bundle/
1111
12- # Install all browsers with mac13 platform override
13- PLAYWRIGHT_HOST_PLATFORM_OVERRIDE=mac13 npx playwright install
14- PLAYWRIGHT_HOST_PLATFORM_OVERRIDE=mac13 npx playwright install-deps
12+ # --- Step 1: Install ARM64 browsers for macOS 14/15 (Apple Silicon) ---
13+ # Use mac14-arm64 override instead of native mac15-arm64 so that webkit is
14+ # compiled against the macOS 14 SDK. This binary is forward-compatible with
15+ # macOS 15 but the reverse is not true (mac15 webkit uses symbols absent on 14).
16+ # NOTE: Firefox is deliberately excluded here. Both arm64 and x64 Firefox
17+ # extract to the same directory path (firefox-<rev>/firefox/), so only one
18+ # can exist. We install x64 Firefox in Step 3, which runs natively on Intel
19+ # Macs and via Rosetta 2 on Apple Silicon.
20+ PLAYWRIGHT_HOST_PLATFORM_OVERRIDE=mac14-arm64 npx playwright install chromium chromium-headless-shell webkit
21+ PLAYWRIGHT_HOST_PLATFORM_OVERRIDE=mac14-arm64 npx playwright install-deps chromium webkit
22+
23+ # --- Step 2: Back up ARM64 Chromium files ---
24+ # Playwright deletes the entire browser revision directory (e.g. chromium-1208/)
25+ # when INSTALLATION_COMPLETE is missing. We must preserve the arm64 subdirectories
26+ # before the x64 install wipes them out.
27+ ARM64_BACKUP=$( mktemp -d)
28+ find " $PLAYWRIGHT_BROWSERS_PATH " -type d -name " chrome-mac-arm64" -exec cp -a {} " $ARM64_BACKUP /chrome-mac-arm64" \;
29+ find " $PLAYWRIGHT_BROWSERS_PATH " -type d -name " chrome-headless-shell-mac-arm64" -exec cp -a {} " $ARM64_BACKUP /chrome-headless-shell-mac-arm64" \;
30+
31+ # --- Step 3: Remove INSTALLATION_COMPLETE markers ---
32+ # Playwright checks for this marker and silently skips if present — even when
33+ # the needed platform variant (e.g. x64) is missing. Removing the markers
34+ # forces the x86 install to re-download.
35+ find " $PLAYWRIGHT_BROWSERS_PATH " -name " INSTALLATION_COMPLETE" -delete
36+
37+ # --- Step 4: Install x86 browsers for macOS 12/13 (Intel) ---
38+ # Firefox and ffmpeg share the same subdirectory for both architectures, so
39+ # this step overwrites the ARM64 copies with x64 — which is intentional since
40+ # x64 binaries run on Apple Silicon via Rosetta 2.
41+ PLAYWRIGHT_HOST_PLATFORM_OVERRIDE=mac13 npx playwright install chromium chromium-headless-shell firefox
42+ PLAYWRIGHT_HOST_PLATFORM_OVERRIDE=mac13 npx playwright install-deps chromium firefox
43+
44+ # --- Step 5: Restore ARM64 Chromium files ---
45+ # Copy arm64 subdirectories back into the browser revision directories so both
46+ # architectures coexist (chrome-mac-arm64/ alongside chrome-mac-x64/).
47+ for chromium_dir in " $PLAYWRIGHT_BROWSERS_PATH " /chromium-* /; do
48+ if [ -d " $ARM64_BACKUP /chrome-mac-arm64" ]; then
49+ cp -a " $ARM64_BACKUP /chrome-mac-arm64" " $chromium_dir /"
50+ fi
51+ done
52+ for headless_dir in " $PLAYWRIGHT_BROWSERS_PATH " /chromium_headless_shell-* /; do
53+ if [ -d " $ARM64_BACKUP /chrome-headless-shell-mac-arm64" ]; then
54+ cp -a " $ARM64_BACKUP /chrome-headless-shell-mac-arm64" " $headless_dir /"
55+ fi
56+ done
57+ rm -rf " $ARM64_BACKUP "
58+
1559npx playwright --version
1660
1761popd
1862
19- # Archive Bundle with symlinks
63+ # Archive Bundle with symlinks preserved (required for macOS .app bundles)
2064zip --symlinks -r playwright-macos-amd64.zip bundle/
0 commit comments