From 957a8293bb1444fd51fd5673002a7781e8127c9d Mon Sep 17 00:00:00 2001 From: Alex Rudenko Date: Thu, 30 Nov 2023 14:26:49 +0100 Subject: [PATCH] fix: warn about launch Chrome using Node x64 on arm64 Macs (#11471) --- .../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 673c76bda06..f35bad0824d 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); }