Closed Lightgazer closed 4 years ago
This error comes usually up if not all the required dependencies are installed. Since you are using Fedora it could get maybe a bit tricky, a recent list of all the needed dependencies, you can find here: https://github.com/microsoft/playwright/blob/master/docs/docker/Dockerfile.bionic
Your code is correct. Reference: https://try.playwright.tech/?s=1pm22 👍
Thanks for reporting this @Lightgazer. @mxschmitt is right in pointing out that this is due to missing dependencies for WebKit to be launched on Fedora. To debug this, you can use the DEBUG
env variable with the script.
DEBUG=* node test.js
This will return a log message similar to the following which will hint at the missing dependencies (libvpx in this case)
pw:browser:err MiniBrowser: error while loading shared libraries:
libvpx.so.5: cannot open shared object file: No such file or directory
I'll try to spin up a virtualbox with Fedora 31 in case this doesn't help.
@arjun27 maybe also something for the new docs: Provide a list of dependencies and their naming for various Linux distributions (Fedora, CentOS, Debian based ones)
@arjun27 I deleted 'chromium', 'firefox', from the snippent. webkit only debug output:
pw:browser <launching> /home/Lightgazer/etc/code/playwright/node_modules/playwright/.local-browsers/webkit/pw_run.sh --inspector-pipe --headless --no-startup-window +0ms
pw:browser <launched> pid=4817 +5ms
pw:protocol SEND ► {"id":1,"method":"Playwright.createContext"} +0ms
pw:browser:err /home/Lightgazer/etc/code/playwright/node_modules/playwright/.local-browsers/webkit/minibrowser-wpe/MiniBrowser: error while loading shared libraries: libvpx.so.5: cannot open shared object file: No such file or directory +0ms
pw:generic Error: read ECONNRESET
pw:generic at Pipe.onStreamRead (internal/stream_base_commons.js:171:27) [] +0ms
pw:browser <process did exit 127, null> +12ms
(node:4806) UnhandledPromiseRejectionWarning: Error: Protocol error (Playwright.createContext): Browser has been closed.
at Promise (/home/Lightgazer/etc/code/playwright/node_modules/playwright-core/lib/webkit/wkConnection.js:102:63)
at new Promise (<anonymous>)
at WKSession.send (/home/Lightgazer/etc/code/playwright/node_modules/playwright-core/lib/webkit/wkConnection.js:101:16)
at WKBrowser.newContext (/home/Lightgazer/etc/code/playwright/node_modules/playwright-core/lib/webkit/wkBrowser.js:65:65)
at WKBrowser.<anonymous> (/home/Lightgazer/etc/code/playwright/node_modules/playwright-core/lib/helper.js:64:31)
at /home/Lightgazer/etc/code/playwright/test.js:6:35
(node:4806) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:4806) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
after sudo dnf install compat-libvpx5 it become:
DEBUG=* node test.js
pw:browser <launching> /home/Lightgazer/etc/code/playwright/node_modules/playwright/.local-browsers/webkit/pw_run.sh --inspector-pipe --headless --no-startup-window +0ms
pw:browser <launched> pid=5854 +4ms
pw:protocol SEND ► {"id":1,"method":"Playwright.createContext"} +0ms
pw:browser:err /home/Lightgazer/etc/code/playwright/node_modules/playwright/.local-browsers/webkit/minibrowser-wpe/MiniBrowser: error while loading shared libraries: libjpeg.so.8: cannot open shared object file: No such file or directory +0ms
pw:generic Error: read ECONNRESET
pw:generic at Pipe.onStreamRead (internal/stream_base_commons.js:171:27) [] +0ms
pw:browser <process did exit 127, null> +12ms
(node:5843) UnhandledPromiseRejectionWarning: Error: Protocol error (Playwright.createContext): Browser has been closed.
at Promise (/home/Lightgazer/etc/code/playwright/node_modules/playwright-core/lib/webkit/wkConnection.js:102:63)
at new Promise (<anonymous>)
at WKSession.send (/home/Lightgazer/etc/code/playwright/node_modules/playwright-core/lib/webkit/wkConnection.js:101:16)
at WKBrowser.newContext (/home/Lightgazer/etc/code/playwright/node_modules/playwright-core/lib/webkit/wkBrowser.js:65:65)
at WKBrowser.<anonymous> (/home/Lightgazer/etc/code/playwright/node_modules/playwright-core/lib/helper.js:64:31)
at /home/Lightgazer/etc/code/playwright/test.js:6:35
(node:5843) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:5843) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
It seems fedora doesn't have libjpeg8 package.
upd I found user repo with libjpeg https://copr.fedorainfracloud.org/coprs/aflyhorse/libjpeg/ But I cant find next dependency: libwebp.so.6.
I also experienced this when trying webkit on Ubuntu 18.04.4. It'd be nice with a better error message, but maybe that is not trivial as many dependencies can be missing?
Hi, same error on Ubuntu 19.10
I also cannot run with webkit on Manjaro. I don't mind the error, but in examples there could be a note that webkit
might not work on Linux OS
@thernstig, @anoop0567, for Ubuntu, I would recommend using our example Docker setup (which is based on Ubuntu) to find the missing dependencies.
@selfrefactor Webkit works on Linux, but I don't think we've tried Manjaro. To debug this issue, you can use the DEBUG environment variable. Set it to DEBUG=pw:browser*
to see the missing dependencies while launching WebKit
Thank you @arjun27 for your fast reply. I can open separate issue if you'd prefer that, but meanwhile this is the error log:
pw:browser:err /home/s/.cache/ms-playwright/webkit-1219/minibrowser-gtk/MiniBrowser:
error while loading shared libraries: libpcre.so.3: cannot open shared object file:
No such file or directory +0ms
pw:browser <process did exit 127, null> +6ms
Ubuntu 19.10 doesn't have libvpx5 package.
Maybe you can use Static linking when compile MiniBrowser? So it will include desired dependencies.
Thank you @Lightgazer for the suggestion, but I will just give up as this is not a deal-breaker for me.
Ubuntu 19.10 doesn't have libvpx5 package.
Maybe you can use Static linking when compile MiniBrowser? So it will include desired dependencies.
@Lightgazer and @selfrefactor and for people that may find this useful 👋 I'm using focal (20.04), there's not libvpx5 package too since it's been superseded by libvpx5.
Here's what I did to fix the issue, I've downloaded libvpx5 package from Bionic
wget http://security.ubuntu.com/ubuntu/pool/main/libv/libvpx/libvpx5_1.7.0-3ubuntu0.18.04.1_amd64.deb
Then just install it
sudo apt install ./libvpx5_1.7.0-3ubuntu0.18.04.1_amd64.deb
However I still can't open webkit with { headless: false }
I can only make it work with headless
I was able to make headful work. I'm using WSL2 / Ubuntu 20.04
So under /usr/lib/x86_64-linux-gnu
I just did a symlink
ln -s libffi.so.7.1.0 libffi.so.6
and webkit now works!
thisguychris's fix solved my issue and I can now use WebKit with headless: false on Ubuntu 20.04
also facing Error: Protocol error (Playwright.createContext): Browser has been closed.
issue when running tests headless in webkit in Teamcity using Docket setup from example.
"playwright": "^1.0.2",
running with codeceptjs.
I see in logs
[Step 1/1] Step 3/9 : RUN apt-get install -y libwoff1 libopus0 libwebp6 libwebpdemux2 libenchant1c2a libgudev-1.0-0 libsecret-1-0 libhyphen0 libgdk-pixbuf2.0-0 libegl1 libnotify4 libxslt1.1 libevent-2.1-6 libgles2 libvpx5
Though I remember a month or so ago I first time tried running tests it worked fine on all 3 supported browsers.
running tests as
sudo docker build -t microsoft/playwright:bionic -f Dockerfile.bionic .
sudo docker run -d --rm --name playwright microsoft/playwright:bionic
npm install
npx codeceptjs run --steps --verbose
Ubuntu 19.10 doesn't have libvpx5 package. Maybe you can use Static linking when compile MiniBrowser? So it will include desired dependencies.
@Lightgazer and @selfrefactor and for people that may find this useful 👋 I'm using focal (20.04), there's not libvpx5 package too since it's been superseded by libvpx5.
Here's what I did to fix the issue, I've downloaded libvpx5 package from Bionic
wget http://security.ubuntu.com/ubuntu/pool/main/libv/libvpx/libvpx5_1.7.0-3ubuntu0.18.04.1_amd64.deb
Then just install it
sudo apt install ./libvpx5_1.7.0-3ubuntu0.18.04.1_amd64.deb
~However I still can't open webkit with
{ headless: false }
I can only make it work with headless~I was able to make headful work. I'm using WSL2 / Ubuntu 20.04
So under
/usr/lib/x86_64-linux-gnu
I just did a symlink
ln -s libffi.so.7.1.0 libffi.so.6
and webkit now works!
@thisguychris Works!!! Thanks!! OS: Ubuntu 20.04 LTS
I've just encountered this bug on NixOS. Is it somehow possible to create a better sandboxed environment for the browser binaries? (At least) Chrome assumes that there are a lot of dependencies at specific file paths, which is prone to errors on the diverse Linux landscape.
Is it possible to statically link all dependencies to each browser executable (or bundle them within their directories) , for better sandboxing?
Operating System: Fedora 31
@Lightgazer fedora is not officially supported atm, so build's crashing.
I'm using focal (20.04), there's not libvpx5 package too since it's been superseded by libvpx5.
@thisguychris Focal (Ubuntu 20.04) is now officially supported since Playwright v1.3.0
Is it possible to statically link all dependencies to each browser executable (or bundle them within their directories) , for better sandboxing?
@Philipp-M all our attempts here failed so far.
Everybody: Playwright v1.3.0 features a "launch doctor" that should print a nice error when some of the browsers miss a dependency and thus cannot launch. Hopefully, this should help battling the dependencies!
Context:
Code Snippet
I just used snippet from README.md
Describe the bug
It creates firefox and chrome screenshots, then falls: