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

[BUG] Playwright Chromium based tools don't work in WSL #21813

Closed
fdgonthier opened this issue Mar 20, 2023 · 8 comments
Closed

[BUG] Playwright Chromium based tools don't work in WSL #21813

fdgonthier opened this issue Mar 20, 2023 · 8 comments

Comments

@fdgonthier
Copy link

System info

  • Playwright Version: 1.x, or master
  • Operating System: Windows 10
  • Browser: Chromium
  • Other info:

Playwright generally works on WSL but, in some case, the Chromium-based GUI tools might end up like this:

image

If this is the case, it's likely all Chromium based applications are likely broken and will have the same goth appearance. This means that your GPU is not properly supported in WSL. You can solve this on a per-app basis by passing the --disable-gpu flag to Chrome applications but Playwright does not allow that.

@fdgonthier
Copy link
Author

There is a flag that you can add to your .wslconfig file which disables GPU support for all WSL applications:

[wsl2]
...
gpuSupport=false

This flag was found through a Google search and is not otherwise in .wslconfig documentation, which is here: https://learn.microsoft.com/en-us/windows/wsl/wsl-config

While disabling the GPU use in WSL not entirely ideal, this at least made the Chromium based application work on my system. This includes Playwright tools and other well-known apps. Maybe then, just don't use a WSL Chrome-based browser as a daily driver.

I think this deserve a mention in Playwright documentation.

@mxschmitt
Copy link
Member

I don't have this config file and it works on my machine with WSL2 out of the box using Ubuntu 20. Maybe you have something else configured which is non-default?

Happy to mention something about WSL, but only if it affects default setups.

@fdgonthier
Copy link
Author

fdgonthier commented Mar 21, 2023

I'm make very extensive use of WSL so I have a few settings changed in .wslconfig. I was 99% sure that this was not working when I got that computer but I did clear the .wslconfig file anyway to test it and make sure. I got this result which I now remember to be familiar...

image

With .wslconfig gone, all the defaults, all I get are transparent windows. With WSLg disabled, and using an X server, the windows become black instead. In both cases, disabling the use of the GPU, locally for Chromium instances, or globally, fixes the problem.

@k1sul1
Copy link

k1sul1 commented Apr 3, 2023

I have the same issue.
image

I made the gpuSupport change, this is what my .wslconfig looks like:

[wsl2]
memory=12GB
swap=0
processors=6

# https://github.com/microsoft/playwright/issues/21813
gpuSupport=false

And wouldn't you know it...

image

I literally spent an hour and 45 minutes before I found this issue, combed through the documentation, and found nothing. As someone evaluating between Cypress & Playwright, this would've been a dealbreaker, as I have no trouble running Cypress.

Since there was literally zero mention about GPUs not working in WSL, I thought that my issue was with this:

image

My computer is managed by my employer, and the ExtensionInstallForcelist policy is set. It doesn't reach into the depths of WSL, but as with any new technology, I didn't know that. 👍 👍 👍 on adding a note about this to the troubleshooting page.

Now that I got it working, I have to say... npx playwright codegen is literally the easiest e2e workflow I've ever seen. This is amazing.

@rgripper
Copy link

rgripper commented Jun 29, 2023

I confirm having the same issue for Chromium. Fixed by disabling GPU through that config.
I didn't have .wslconfig initially on my system.
Windows 11 Home 22H2
WSL 2
Ubuntu 22.04.2 LTS.
playwright 1.35.1

@pavelfeldman
Copy link
Member

Why was this issue closed?

Thank you for your contribution to our project. This issue has been closed due to its limited upvotes and recent activity, and insufficient feedback for us to effectively act upon. Our priority is to focus on bugs that reflect higher user engagement and have actionable feedback, to ensure our bug database stays manageable.

Should you feel this closure was in error, please create a new issue and reference this one. We're open to revisiting it given increased support or additional clarity. Your understanding and cooperation are greatly appreciated.

@k1sul1
Copy link

k1sul1 commented Apr 23, 2024

Your understanding and cooperation are greatly appreciated

I'd have more understanding if real issues weren't closed with a copypasta response, esp. when the issue could be mitigated by mentioning it in the documentation.

https://learn.microsoft.com/en-us/windows/wsl/troubleshooting <-- Not one word about GPU problems.

I guess it's not that important since this issue is literally the 3rd thing that comes up when I search for "playwright wsl".

@krukonshedul
Copy link

krukonshedul commented Jul 3, 2024

It's 2am, I'm 12h into trying to get Playwright (but not only Playwright - it's been the last one to surrender it's misgivings and start working) to behave on my brand new PC (Win11 + WSL2 + Ubuntu22 + intel CPU), right after setting it up and the

[wsl2]
gpuSupport=false

in the %UserProfile%/.wslconfig file that I've created for this purpose was what got it working. I've never had any similar problems on any of the machines I interacted with, including my previous setups (Win10 + WSL2 + Ubuntu22 & another Win10 + WSL2 + Ubuntu22, both with dedicated GPUs & MacOs & various CI systems).

I'll try to sort out all of my actions here later on for any1 looking, but I had exactly the same symptoms (the border of the window displayed, but transparent and without any content) on any of the Ubuntu apps more complex than xapps, such as playwrightless google-chrome and all the other browsers I've tried - which'd suggest that Playwright invocation of those browsers in the WSL setup is a victim of a bug laying elsewhere.

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

No branches or pull requests

7 participants