From eb753d4a67b566afeea4da97eb86f185a4362c1e Mon Sep 17 00:00:00 2001 From: Alex Rudenko Date: Thu, 30 Nov 2023 13:08:38 +0100 Subject: [PATCH] fix: warn about launch Chrome using Node x64 on arm64 Macs Closes #10758 --- .../puppeteer-core/src/node/ChromeLauncher.ts | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/packages/puppeteer-core/src/node/ChromeLauncher.ts b/packages/puppeteer-core/src/node/ChromeLauncher.ts index 673c76bda06e2..f35bad0824d2b 100644 --- a/packages/puppeteer-core/src/node/ChromeLauncher.ts +++ b/packages/puppeteer-core/src/node/ChromeLauncher.ts @@ -15,6 +15,7 @@ */ import {mkdtemp} from 'fs/promises'; +import os from 'os'; import path from 'path'; import { @@ -64,6 +65,26 @@ export class ChromeLauncher extends ProductLauncher { ); } + if ( + this.puppeteer.configuration.logLevel === 'warn' && + process.platform === 'darwin' && + process.arch === 'x64' + ) { + const cpus = os.cpus(); + if (cpus[0]?.model.includes('Apple')) { + console.warn( + [ + '\x1B[1m\x1B[43m\x1B[30m', + 'Degraded performance warning:\x1B[0m\x1B[33m', + 'Launching Chrome on Mac Silicon (arm64) from an x64 Node installation results in', + 'Rosetta translating the Chrome binary, even if Chrome is already arm64. This would', + 'result in huge performance issues. To resolve this, you must run Puppeteer with', + 'a version of Node built for arm64.', + ].join('\n ') + ); + } + } + return super.launch(options); }