[microsoft/playwright][BUG] Playwright 1.38 无法在 macOS 13/14 上运行 Chromium 或 Firefox

2024-04-09 773 views
1
系统信息
  • 编剧版本:[v1.38.1]
  • 操作系统:[macOS 13.5.2、macOS 14.0]
  • 浏览器:[Chromium、Firefox]
  • 其他信息:Chromium 117.0.5938.62(playwright build v1080)、Firefox 117.0(playwright build v1424)
源代码
  • [ ] 我提供了准确的源代码,可以在本地重现该问题。

测试文件(独立)

const { chromium } = require('playwright');

(async () => {
  const browser = await chromium.launch();
  const page = await browser.newPage();
  await browser.close();
})();
const { firefox } = require('playwright');

(async () => {
  const browser = await firefox.launch();
  await browser.close();
})();

脚步

  • 运行测试。

预期的

测试结束,没有任何错误。

实际的

第一个测试导致此错误:

/Users/.../nodejs/playwright/node_modules/playwright-core/lib/server/chromium/crPage.js:377
      this._firstNonInitialNavigationCommittedReject(new Error('Page closed'));
                                                     ^

Error: Page closed
    at CRSession.<anonymous> (/Users/.../nodejs/playwright/node_modules/playwright-core/lib/server/chromium/crPage.js:377:54)
    at Object.onceWrapper (node:events:627:28)
    at CRSession.emit (node:events:525:35)
    at /Users/.../nodejs/playwright/node_modules/playwright-core/lib/server/chromium/crConnection.js:211:39

第二个测试导致此错误:

node:internal/process/promises:279
            triggerUncaughtException(err, true /* fromPromise */);
            ^

browserType.launch: Browser.enable): Browser closed.
==================== Browser output: ====================
<launching> /Users/.../Library/Caches/ms-playwright/firefox-1424/firefox/Nightly.app/Contents/MacOS/firefox -no-remote -headless -profile /var/folders/dt/9bj0djrs22x5g66k9_nbz2zc0000gn/T/playwright_firefoxdev_profile-dxdJBm -juggler-pipe -silent
<launched> pid=18686
[pid=18686][err] *** You are running in headless mode.
[pid=18686] <process did exit: exitCode=null, signal=SIGSEGV>
[pid=18686] starting temporary directories cleanup
=========================== logs ===========================
<launching> /Users/.../Library/Caches/ms-playwright/firefox-1424/firefox/Nightly.app/Contents/MacOS/firefox -no-remote -headless -profile /var/folders/dt/9bj0djrs22x5g66k9_nbz2zc0000gn/T/playwright_firefoxdev_profile-dxdJBm -juggler-pipe -silent
<launched> pid=18686
[pid=18686][err] *** You are running in headless mode.
[pid=18686] <process did exit: exitCode=null, signal=SIGSEGV>
[pid=18686] starting temporary directories cleanup
============================================================
    at /Users/.../nodejs/playwright/test/example.test2.js:4:33
    at Object.<anonymous> (/Users/.../nodejs/playwright/test/example.test2.js:7:3) {
  name: 'Error'
}

请注意,在第二个测试中,甚至没有调用创建新页面。

浏览器版本 Chromium 117.0.5938.62(playwright build v1080)和 Firefox 117.0(playwright build v1424)在 macOS 13.5.2 和 macOS 14.0 中启动时似乎会崩溃。

注意:我遇到了类似的问题,但使用的是 Playwright 1.36.2 以及 Firefox 和 Webkit。唯一运行良好的浏览器是 Chromium。

回答

8

附加信息:

我使用以下命令安装了新的浏览器:

npx playwright install --with-deps

从安装文件夹运行 Chromium 时,它无法打开,并且出现以下错误:

Received signal 11 <unknown> 000000000000
 [0x000121656d82]
 [0x000121649143]
 [0x000121656cd1]
 [0x7ff81813737d]
 [0x000121603fc0]
 [0x0001237b3e0e]
 [0x0001237b3a58]
 [0x000120ffc11f]
 [0x000120ffd194]
 [0x000120ffcc29]
 [0x00011f30e1d8]
 [0x00011fa339db]
 [0x00011f30e75f]
 [0x00011f31126a]
 [0x00011f30cddf]
 [0x0001208a0df6]
 [0x0001208a1f96]
 [0x0001208a1df0]
 [0x0001208a056f]
 [0x0001208a0755]
 [0x00011cb598b1]
 [0x0001090238de]
 [0x7ff817d813a6]
[end of stack trace]
[0929/135034.230873:WARNING:crash_report_exception_handler.cc(235)] UniversalExceptionRaise: (os/kern) failure (5)
[1]    18937 segmentation fault  ./Chromium

从安装文件夹运行 Firefox 时,它无法打开,并且出现以下错误:

[1]    19065 segmentation fault  ./firefox
[1]    19089 segmentation fault  ./firefox-bin
8

