playwright
playwright copied to clipboard
[Bug]: Timeout on electron.launch when not loading any file or URL in the main window
Version
1.41.1
Steps to reproduce
- Clone my repo at https://github.com/dabo248/electron-playwright-issue
- Run the following commands:
npm install
npm run build
npx playwright test
Expected behavior
I expect the example test to succeed without setting any URL or file to the main window. Only if I load an URL (or file) with the BrowserWindow it works. See main.js for this workaround.
Actual behavior
Playwright's electron.launch
does not return and the test runs into a timeout.
I was able to track it down to _waitForAllPagesToBeInitialized not returning for the main window because of Emulation.setFocusEmulationEnabled not receiving a response.
When running the test with DEBUG=pw:protocol npx playwright test
you can see a response for the browser view ("id":11
), but not for the browser window ("id":22
):
pw:protocol SEND ► {"id":11,"method":"Emulation.setFocusEmulationEnabled","params":{"enabled":true},"sessionId":"8D031A3EF58E25A9CCF2354E0C8F467E"} +1ms
[...]
pw:protocol ◀ RECV {"id":11,"result":{},"sessionId":"8D031A3EF58E25A9CCF2354E0C8F467E"} +0ms
[...]
pw:protocol SEND ► {"id":22,"method":"Emulation.setFocusEmulationEnabled","params":{"enabled":true},"sessionId":"D8169FB4EE16A5D0A8366C326B7FACC6"} +1ms
Additional context
I first experienced this issue when switching from Electron 24.1.0 to 27.1.2 without changing the Playwright version.
Environment
System:
OS: Linux 6.5 Ubuntu 22.04.3 LTS 22.04.3 LTS (Jammy Jellyfish)
CPU: (4) x64 QEMU Virtual CPU version 2.5+
Memory: 12.71 GB / 15.61 GB
Container: Yes
Binaries:
Node: 18.15.0 - ~/.nvm/versions/node/v18.15.0/bin/node
npm: 9.5.0 - ~/.nvm/versions/node/v18.15.0/bin/npm
Languages:
Bash: 5.1.16 - /usr/bin/bash
npmPackages:
@playwright/test: ^1.41.1 => 1.41.1
I was able to repro by modifying the executablePath
:
const electronApp = await _electron.launch({
executablePath: 'dist/mac-arm64/electron-playwright-issue.app/Contents/MacOS/electron-playwright-issue'
});
Can confirm this also happens in our codebase. At the beginning of our program we have this code:
const dummy = new BrowserWindow({ x: 1, y: 1, show: false });
doSomething(dummy.getNativeWindowHandle());
dummy
is the first BrowserWindow
to be created, and because we merely need a HWND
to handle WM_QUERYENDSESSION
messages, loadURL
is not called, which resulted in the same issue.
Once I added
await dummy.loadURL('about:blank');
_electron.launch
no longer hangs.
Environment
Windows 11 x64 22631
[email protected]
[email protected]
[email protected]