Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

playwright: 1.27.1 -> 1.31.1 #214939

Merged
merged 3 commits into from
Apr 17, 2023
Merged

playwright: 1.27.1 -> 1.31.1 #214939

merged 3 commits into from
Apr 17, 2023

Conversation

mguentner
Copy link
Contributor

@mguentner mguentner commented Feb 6, 2023

Description of changes

Updates playwright from 1.27.1 to 1.31.0. Tested by running (typescript) e2e tests and playwright cr https://nixos.org

Things done
  • Built on platform(s)
    • x86_64-linux
    • aarch64-linux
    • x86_64-darwin
    • aarch64-darwin
  • For non-Linux: Is sandbox = true set in nix.conf? (See Nix manual)
  • Tested, as applicable:
  • Tested compilation of all packages that depend on this change using nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD". Note: all changes have to be committed, also see nixpkgs-review usage
  • Tested basic functionality of all binary files (usually in ./result/bin/)
  • 23.05 Release Notes (or backporting 22.11 Release notes)
    • (Package updates) Added a release notes entry if the change is major or breaking
    • (Module updates) Added a release notes entry if the change is significant
    • (Module addition) Added a release notes entry if adding a new NixOS module
    • (Release notes changes) Ran nixos/doc/manual/md-to-db.sh to update generated release notes
  • Fits CONTRIBUTING.md.

@wegank
Copy link
Member

wegank commented Feb 6, 2023

@ofborg build playwright playwright.passthru.tests

@NickCao
Copy link
Member

NickCao commented Feb 7, 2023

error: hash mismatch in fixed-output derivation '/nix/store/i5d93s160jv7wy3sdg7pf2xf1jlr0a4b-playwright-browsers-base.drv':
         specified: sha256-clpDSEZHVT1Vo1fYwKxPc2w35X+RKTUiIrbq8x2Uepg=
            got:    sha256-0ZRC1UpPLEw59hbKHkNe3VnnQOdA6nx7Xp/aziLcuv4=

@mguentner
Copy link
Contributor Author

Can someone on x86_64-darwin please support to figure out what is going on here?

@Gerschtli
Copy link
Contributor

When using this, I get errors for webkit:

browserType.launch: Executable doesn't exist at /nix/store/dfvwk203vzygp2434xgb73hmb5cbh784-playwright-browsers/webkit-1767/pw_run.sh
╔═════════════════════════════════════════════════════════════════════════╗
║ Looks like Playwright Test or Playwright was just installed or updated. ║
║ Please run the following command to download new browsers:              ║
║                                                                         ║
║     npx playwright install                                              ║
║                                                                         ║
║ <3 Playwright Team                                                      ║
╚═════════════════════════════════════════════════════════════════════════╝

And firefox:

browserType.launch: Browser.enable): Browser closed.
==================== Browser output: ====================
<launching> /nix/store/dfvwk203vzygp2434xgb73hmb5cbh784-playwright-browsers/firefox-1372/firefox/firefox -no-remote -headless -profile /tmp/playwright_firefoxdev_profile-BSFxS2 -juggler-pipe -silent
<launched> pid=308691
[pid=308691][err] *** You are running in headless mode.
[pid=308691][out] [GFX1-]: glxtest: libEGL no display
[pid=308691][out] [GFX1-]: glxtest: No visuals found
[pid=308691][out] [GFX1-]: More than 1 GPU vendor detected via PCI, cannot deduce vendor
[pid=308691][out] [GFX1-]: PCI candidate 0x8086/0x9bc4
[pid=308691][out] [GFX1-]: PCI candidate 0x10de/0x1f95
[pid=308691] <process did exit: exitCode=0, signal=null>
[pid=308691] starting temporary directories cleanup
=========================== logs ===========================
<launching> /nix/store/dfvwk203vzygp2434xgb73hmb5cbh784-playwright-browsers/firefox-1372/firefox/firefox -no-remote -headless -profile /tmp/playwright_firefoxdev_profile-BSFxS2 -juggler-pipe -silent
<launched> pid=308691
[pid=308691][err] *** You are running in headless mode.
[pid=308691][out] [GFX1-]: glxtest: libEGL no display
[pid=308691][out] [GFX1-]: glxtest: No visuals found
[pid=308691][out] [GFX1-]: More than 1 GPU vendor detected via PCI, cannot deduce vendor
[pid=308691][out] [GFX1-]: PCI candidate 0x8086/0x9bc4
[pid=308691][out] [GFX1-]: PCI candidate 0x10de/0x1f95
[pid=308691] <process did exit: exitCode=0, signal=null>
[pid=308691] starting temporary directories cleanup
============================================================

