Rayrun
โ† Back to Discord Forum

[Question] How does Playwright track, build and embed the open source WebKit?

I'm really curious to know how Playwright does it, and why it uses this approach rather than the WebKit binaries that come with macOS.

Some more specifics:

  1. how does it know which branch/commit from the open-source WebKit repo to track and use to build?
  2. do users of Playwright have to build WebKit, or does it come with Playwright?
  3. How does it communicate with WebKit? Does it use WKWebView or some other interface/protocol, similar to Chrome Devtools Protocol?

Note, I also posted this in the GitHib repo, not sure where was best. Best regards.

This thread is trying to answer question "How does Playwright track, build, and embed the open-source WebKit, and can it work with a company's own patched WebKit binaries?"

20 replies

PW or more secificaly the browser support librarys is where the magic to allow PW and the browser to communicate, the versions need to match up, only way to ensure the shape of the object, or members in the ojbect match up. And with that PW is able to communicate with the given browsers.

thanks for the response @dand33 ๐Ÿ™‚

Its a great answer that abstracts the away the specifics of embedding each browser, which is great, but im more curious about the specifics between PW and WebKit. Specifically, questions 1 and 3.

I wasnt able to find how PW talks to WebKit in the repo, so thats why I am asking here. If i can get redirected to where that logic is, that would be great as well. Thanks!

do users of Playwright have to build WebKit, or does it come with Playwright?

It comes with playwright (when you do npx playwright install in node or its analogues in other environments), just like the other browsers

https://github.com/microsoft/playwright/issues/5795 and here's something about browser versions

why it uses this approach rather than the WebKit binaries that come with macOS.

Because they want to be multiplatform, and macos ones only work on macos (i guess)

refactoreric

Here's something from 2 years ago with a presentation about the architecture of Playwright: https://www.youtube.com/watch?v=PXTspGn1im0

Basically Playwright supports 3 engines: Chromium, Firefox, WebKit.

Chromium-based browsers are supported without patches, as long as they match the supported versions listed in the release notes.

Firefox requires patches to its devtools protocol (Juggler).

Safari isn't cross-platform, so Playwright provides a cross-platform WebKit browser. (And I think it has some patches for the WebKit inspector protocol as well?)

In most cases it's best and most convenient to just use the Playwright-provided browsers. npx playwright install installs them. https://playwright.dev/docs/browsers

You can also use channels for Chrome and Edge.

Perhaps when WebDriver BiDi catches up to the capabilities required for Playwright, then Playwright may start using that protocol, and no longer needs to provide patched or custom-built browsers.

@refactoreric thanks! Do you know if PW's patched WebKit and Firefox are open-source?

@mxschmitt hmmm, I guess what I am asking specifically is if the source code of the patched WebKit builds in PW are open-source, like a fork of the WebKit open source project. I wasnt able to find that in the link you provided, but I could be mistaken. Thanks again ๐Ÿ™‚

yes, just found them. Thank you!

This diff file is great, and shows every patch PW has made to its WebKit fork, but im still curious if the actual repo of fork (if it exists) is open-source, do you know if it is? @mxschmitt

There is no fork with individual patches, we only work with these patch files (firefox,webkit).

ahh okay, given the diff file, how can history be tracked then?

the dev experience with the patch file alone seems very limiting. I guess im just wondering if someone wanted to contribute to the patches, what would the dx look like

Apply diff, make changes, generate diff. Usually the barrier for browser contributions is very high, hence we have not documented it. What are you trying to work on?

i want to experiment with a couple things:

  1. my company (https://sigmaos.com) patches and embeds WebKit binaries as well. I want to experiment with using PW with our WebKit binaries, by applying the PW patches then our patches on top.
  2. try to allow PW to evaluate script in already existing content worlds of a webpage

Yeah this seems outside of the scope for Playwright. The patches above is all what we do in order to communicate with the browser over pipes.

so in theory, assuming that my patches dont mess with the PW patches, then I could hook up my WebKit binaries to Playwright it should work no?

Related Discord Threads

TwitterGitHubLinkedIn
AboutQuestionsDiscord ForumBrowser ExtensionTagsQA Jobs

Rayrun is a community for QA engineers. I am constantly looking for new ways to add value to people learning Playwright and other browser automation frameworks. If you have feedback, email [email protected].