playwright
playwright copied to clipboard
[BUG] Safari/WebKit browser doesn't work in docker container
System info
- Playwright Version: [v1.34.2]
- Operating System: [macOS 13.2, mcr.microsoft.com/playwright:v1.34.2-jammy]
- Browser: [WebKit]
- Other info:
Source code
- [ ] I provided exact source code that allows reproducing the issue locally. https://github.com/sylhero/playwright-bug
Link to the GitHub repository with the repro
[https://github.com/sylhero/playwright-bug]
Steps
Expected
it should work as running on the local
Actual
blank screen and timeout
+1. Previously it used to work without any extra packages. Probably need to rebuild the docker image with libgudev
Error: browserType.launch:
╔══════════════════════════════════════════════════════╗
║ Host system is missing dependencies to run browsers. ║
║ Please install them with the following command: ║
║ ║
║ npx playwright install-deps ║
║ ║
║ Alternatively, use apt: ║
║ apt-get install libgudev-1.0-0 ║
║ ║
║ <3 Playwright Team ║
╚══════════════════════════════════════════════════════╝
@sylhero @unickq I've tried the following and worked for me:
$ docker run --rm -it mcr.microsoft.com/playwright:v1.34.2 /bin/bash
root@96e6aeada06b:/$ cd && npm init -y && npm i @playwright/[email protected]
root@96e6aeada06b:~$ cat <<'EOF' > a.mjs
import { webkit } from '@playwright/test';
const browser = await webkit.launch();
const page = await browser.newPage();
console.log(await page.evaluate(() => navigator.userAgent));
await browser.close();
EOF
root@96e6aeada06b:~$ node a.mjs
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/16.4 Safari/605.1.15
We had the issue with the missing dependency, but it should be fixed with 1.34.2 docker image.
@unickq @aslushnikov Thanks for looking into this issue! Yes, it works with other testcases and I have no problem with the docker image or test execution. The real problem for me is if I run the test on my local mac machine directly it works but when I execute the same test with the image it fails. I would like to understand why it happens or did I just find an edge case that breaks the test execution within the container?
@sylhero The issue you're talking about does exit in Playwright 1.34.0 and the corresponding 1.34.0 container: https://github.com/microsoft/playwright/issues/23186
However, it was fixed in the patch releases. So please make sure you use 1.34.2 docker container and latest & greatest Playwright as well.
@aslushnikov I created the test repo with exactly the version you mentioned https://github.com/sylhero/playwright-bug/blob/main/Dockerfile#L1 and https://github.com/sylhero/playwright-bug/blob/main/sample/package.json#L11 and it's still not working
@sylhero your test does fail for me on webkit. The reason it doesn't work is that the website fails to render due to some bad character:
@aslushnikov so two things:
- the website renders properly in all browsers. You can open the link in the test case directly on your local machine
- I enabled chrome,firefox and edge and run the test in the container they all work
Besides that, if I just run the test directly on the local machine it all worked
so without container, all browsers/tests passed. With container only Safari failed.
I was able to reproduce and found out that this is a libsoup2 bug. Once we migrate to libsoup3 this is gonna be fixed. Assigning to me by that.
@mxschmitt - so what is the workaround for now? Manually installing libsoup3 in the container?
Is this going to be a fix to the mcr.microsoft.com/playwright:X
image?
There is unfortunately no workaround available as of today. We need to finish the libsoup3 migration on our side, which we hope to be able to complete with 1.36. But generally speaking we can't commit to any date.
Thanks for your understanding.
Merging this into the libsoup3 tracking bug: https://github.com/microsoft/playwright/issues/22569
The issue persists in v1.37
@aslushnikov what version of playwright we can use? https://github.com/microsoft/playwright/issues/22569 is still open and as someone mentioned above, v1.37 still has same issue.
This issue is still open and isn't fixed yet.
It's merged into https://github.com/microsoft/playwright/issues/22569
@sylhero I was looking into your issue. The issue is that the https://upg.plusgrade.com/static/app/app.727ce299.js
site returns the response as a "double encoded gzip". This means its a gzip in a gzip which is not per spec. The Content-Type header is wrong, it should be application/javascript
.
It works in Chromium and WebKit (with libsoup3) because both accept Brotli as an encoding as well, so then the server will prefer Brotli and the server sends the response correctly when Brotli is accepted while our WebKit as of today (libsoup2.4) does not support Brotli.
You can observe it by doing:
curl -v -H "Accept-Encoding: deflate, gzip" https://upg.plusgrade.com/static/app/app.727ce299.js
compared to e.g.:
curl -v -H "Accept-Encoding: deflate, gzip" https://microsoft.github.io/monaco-editor/runtime.js
The libsoup3 migration is almost done, so it will start working after https://github.com/microsoft/playwright/pull/26596.