You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Bug]: Not able to install Playwright in Docker on M1 with aarch64 architecture #796
I encounter an issue where if I run playwright in the docker, I would have the below error
(node:97) UnhandledPromiseRejectionWarning: Error: Page closed
at CRSession. (/usr/local/lib/python3.8/dist-packages/playwright/driver/package/lib/server/chromium/crPage.js:341:60)
at Object.onceWrapper (events.js:420:28)
at CRSession.emit (events.js:326:22)
at /usr/local/lib/python3.8/dist-packages/playwright/driver/package/lib/server/chromium/crConnection.js:177:43
(node:97) 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(). To terminate the node process on unhandled promise rejection, use the CLI flag --unhandled-rejections=strict (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
It run fine in my own machine (macOS m1). I research and saw that it is related to browser.close too early. However, I'm using pytest and is using playwright as sync and not async function since pytest has fixture which can yield the page and then do a browser close later. E.g code below:
pytest.fixture
def page():
with sync_playwright() as p:
browser = p.chromium.launch()
page = browser.new_page()
yield page
browser.close()
Do we. know why the same code run fine in my local machine but not in playwright docker?
From a short investigation, in the logs I can see a Chromium Stacktrace.
Stacktrace
E playwright._impl._api_types.Error: Protocol error (Target.createTarget): Browser closed.
E ==================== Browser output: ====================
E [pid=7450][err] [0707/092357.911702:WARNING:gpu_process_host.cc(1308)] The GPU process has crashed 3 time(s)
E [pid=7450][err] [0707/092357.914350:ERROR:gpu_process_host.cc(989)] GPU process launch failed: error_code=1002
E [pid=7450][err] [0707/092357.914615:WARNING:gpu_process_host.cc(1308)] The GPU process has crashed 4 time(s)
E [pid=7450][err] [0707/092357.916485:ERROR:gpu_process_host.cc(989)] GPU process launch failed: error_code=1002
E [pid=7450][err] base::debug::StackTrace::StackTrace()
E [pid=7450][err] microsoft/playwright#2 0x0040065aba21 [0707/092357.916915:WARNING:gpu_process_host.cc(1308)] The GPU process has crashed 5 time(s)
E [pid=7450][err] [0707/092357.919388:ERROR:gpu_process_host.cc(989)] GPU process launch failed: error_code=1002
E [pid=7450][err] [0707/092357.919652:WARNING:gpu_process_host.cc(1308)] The GPU process has crashed 6 time(s)
E [pid=7450][err] [0707/092357.926915:ERROR:gpu_process_host.cc(989)] GPU process launch failed: error_code=1002
E [pid=7450][err] [0707/092357.927401:WARNING:gpu_process_host.cc(1308)] The GPU process has crashed 7 time(s)
E [pid=7450][err] [0707/092357.940677:ERROR:gpu_process_host.cc(989)] GPU process launch failed: error_code=1002
E [pid=7450][err] [0707/092357.940735:WARNING:gpu_process_host.cc(1308)] The GPU process has crashed 8 time(s)
E [pid=7450][err] base::debug::(anonymous namespace)::StackDumpSignalHandler()
E [pid=7450][err] microsoft/playwright#3 0x00400dd6b3c0 [0707/092357.957861:ERROR:gpu_process_host.cc(989)] GPU process launch failed: error_code=1002
E [pid=7450][err] [0707/092357.957920:WARNING:gpu_process_host.cc(1308)] The GPU process has crashed 9 time(s)
E [pid=7450][err] <unknown>
E [pid=7450][err] microsoft/playwright#4 0x00400dd197b2 <unknown>
E [pid=7450][err] microsoft/playwright#5 0x00400dd1c61b <unknown>
E [pid=7450][err] microsoft/playwright#6 0x00400dd27d37 <unknown>
E [pid=7450][err] microsoft/playwright#7 0x00400edd08b8 _dl_catch_exception
E [pid=7450][err] microsoft/playwright#8 0x00400dd275fa <unknown>
E [pid=7450][err] microsoft/playwright#9 0x00400dd4f34c <unknown>
E [pid=7450][err] microsoft/playwright#10 0x00400edd08b8 _dl_catch_exception
E [pid=7450][err] microsoft/playwright#11 0x00400edd0983 _dl_catch_error
E [pid=7450][err] microsoft/playwright#12 0x00400dd4fb59 <unknown>
E [pid=7450][err] microsoft/playwright#13 0x00400dd4f3da dlopen
E [pid=7450][err] microsoft/playwright#14 0x004003cefa70 LibUdev0Loader::Load()
E [pid=7450][err] microsoft/playwright#15 0x004003cee9e4 device::Udev1Loader::Init()
E [pid=7450][err] microsoft/playwright#16 0x004003ceea49 device::UdevLoader::Get()
E [pid=7450][err] microsoft/playwright#17 0x004003cee119 device::udev_new()
E [pid=7450][err] microsoft/playwright#18 0x004003ceedf7 device::UdevWatcher::StartWatching()
E [pid=7450][err] microsoft/playwright#19 0x004003da3ed5 media::DeviceMonitorLinux::BlockingTaskRunnerHelper::Initialize()
E [pid=7450][err] microsoft/playwright#20 0x00400656eb73 base::TaskAnnotator::RunTask()
E [pid=7450][err] microsoft/playwright#21 0x004006585ba7 base::internal::TaskTracker::RunContinueOnShutdown()
E [pid=7450][err] microsoft/playwright#22 0x00400658568e base::internal::TaskTracker::RunTask()
E [pid=7450][err] microsoft/playwright#23 0x0040065bc50e base::internal::TaskTrackerPosix::RunTask()
E [pid=7450][err] microsoft/playwright#24 0x004006585318 base::internal::TaskTracker::RunAndPopNextTask()
E [pid=7450][err] microsoft/playwright#25 0x004006590ead base::internal::WorkerThread::RunWorker()
E [pid=7450][err] microsoft/playwright#26 0x004006590bad base::internal::WorkerThread::RunPooledWorker()
E [pid=7450][err] microsoft/playwright#27 0x0040065bcd5c base::(anonymous namespace)::ThreadFunc()
E [pid=7450][err] microsoft/playwright#28 0x00400dd5f609 start_thread
E [pid=7450][err] microsoft/playwright#29 0x00400ed8f293 clone
E [pid=7450][err] r8: 00000000effffef5 r9: 0000000070000022 r10: 00000040172c6000 r11: 0000000000000032
E [pid=7450][err] r12: 000033aa00424000 r13: 000000006ffffeff r14: 0000004013a9a818 r15: 000000006ffffe35
E [pid=7450][err] di: 000000006fffffff si: 0000000000000029 bp: 0000004013a9a740 bx: 000000006ffffdff
E [pid=7450][err] dx: 0000000000000000 ax: 0000061d0000061c cx: 000033aa00424040 sp: 0000004013a9a5f0
E [pid=7450][err] ip: 000000400dd197b2 efl: 0000000000000202 cgf: 002b000000000033 erf: 0000000000000004
E [pid=7450][err] trp: ffffffffffffffff msk: 0000000000000000 cr2: 0000061d00000624
E [pid=7450][err] [end of stack trace]
E [pid=7450][err] qemu: uncaught target signal 11 (Segmentation fault) - core dumped
This looks like a Docker bug. See the following related issues:
Also it seems you can workaround it by passing args=["--disable-gpu"] when launching the browser or we would need to create Docker images for the ARM64 architecture.
Another workaround which might work is using the Docker image ubuntu:focal instead and installing Playwright in there manually and the dependencies via playwright install and playwright install-deps. See here for docs.
Thanks for checking. Using args=["--disable-gpu"] does not help.
Please find the attached logs for this => logs.txt
I triedubuntu:focaldocker image before but I have the below playwright version install error where I can't install the latest version and stuck with 0.162.2 only
> [ 9/12] RUN pip install playwright==1.12.1: microsoft/playwright#12 1.281 ERROR: Could not find a version that satisfies the requirement playwright==1.12.1 (from versions: 0.0.1, 0.0.2, 0.0.3, 0.0.4, 0.0.5, 0.0.6, 0.0.7, 0.0.8, 0.0.9, 0.0.10, 0.0.11, 0.0.12, 0.0.13, 0.0.14, 0.0.15, 0.0.16, 0.0.17, 0.0.18, 0.7.0, 0.7.1, 0.8.0, 0.140.0, 0.142.0, 0.142.1, 0.142.2, 0.142.3, 0.150.0, 0.151.0, 0.151.1, 0.152.0, 0.162.0, 0.162.1, 0.162.2) microsoft/playwright#12 1.282 ERROR: No matching distribution found for playwright==1.12.1
Here it is. What does this mean? This also only happen in docker only.
pip debug --verbose
Traceback (most recent call last):
File "/usr/bin/pip", line 11, in <module>
load_entry_point('pip==20.0.2', 'console_scripts', 'pip')()
File "/usr/lib/python3/dist-packages/pip/_internal/cli/main.py", line 73, in main
command = create_command(cmd_name, isolated=("--isolated" in cmd_args))
File "/usr/lib/python3/dist-packages/pip/_internal/commands/__init__.py", line 96, in create_command
module = importlib.import_module(module_path)
File "/usr/lib/python3.8/importlib/__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
File "<frozen importlib._bootstrap>", line 991, in _find_and_load
File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 848, in exec_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "/usr/lib/python3/dist-packages/pip/_internal/commands/debug.py", line 11, in <module>
from pip._vendor.certifi import where
ModuleNotFoundError: No module named 'pip._vendor.certifi'
Seems like the PIP installation inside the Docker container (also the official image) seems broken. Could you try executing this beforehand inside the container?
changed the title [-]Playwright Docker throwing UnhandledPromiseRejectionWarning: Error: Page closed[/-][+][Bug]: Not able to install Playwright in Docker on M1 with aarch64 architecture[/+]on Jul 7, 2021
budsee As per the logs, on apple m1 the docker runs natively with arm64 but currently playwright only supports x86_64 on linux docker, if you want to run it currently then you need to emulate x86 with qemu.
Activity
mxschmitt commentedon Jul 7, 2021
Hi, would be great if you could provide us more logs using the
DEBUG=pw:apienvironment variable, there we should see the API calls.Also I'm curious why you are not using the official Pytest plugin for Playwright: https://github.com/microsoft/playwright-pytest
budsee commentedon Jul 7, 2021
Hi
The logs are huge, so I pipe to a file and attached here => logs.txt
Ah it's because I'm using pytest-bdd to be exact. playwright-pytest does not seem to work with pytest-bdd
mxschmitt commentedon Jul 7, 2021
From a short investigation, in the logs I can see a Chromium Stacktrace.
Stacktrace
This looks like a Docker bug. See the following related issues:
Also it seems you can workaround it by passing
args=["--disable-gpu"]when launching the browser or we would need to create Docker images for theARM64architecture.Another workaround which might work is using the Docker image
ubuntu:focalinstead and installing Playwright in there manually and the dependencies viaplaywright installandplaywright install-deps. See here for docs.budsee commentedon Jul 7, 2021
Thanks for checking. Using
args=["--disable-gpu"]does not help.Please find the attached logs for this => logs.txt
I tried
ubuntu:focaldocker image before but I have the below playwright version install error where I can't install the latest version and stuck with 0.162.2 only> [ 9/12] RUN pip install playwright==1.12.1: microsoft/playwright#12 1.281 ERROR: Could not find a version that satisfies the requirement playwright==1.12.1 (from versions: 0.0.1, 0.0.2, 0.0.3, 0.0.4, 0.0.5, 0.0.6, 0.0.7, 0.0.8, 0.0.9, 0.0.10, 0.0.11, 0.0.12, 0.0.13, 0.0.14, 0.0.15, 0.0.16, 0.0.17, 0.0.18, 0.7.0, 0.7.1, 0.8.0, 0.140.0, 0.142.0, 0.142.1, 0.142.2, 0.142.3, 0.150.0, 0.151.0, 0.151.1, 0.152.0, 0.162.0, 0.162.1, 0.162.2) microsoft/playwright#12 1.282 ERROR: No matching distribution found for playwright==1.12.1mxschmitt commentedon Jul 7, 2021
Could you provide us the output of
pip debug --verbose?budsee commentedon Jul 7, 2021
Here it is. What does this mean? This also only happen in docker only.
pip debug --verbose
mxschmitt commentedon Jul 7, 2021
Seems like the PIP installation inside the Docker container (also the official image) seems broken. Could you try executing this beforehand inside the container?
curl -sS https://bootstrap.pypa.io/get-pip.py | pythonbudsee commentedon Jul 7, 2021
Does not seem to help
root@db8d954583cc:/# pip install playwright==1.21.1 ERROR: Could not find a version that satisfies the requirement playwright==1.21.1 (from versions: 0.0.1, 0.0.2, 0.0.3, 0.0.4, 0.0.5, 0.0.6, 0.0.7, 0.0.8, 0.0.9, 0.0.10, 0.0.11, 0.0.12, 0.0.13, 0.0.14, 0.0.15, 0.0.16, 0.0.17, 0.0.18, 0.7.0, 0.7.1, 0.8.0, 0.140.0, 0.142.0, 0.142.1, 0.142.2, 0.142.3, 0.150.0, 0.151.0, 0.151.1, 0.152.0, 0.162.0, 0.162.1, 0.162.2) ERROR: No matching distribution found for playwright==1.21.1mxschmitt commentedon Jul 7, 2021
And what is the output for
pip debug --verbosethere?Background: pip debug will log the supported architectures, based on that we can see where the problem is.
budsee commentedon Jul 7, 2021
Here's the updated one => logs.txt
[-]Playwright Docker throwing UnhandledPromiseRejectionWarning: Error: Page closed[/-][+][Bug]: Not able to install Playwright in Docker on M1 with aarch64 architecture[/+]kumaraditya303 commentedon Jul 8, 2021
budsee As per the logs, on apple m1 the docker runs natively with arm64 but currently playwright only supports x86_64 on linux docker, if you want to run it currently then you need to emulate x86 with qemu.
budsee commentedon Jul 8, 2021
Thanks! Will there be any future plan to incorporate arm64 into the docker anytime soon?
mxschmitt commentedon Jul 29, 2021
Since the Python image is based on the upstream one, I will close this one here and we will track it upstream: microsoft/playwright#7723