Tested with pnpm create playwright and setting PLAYWRIGHT_BROWSERS_PATH = pkgs.playwright.browsers;

@mguentner
Copy link
Contributor Author

NixOS x86_64: the only browser that works for me is chromium. I get the same error with firefox as @Gerschtli
At least the derivation only seems to package chromium, firefox and ffmpeg-linux

@mguentner
Copy link
Contributor Author

playwright defines all it's browsers with their revision / version in this file: https://github.com/microsoft/playwright/blob/e6f83f5b945783067d9bf5cb89cf023bc926478e/packages/playwright-core/browsers.json

The nix derivation for linux constructs a folder that mimics the one playwright install would create and links the browser binaries of the nixpkgs equivalents. Because of this, not only versions will differ (what playwright defines / ships and what is defined in nixpkgs as say firefox) but also the applied patches.
On darwin, the derivation does not even change the binaries for nixpkgs ones, does this work in current master?

The playwright project maintains several patches here. It is worth exploring whether once applied to the derivation in nixpkgs, it will build a firefox that is able to work together with playwright.

At least in the current nixpkgs master, playwright+firefox is also broken. Here is a shell.nix in which you can run playwright ff https://nixos.org to reproduce it.

{ pkgs ? import <nixpkgs> {}
}:
pkgs.mkShell {
  name = "playwright-environment";
  buildInputs = [
    pkgs.playwright
  ];
  shellHook = ''
    export PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD="true"
    export PLAYWRIGHT_BROWSERS_PATH="${pkgs.playwright.browsers}"
    export PLAYWRIGHT_BROWSERS_VERSION="${pkgs.playwright.version}"
  '';
}

For webkit: There does not seem to be an equivalent derivation in nixpkgs right now, here are some hints how to build and start it.

@SuperSandro2000
Copy link
Member

also the applied patches.

We cannot realistically apply them because they are gigantic blobs and unmanageable unless we pin the exact browser version from upstream and then we can also download their blob.

@mguentner
Copy link
Contributor Author

I agree. For the record, it might be possible to extract the information from here, but this is still no guarantee that the result will work as expected.

Accordingly we should remove firefox from the derivation and only enable chromium as this is the only browser that currently works.

Still - I have no idea what the situation on darwin is as the derivation looks completely different. @SuperSandro2000 have you tested your initial work on darwin?

@mguentner
Copy link
Contributor Author

mguentner commented Feb 25, 2023

I have removed firefox support (on Linux, see discussion above) and support for darwin altogether in two commits.
If it turns out that playwright actually works on darwin with the upstream binaries, then I can easily delete the most recent commit 7c78304.

@SuperSandro2000 ☝️

@mguentner mguentner changed the title playwright: 1.27.1 -> 1.30.0 playwright: 1.27.1 -> 1.31.0 Feb 25, 2023
@ofborg ofborg bot added 8.has: clean-up 10.rebuild-darwin: 0 This PR does not cause any packages to rebuild on Darwin and removed 10.rebuild-darwin: 1-10 labels Feb 25, 2023
@mguentner mguentner mentioned this pull request Apr 9, 2023
12 tasks
@yrd
Copy link
Member

yrd commented Apr 10, 2023

