playwright: [BUG] Channel chrome on M1 chip performance degradation

Context:

  • Playwright Version: 1.25.0
  • Operating System: Mac M1 pro
  • Node.js version: 14.6
  • Browser: Chrome
  • Extra: channel chrome

Code Snippet

import { test, expect } from '@playwright/test';
  test('login to homepage with Email', async ({ page, baseURL }) => {
  await page.goto('https://google.com/')
  });  


Playwright project config for chrome channel

 {
      name: 'chromium',
      use: {
        channel: 'chrome',
        ...devices['Desktop Chrome'],
      },
    },

Describe the bug

When tests are run with channel chrome rendering speed is severely affected. Chrome under tests tries to eat all the cpu and RAM available. The easiest way to experience it is to make a debug breakpoint and open chrome in headed mode and try to use it. (pop inspect, navigate to another page) There are no issues with the default chromium channel. Chrome channel is used in my case to have FFmpeg codecs included.

About this issue

  • Original URL
  • State: open
  • Created 2 years ago
  • Comments: 17 (4 by maintainers)

Most upvoted comments

I faced the same issue. Google Chrome was getting launched in the x86_64 translated version instead of the arm version which was slowing down the entire browser and using up a lot of system resources. I was running the Playwright commands on a non-rosetta-enabled terminal. (To check if you have rosetta enabled you can type arch in your terminal. If it returns arm64 then you’re not using rosetta. If it returns i386 then it is using rosetta.)

The reason why Chrome is launching in the x86 translated build is probably because the node version you’re using must be an x86 version. To confirm this you can use the os library provided by NodeJS. Add this code in your playwright.config.(ts/js) file:

// playwright.config.ts

import os from "os"

console.log(`Architecture: ${os.arch()}`);

// Rest of your config file..

Now when you run your Playwright tests in a non-rosetta-enabled terminal, if you see Architecture: x64 then that means you have the x86 version of node installed on your system. This might have been caused because you installed node in a rosetta-enabled terminal. To solve this issue is as simple as to uninstall and reinstall your current version of node from a non-rosetta enabled terminal. If you’re using nvm then you can follow the steps below.

arch # Make sure this is returning arm64. Else exit out of the terminal, disable rosetta for it and restart it.
node -v # Note down the current node version for reinstalling the same version
nvm deactivate # To make sure node doesn't throw an error when you try to uninstall the default node version. In my case it was 18.12.1
nvm uninstall 18.12.1 # Uninstall the node version you're using
nvm install 18.12.1
nvm alias default 18.12.1
node -v # Executing this command should give the same node version again

It’s important to note that executing the commands above might affect your package managers like yarn if you have them installed. In that is the case you just have to reinstall them.

Now you can go to your playwright test folder and execute this command to reinstall all the packages.

rm -rf node_modules  && rm -rf yarn.lock && yarn install
# Or
rm -rf node_modules  && rm -rf package.lock && npm install

Once this is done you should be able to open Chrome in the arm64 version in the Playwright tests and the tests should execute much more smoothly.

Just hit this problem, you need to un-check Open using Rosetta on your Terminal (or whatever shell), and restart your machine: Screenshot 2023-07-07 at 2 13 09 PM

I’m assuming Chrome when launched via Playwright (which is launched via Terminal) is inheriting the arch somehow. You can check this by hitting About Google Chrome and checking the arch in the parenthesis: Screenshot 2023-07-07 at 2 18 46 PM

If you pause your Playwright session and it shows x86_64 translated, then it is running in the wrong arch.