From 820715768fda2e272fcb9d2c30526807914423c0 Mon Sep 17 00:00:00 2001 From: Marvin Hagemeister Date: Sun, 18 Apr 2021 14:35:49 +0200 Subject: [PATCH 1/4] feat(launcher): fix installation error on Apple M1 chips The previous logic assumed that an arm64 arch is only available in Linux. WIth Apple's arm64 M1 Chip this assumption isn't true anymore. Currently there are no official MacOS arm64 chromium builds available, but we can make use of the excellent Rosetta feature in MacOS that allows us to run x86 binaries on M1. Once native MacOS arm64 chromium builds are available we should switch to those. Fixes #6622 --- src/node/BrowserFetcher.ts | 5 ++++- src/node/Launcher.ts | 4 +++- src/node/install.ts | 4 +++- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/src/node/BrowserFetcher.ts b/src/node/BrowserFetcher.ts index 11e85bb666411..ca40e43d280b7 100644 --- a/src/node/BrowserFetcher.ts +++ b/src/node/BrowserFetcher.ts @@ -293,7 +293,10 @@ export class BrowserFetcher { if (await existsAsync(outputPath)) return this.revisionInfo(revision); if (!(await existsAsync(this._downloadsFolder))) await mkdirAsync(this._downloadsFolder); - if (os.arch() === 'arm64') { + + // Use intel x86 build on Apple M1 until native MacOS arm64 + // chromium builds are available + if (os.platform() !== 'darwin' && os.arch() === 'arm64') { handleArm64(); return; } diff --git a/src/node/Launcher.ts b/src/node/Launcher.ts index 828b18c0a66e1..c4052fe91bbe6 100644 --- a/src/node/Launcher.ts +++ b/src/node/Launcher.ts @@ -105,7 +105,9 @@ class ChromeLauncher implements ProductLauncher { let chromeExecutable = executablePath; if (!executablePath) { - if (os.arch() === 'arm64') { + // Use intel x86 build on Apple M1 until native MacOS arm64 + // chromium builds are available + if (os.platform() !== 'darwin' && os.arch() === 'arm64') { chromeExecutable = '/usr/bin/chromium-browser'; } else { const { missingText, executablePath } = resolveExecutablePath(this); diff --git a/src/node/install.ts b/src/node/install.ts index 41f2834d80d5a..621981c2ba4a1 100644 --- a/src/node/install.ts +++ b/src/node/install.ts @@ -90,7 +90,9 @@ export async function downloadBrowser() { if (NPM_NO_PROXY) process.env.NO_PROXY = NPM_NO_PROXY; function onSuccess(localRevisions: string[]): void { - if (os.arch() !== 'arm64') { + // Use intel x86 build on Apple M1 until native MacOS arm64 + // chromium builds are available + if (os.platform() !== 'darwin' && os.arch() !== 'arm64') { logPolitely( `${supportedProducts[product]} (${revisionInfo.revision}) downloaded to ${revisionInfo.folderPath}` ); From 50a973f9fb878d9c77f362abb910daabf4711785 Mon Sep 17 00:00:00 2001 From: Mathias Bynens Date: Mon, 19 Apr 2021 08:59:48 +0200 Subject: [PATCH 2/4] Update src/node/BrowserFetcher.ts --- src/node/BrowserFetcher.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/node/BrowserFetcher.ts b/src/node/BrowserFetcher.ts index ca40e43d280b7..c1792aa73903e 100644 --- a/src/node/BrowserFetcher.ts +++ b/src/node/BrowserFetcher.ts @@ -294,8 +294,8 @@ export class BrowserFetcher { if (!(await existsAsync(this._downloadsFolder))) await mkdirAsync(this._downloadsFolder); - // Use intel x86 build on Apple M1 until native MacOS arm64 - // chromium builds are available + // Use Intel x86 builds on Apple M1 until native macOS arm64 + // Chromium builds are available. if (os.platform() !== 'darwin' && os.arch() === 'arm64') { handleArm64(); return; From 38451e6ee32be48a146d0790721bf2aa8605fd69 Mon Sep 17 00:00:00 2001 From: Mathias Bynens Date: Mon, 19 Apr 2021 08:59:52 +0200 Subject: [PATCH 3/4] Update src/node/Launcher.ts --- src/node/Launcher.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/node/Launcher.ts b/src/node/Launcher.ts index c4052fe91bbe6..b116be45517f7 100644 --- a/src/node/Launcher.ts +++ b/src/node/Launcher.ts @@ -105,8 +105,8 @@ class ChromeLauncher implements ProductLauncher { let chromeExecutable = executablePath; if (!executablePath) { - // Use intel x86 build on Apple M1 until native MacOS arm64 - // chromium builds are available + // Use Intel x86 builds on Apple M1 until native macOS arm64 + // Chromium builds are available. if (os.platform() !== 'darwin' && os.arch() === 'arm64') { chromeExecutable = '/usr/bin/chromium-browser'; } else { From 774d04960590fd41eed770fdefa9223a36d9b5de Mon Sep 17 00:00:00 2001 From: Mathias Bynens Date: Mon, 19 Apr 2021 08:59:57 +0200 Subject: [PATCH 4/4] Update src/node/install.ts --- src/node/install.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/node/install.ts b/src/node/install.ts index 621981c2ba4a1..bb44f4e26cb9b 100644 --- a/src/node/install.ts +++ b/src/node/install.ts @@ -90,8 +90,8 @@ export async function downloadBrowser() { if (NPM_NO_PROXY) process.env.NO_PROXY = NPM_NO_PROXY; function onSuccess(localRevisions: string[]): void { - // Use intel x86 build on Apple M1 until native MacOS arm64 - // chromium builds are available + // Use Intel x86 builds on Apple M1 until native macOS arm64 + // Chromium builds are available. if (os.platform() !== 'darwin' && os.arch() !== 'arm64') { logPolitely( `${supportedProducts[product]} (${revisionInfo.revision}) downloaded to ${revisionInfo.folderPath}`