由于浏览器无法启动,您的计算机上似乎出现了某些问题。我们的测试在 macOS 13.5 机器人上运行并在本地运行,没有出现任何问题。如果没有能力在本地重现这一点并且没有足够的诊断信息,我们就无法做很多事情。

4

我有一台 MacBook Pro 16 英寸,2019 年。

处理器:2.3 GHz 8 核 Intel Core i9 显卡:Intel UHD Graphics 630 1536 MB 内存:32 GB 2667 MHz DDR4

我下载了Chromium 版本 117.0.5938.112 官方版本 x86_64(不是 Playwright 版本),它工作正常。

事实上,如果我用这个 Chromium 版本替换 Chromium Playwright 版本,那么 Playwright 测试就可以正常工作。

以防万一这有帮助。

5

让我们检查一下您是否正在下载 Intel 版本的浏览器:

跑步

file /Users/<user>/Library/Caches/ms-playwright/chromium-1080/chrome-mac/Chromium.app/Contents/MacOS/Chromium

它不应该说arm,应该是amd之类的东西。如果显示arm,请尝试重新安装浏览器:

跑步

npx playwright uninstall --all
npx playwright install

您应该会看到从 CDN 下载的浏览器 URL。您能否分享这些内容并仔细检查是否下载了英特尔版本的浏览器?

2

当我执行命令时:

file /Users/<user>/Library/Caches/ms-playwright/chromium-1080/chrome-mac/Chromium.app/Contents/MacOS/Chromium

我得到以下输出:

/Users/<user>/Library/Caches/ms-playwright/chromium-1080/chrome-mac/Chromium.app/Contents/MacOS/Chromium: Mach-O 64-bit executable x86_64

我安装浏览器时的输出如下:

Downloading Chromium 117.0.5938.62 (playwright build v1080) from https://playwright.azureedge.net/builds/chromium/1080/chromium-mac.zip
136.1 Mb [====================] 100% 0.0s
Chromium 117.0.5938.62 (playwright build v1080) downloaded to /Users/<user>/Library/Caches/ms-playwright/chromium-1080
Downloading FFMPEG playwright build v1009 from https://playwright.azureedge.net/builds/ffmpeg/1009/ffmpeg-mac.zip
1.1 Mb [====================] 100% 0.0s
FFMPEG playwright build v1009 downloaded to /Users/<user>/Library/Caches/ms-playwright/ffmpeg-1009
Downloading Firefox 117.0 (playwright build v1424) from https://playwright.azureedge.net/builds/firefox/1424/firefox-mac-13.zip
75.9 Mb [====================] 100% 0.0s
Firefox 117.0 (playwright build v1424) downloaded to /Users/<user>/Library/Caches/ms-playwright/firefox-1424
Downloading Webkit 17.0 (playwright build v1908) from https://playwright.azureedge.net/builds/webkit/1908/webkit-mac-13.zip
64.2 Mb [====================] 100% 0.0s
Webkit 17.0 (playwright build v1908) downloaded to /Users/<user>/Library/Caches/ms-playwright/webkit-1908

似乎一切都是正确的。但是,我直接使用 URL https://playwright.azureedge.net/builds/chromium/1080/chromium-mac.zip下载了 Chromium ,我使用 Archive Utility.app 或 The Unarchiver.app 解压它,效果很好。

如果我使用终端中的 unzip 命令解压缩它,则浏览器将无法工作。

如果我从两个可执行文件中获取 md5,则结果是相同的。

这可能是与符号链接解压缩方式有关的问题吗?

8

这确实是出乎意料的,您可以比较使用这两个实用程序提取的文件吗?我们无法在我们这边复制它......

0

哪些公用事业?

8

我的意思是,如果 Archive Utility.app 生成工作版本,而解压缩生成不工作版本,您可以将它们提取到同级文件夹中并进行比较吗?

2

好的了解了。

比较得到以下结果(在左侧,工作浏览器):

铬:

铬比较

火狐浏览器:

火狐比较

这里有两个浏览器的下载链接。一个使用 Archive Utility.app 解压缩(工作正常),另一个使用 npx 解压缩(不工作),适用于 Chromium 和 Firefox:浏览器

仅供参考:为了压缩/解压缩,我使用了 Archive Utility,版本 10.15

5

感谢您提供额外信息。一些二进制文件确实不同,我看到的差异如下:

< 00a0b350: 0000 0000 0000 4700 6900 dd1e 2000 4800  ......G.i... .H.
---
> 00a0b350: b1ae 1a00 0000 4700 6900 dd1e 2000 4800  ......G.i... .H.

鉴于简单的解压缩会在您的系统上产生不同的结果,并且没有其他此类报告,我们认为您的 Node 安装或操作系统已损坏。我会从重新安装 Node 开始,但除此之外,我们无法从该错误中恢复。

1

如上所述结束,如果这不涵盖您的用例,请随时打开一个新问题。

2

非常感谢。至少,我有手动下载浏览器并将其替换到 npx 安装它们的文件夹中的解决方法。