Skip to content

Conversation

mxschmitt
Copy link
Member

@mxschmitt mxschmitt commented Jun 19, 2025

This PR adds support for running WebKit in a dedicated WSL environment (webkit-wsl) on Windows. It introduces a transport layer to proxy browser communication between Windows and WSL, along with a PowerShell script to install and configure a WSL distro with the necessary WebKit setup.

#37036

@mxschmitt mxschmitt force-pushed the webkit-via-wsl-experiment branch from 10a64dd to 34667d2 Compare June 19, 2025 12:30

This comment has been minimized.

Copy link
Contributor

@agg23 agg23 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is very clean. I like it.

@mxschmitt mxschmitt force-pushed the webkit-via-wsl-experiment branch from 71966c1 to ba2acea Compare July 3, 2025 14:18

This comment has been minimized.

This comment has been minimized.

@mxschmitt mxschmitt force-pushed the webkit-via-wsl-experiment branch from 3bebff5 to add6387 Compare August 5, 2025 12:02

This comment has been minimized.

@mxschmitt mxschmitt force-pushed the webkit-via-wsl-experiment branch from add6387 to 5e6d1dd Compare August 13, 2025 14:12

This comment has been minimized.

@mxschmitt mxschmitt force-pushed the webkit-via-wsl-experiment branch from 5e6d1dd to a572b25 Compare August 15, 2025 09:33

This comment has been minimized.

This comment has been minimized.

@mxschmitt mxschmitt force-pushed the webkit-via-wsl-experiment branch from 7f35898 to b9d96dd Compare August 17, 2025 15:17

This comment has been minimized.

This comment has been minimized.

Copy link
Member

@Skn0tt Skn0tt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks great! there's a few places where comments could help, but otherwise I only have nits.

const [executable, ...args] = process.argv.slice(2);

if (!(await fs.promises.stat(executable)).isFile())
throw new Error(`Executable does not exist. Did you update Playwright recently? Make sure to run npx playwright install webkit-wsl`);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, can we throw the exact error somewhere in a parent? We try to detect the package manager, so npx isn't necessarily accurate.

@mxschmitt mxschmitt force-pushed the webkit-via-wsl-experiment branch from 8d9d0ca to e0ddad3 Compare August 18, 2025 12:16

This comment has been minimized.

@mxschmitt mxschmitt marked this pull request as ready for review August 18, 2025 15:47
Copy link
Contributor

@dgozman dgozman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The implementation looks mostly good, but I got tired halfway through the tests. It seems like we should address those tests that do not work and minimize changes that should be done by the user.

@@ -98,3 +108,8 @@ export class WebKit extends BrowserType {
return webkitArguments;
}
}

export async function translatePathToWSL(path: string): Promise<string> {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As discussed before, perhaps do this once, save somewhere on WKBrowser and then just path.join() when needed?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The input path is from the user, could be from a different drive, network file share, be a symlink etc. so I don't think any custom path join logic would be bug-free looking at their impl - lets keep the async call for now and iterate later on it if needed?


child.on('close', (code, signal) => {
log('Child exit', { code, signal });
shutdown(code ?? (signal ? 0 : 0));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't this be non-zero when signal is present?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done, ptal.

parentOut.destroy();

// Close listener and destroy any sockets
await new Promise(resolve => server.close(() => resolve(null)));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the pattern should be:

  • call server.close()
  • destroy sockets
  • wait for server.close callback

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done, ptal.

});
})().catch(error => {
console.error('Error occurred:', error);
process.exit(1);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we try to preserve the childs error code?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The child's exit code is already preserved on lines 67-70. The process.exit(1) in the catch block is only for setup errors that happen before the child process starts (like missing env vars, file not found, socket connection issues). Those aren't child exit codes since the child hasn't run yet.

@mxschmitt mxschmitt force-pushed the webkit-via-wsl-experiment branch from e0ddad3 to 763eddd Compare August 26, 2025 14:56

This comment has been minimized.

@mxschmitt mxschmitt force-pushed the webkit-via-wsl-experiment branch from 763eddd to 539a7cd Compare August 27, 2025 11:28

This comment has been minimized.

@mxschmitt mxschmitt force-pushed the webkit-via-wsl-experiment branch from 539a7cd to 294493a Compare September 5, 2025 16:02

This comment has been minimized.

@mxschmitt mxschmitt force-pushed the webkit-via-wsl-experiment branch from 0f3c524 to 6887a77 Compare September 9, 2025 09:12

This comment has been minimized.

This comment has been minimized.

@mxschmitt mxschmitt merged commit 573441c into microsoft:main Sep 9, 2025
34 of 37 checks passed
@mxschmitt mxschmitt deleted the webkit-via-wsl-experiment branch September 9, 2025 10:34
Copy link
Contributor

github-actions bot commented Sep 9, 2025

Test results for "tests 1"

1 failed
❌ [playwright-test] › runner.spec.ts:118 › should ignore subprocess creation error because of SIGINT @macos-latest-node18-1

3 flaky ⚠️ [firefox-library] › library/inspector/cli-codegen-1.spec.ts:1079 › cli codegen › should not throw csp directive violation errors `@firefox-ubuntu-22.04-node18`
⚠️ [firefox-page] › page/page-emulate-media.spec.ts:144 › should keep reduced motion and color emulation after reload `@firefox-ubuntu-22.04-node18`
⚠️ [chromium-library] › library/proxy.spec.ts:93 › should proxy local network requests › with other bypasses › loopback address `@ubuntu-22.04-chromium-tip-of-tree`

46774 passed, 821 skipped


Merge workflow run.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants