'Puppeteer stuck while capture image
I'm using puppeteer to save some pages as images. When running I see the following errors:
15/2/2022-18:02:43 - Server started on port 8877
[0215/181819.876532:ERROR:browser_main_loop.cc(530)] Failed to open an X11 connection.
[0215/181819.877897:ERROR:bus.cc(392)] Failed to connect to the bus: Failed to connect to socket /var/run/dbus/system_bus_socket: No such file or directory
[0215/181819.879444:WARNING:dns_config_service_linux.cc(470)] Failed to read DnsConfig.
[0215/181819.881540:ERROR:gl_implementation.cc(403)] Failed to load /usr/lib/chromium/swiftshader/libGLESv2.so: Error loading shared library /usr/lib/chromium/swiftshader/libGLESv2.so: No such file or directory
[0215/181819.882631:ERROR:vaapi_wrapper.cc(596)] Could not get a valid VA display
DevTools listening on ws://127.0.0.1:40752/devtools/browser/497bc455-7ee9-41e2-ad3d-e615a1710994
[0215/181819.916748:ERROR:gpu_channel_manager.cc(818)] ContextResult::kFatalFailure: Failed to create shared context for virtualization.
[0215/181819.916796:ERROR:shared_image_stub.cc(524)] SharedImageStub: unable to create context
[0215/181819.916828:ERROR:gpu_channel.cc(568)] GpuChannel: Failed to create SharedImageStub
start
[0215/181820.118042:ERROR:gpu_channel_manager.cc(818)] ContextResult::kFatalFailure: Failed to create shared context for virtualization.
[0215/181820.118081:ERROR:shared_image_stub.cc(524)] SharedImageStub: unable to create context
[0215/181820.118107:ERROR:gpu_channel.cc(568)] GpuChannel: Failed to create SharedImageStub
[0215/181820.118667:ERROR:gpu_channel_manager.cc(818)] ContextResult::kFatalFailure: Failed to create shared context for virtualization.
[0215/181820.118689:ERROR:shared_image_stub.cc(524)] SharedImageStub: unable to create context
[0215/181820.118702:ERROR:gpu_channel.cc(568)] GpuChannel: Failed to create SharedImageStub
[0215/181820.119245:ERROR:gpu_channel_manager.cc(818)] ContextResult::kFatalFailure: Failed to create shared context for virtualization.
[0215/181820.119266:ERROR:shared_image_stub.cc(524)] SharedImageStub: unable to create context
[0215/181820.119279:ERROR:gpu_channel.cc(568)] GpuChannel: Failed to create SharedImageStub
The code remain blocked and the latter errors are printed in loop.
I'm using puppeteer version 13.3.1:
"dependencies": {
"axios": "^0.24.0",
"cors": "~2.8.4",
"easy-pid-file": "~1.0.7",
"express": "~4.16.3",
"jspdf": "~2.3.1",
"moment": "^2.29.1",
"puppeteer": "^13.3.1",
"y18n": "^5.0.5"
}
When starting the browser I use the following config:
const browser = await puppeteer.launch({
dumpio: true,
executablePath: process.env.CHROMIUM_PATH,
args: ["--no-sandbox","--disable-setuid-sandbox","--disable-dev-shm-usage", "--disable-accelerated-2d-canvas","--no-first-run","--no-zygote", "--single-process","--disable-gpu", "--disable-gpu-rasterization"],
devtools: false,
headless: true,
});
I run the puppeteer containerized in K8s. The base image that I use is alpine:3.15
How can I fix this issues?
Later edit
I tried this suggested solution. From my initial list of args I removed the mentioned args and I installed all the dependencies. It didn't worked
Later edit
I tried this suggestion. The result was that the error messages are not printed in a loop anymore. Still some of them remained:
15/2/2022-20:02:07 - Server started on port 8877
[0215/201841.761356:ERROR:browser_main_loop.cc(530)] Failed to open an X11 connection.
[0215/201841.763190:ERROR:bus.cc(392)] Failed to connect to the bus: Failed to connect to socket /var/run/dbus/system_bus_socket: No such file or directory
[0215/201841.764900:WARNING:dns_config_service_linux.cc(470)] Failed to read DnsConfig.
[0215/201841.767437:WARNING:vaapi_wrapper.cc(589)] VAAPI video acceleration not available for disabled
DevTools listening on ws://127.0.0.1:9222/devtools/browser/251b429b-6a6d-46d1-b12e-2209c0b28574
start
As behavior I don't see lots of errors in log but still the code seems like is frozen. Further, the chromium process is taking all the cpu:
Later edit
In my previous image it can be seen that the CPU limit for the pod is 800m. Also it can be seen that this limit is reached.
I increased the limit to 1300m CPU. This time it worked to save image. The interesting part is that for each image, the CPU is around 500.
Why when I had the limit set to 800m CPU the chromium process was taking all the CPU and when I have 1300m, for each save as image operation the CPU is around 500m? Is there a minimum CPU requirement for chromium?
My chromium version is: 93.0.4577.82
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|