Sorry for taking so long to review this…
We've had this discussion before here: microsoft/playwright#5501 It would be nice to get some feedback from the Playwright maintainers, maybe we can include a small subset of their patches to get it to work. As for Darwin, I'll try to get around to testing it again… As far as I remember, the Playwright-provided binaries (which you also get when running playwright install) should work as-is there. Since it depends on system stuff anyway, I would argue it isn't really that reproducible anyway when using the browser bundle on Darwin so it should be fine to just drop it.

@SuperSandro2000
Copy link
Member

maybe we can include a small subset of their patches to get it to work

Last time I checked they had one gigantic patch file, instead of multipler smaller ones we could more easily apply.

Copy link
Member

@SuperSandro2000 SuperSandro2000 left a comment

Choose a reason for hiding this comment

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

please rebase. I don't really have a strong opinion about the changes. Should be alright.

@mguentner
Copy link
Contributor Author

I have rebased against the current master and did some changes along the way:

  • playwright-python is now at the latest 1.31.x release, I did not want to advance it further as already a dependency changed again (greenlet 1.x -> 2.x)
  • I have re-ordered the commits for convenience while testing under darwin, @yrd if you drop the latest commit, you will have mac support again to report back whether the binaries simply work 👍

Regarding the firefox situation: I think that if nixpkgs wants to support playwright + firefox, it should try to package the upstream patched binary and make it run instead of producing a similar patched binary with the nixpkgs firefox derivation. The main reason is that playwright is a e2e testing framework and environments should be quite reproducible so that it makes sense. Replacing binaries changes the environment drastically (like it does not work at all and all your tests fail under NixOS 😆). Patching them to make them work under NixOS only will produce NixOS issues like dynamic linker, patchelf etc. but not fundamental issues like version mismatch (playwright assumes it's firefox x, but nixpkgs replaced it with y) or missing APIs.
After this PR, #197899 should be rebased and firefox support can be added again through the upstream binary. WDYT?

@wegank
Copy link
Member

wegank commented Apr 11, 2023

There was @hamann's #225708 (and a follow-up #225758) a few hours ago, which fixed the x86_64-darwin builds, so I guess the last commit could be dropped?

@ofborg ofborg bot added the 2.status: merge conflict This PR has merge conflicts with the target branch label Apr 11, 2023
firefox requires patches to work with playwright, nixpkgs'
firefox does not work out of the box with playwright.

Discussion: NixOS#214939
@mguentner
Copy link
Contributor Author

@wegank Ah nice, I did not see that! darwin support is back.

@mguentner mguentner changed the title playwright: 1.27.1 -> 1.31.0 playwright: 1.27.1 -> 1.31.1 Apr 11, 2023
@ofborg ofborg bot removed the 2.status: merge conflict This PR has merge conflicts with the target branch label Apr 11, 2023
@ofborg ofborg bot requested a review from SuperSandro2000 April 11, 2023 21:08
@ofborg ofborg bot added 10.rebuild-darwin: 1-10 and removed 10.rebuild-darwin: 0 This PR does not cause any packages to rebuild on Darwin labels Apr 11, 2023
@wegank wegank merged commit 8edbe93 into NixOS:master Apr 17, 2023
@fczuardi
Copy link

so, is it possible to use playwright test on a nodejs project in nixos?

I have tried a bunch of different combination of pkgs, like playwright, playwright-driver, playwright-test, set up the env vars PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD=1 PLAYWRIGHT_SKIP_VALIDATE_HOST_REQUIREMENTS=true PLAYWRIGHT_BROWSERS_PATH=$(nix build --print-out-paths nixpkgs#playwright-driver.browsers)

and typing playwright test on a js project with tests give me all errors with Error: Failed to launch the browser process! spawn /home/fcz/.cache/puppeteer/chrome/linux-1108766/chrome-linux/chrome ENOENT

@Gerschtli
Copy link
Contributor

You need to make sure that the nixpkgs version and the one installed via npm are using the exact same version of playwright. Maybe your npm installed one is more recent.

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

Successfully merging this pull request may close these issues.

7 participants