Chromium: `await context.newPage()` hangs forever, addressed with `--disable-gpu` arg
See original GitHub issueContext:
- Playwright Version: 1.7.0
- Operating System: Linux, Debian
- Node.js version: 14
- Browser: Chromium
- Extra: [any specific details about your environment]
Code Snippet
Using this code:
import { chromium } from "playwright";
const browser = await chromium.launch();
const context = await browser.newContext({ ignoreHTTPSErrors: true });
const page = await context.newPage();
Describe the bug
Using DEBUG=pw:browser
.
Broken case:
2020-12-18T11:52:23.757Z info: chromium.launch()
pw:browser <launching> /test/node_modules/playwright/.local-browsers/chromium-833159/chrome-linux/chrome --disable-background-networking --enable-features=NetworkService,NetworkServiceInProcess --disable-background-timer-throttling --disable-backgrounding-occluded-windows --disable-breakpad --disable-client-side-phishing-detection --disable-component-extensions-with-background-pages --disable-default-apps --disable-dev-shm-usage --disable-extensions --disable-features=TranslateUI,BlinkGenPropertyTrees,ImprovedCookieControls,SameSiteByDefaultCookies,LazyFrameLoading --disable-hang-monitor --disable-ipc-flooding-protection --disable-popup-blocking --disable-prompt-on-repost --disable-renderer-backgrounding --disable-sync --force-color-profile=srgb --metrics-recording-only --no-first-run --enable-automation --password-store=basic --use-mock-keychain --user-data-dir=/tmp/playwright_chromiumdev_profile-YnnTiK --remote-debugging-pipe --headless --hide-scrollbars --mute-audio --blink-settings=primaryHoverType=2,availableHoverTypes=2,primaryPointerType=4,availablePointerTypes=4 --no-sandbox --disable-dev-shm-usage --no-startup-window +0ms
pw:browser <launched> pid=106 +13ms
pw:browser [err] [1218/115224.064088:ERROR:bus.cc(393)] Failed to connect to the bus: Failed to connect to socket /var/run/dbus/system_bus_socket: No such file or directory +101ms
2020-12-18T11:52:24.068Z info: suite setup done
2020-12-18T11:52:24.069Z info: browser.newContext()
2020-12-18T11:52:24.073Z info: context.newPage()
pw:browser [err] [1218/115224.069551:FATAL:xlib_support.cc(44)] Check failed: xlib_xcb_loader->Load("libX11-xcb.so.1"). +250ms
pw:browser [err] #0 0x55e96b0f0919 base::debug::CollectStackTrace() +0ms
...
pw:browser [err] Received signal 6 +1ms
pw:browser [err] #0 0x55e96b0f0919 base::debug::CollectStackTrace() +7ms
pw:browser [err] #1 0x55e96b0616d3 base::debug::StackTrace::StackTrace() +7ms
pw:browser [err] #2 0x55e96b0f04fb base::debug::(anonymous namespace)::StackDumpSignalHandler() +8ms
pw:browser [err] #3 0x7febb87ac730 (/lib/x86_64-linux-gnu/libpthread-2.28.so+0x1272f) +0ms
pw:browser [err] #4 0x7febb690e7bb gsignal +0ms
pw:browser [err] #5 0x7febb68f9535 abort +0ms
pw:browser [err] #6 0x55e96b0ef495 base::debug::BreakDebugger() +8ms
pw:browser [err] #7 0x55e96b072d6d logging::LogMessage::~LogMessage() +8ms
pw:browser [err] #8 0x55e96b07344e logging::LogMessage::~LogMessage() +8ms
pw:browser [err] #9 0x55e96be35c9f x11::InitXlib() +10ms
pw:browser [err] #10 0x55e96be35e59 x11::XlibDisplay::XlibDisplay() +10ms
pw:browser [err] #11 0x55e96be0fae0 x11::Connection::GetXlibDisplay() +11ms
pw:browser [err] #12 0x55e96c2b94f7 gl::init::InitializeGLOneOffPlatformX11() +11ms
pw:browser [err] #13 0x55e96c2b74cb gl::init::InitializeGLOneOffPlatformImplementation() +11ms
pw:browser [err] #14 0x55e96c2b7172 gl::init::(anonymous namespace)::InitializeGLOneOffPlatformHelper() +12ms
pw:browser [err] #15 0x55e96c2b72dc gl::init::InitializeGLNoExtensionsOneOff() +11ms
pw:browser [err] #16 0x55e96cccba78 gpu::GpuInit::InitializeAndStartSandbox() +13ms
pw:browser [err] #17 0x55e96f920a23 content::GpuMain() +22ms
pw:browser [err] #18 0x55e96afffed9 content::RunZygote() +8ms
pw:browser [err] #19 0x55e96b001144 content::ContentMainRunnerImpl::Run() +9ms
pw:browser [err] #20 0x55e96affe7a4 content::RunContentProcess() +7ms
pw:browser [err] #21 0x55e96afff12c content::ContentMain() +8ms
pw:browser [err] #22 0x55e96b05b612 headless::(anonymous namespace)::RunContentMain() +8ms
pw:browser [err] #23 0x55e96b05b4bb headless::RunChildProcessIfNeeded() +9ms
pw:browser [err] #24 0x55e96b059c25 headless::HeadlessShellMain() +8ms
pw:browser [err] #25 0x55e968575f05 ChromeMain +25ms
pw:browser [err] #26 0x7febb68fb09b __libc_start_main +1ms
pw:browser [err] #27 0x55e968575d2a _start +27ms
pw:browser [err] r8: 0000000000000000 r9: 00007ffc1e841d30 r10: 0000000000000008 r11: 0000000000000246 +0ms
pw:browser [err] r12: 000034c044404c98 r13: 000034c044404c90 r14: 000034c044404c80 r15: 00007ffc1e842800 +0ms
pw:browser [err] di: 0000000000000002 si: 00007ffc1e841d30 bp: 00007ffc1e841f80 bx: 0000000000000006 +0ms
pw:browser [err] dx: 0000000000000000 ax: 0000000000000000 cx: 00007febb690e7bb sp: 00007ffc1e841d30 +0ms
pw:browser [err] ip: 00007febb690e7bb efl: 0000000000000246 cgf: 002b000000000033 erf: 0000000000000000 +1ms
pw:browser [err] trp: 0000000000000000 msk: 0000000000000000 cr2: 0000000000000000 +0ms
pw:browser [err] [end of stack trace] +0ms
pw:browser [err] Calling _exit(1). Core file will not be generated. +0ms
pw:browser [err] [1218/115227.265663:WARNING:gpu_process_host.cc(1275)] The GPU process has crashed 6 time(s) +1ms
pw:browser [err] [1218/115227.271729:WARNING:gpu_process_host.cc(999)] Reinitialized the GPU process after a crash. The reported initialization time was 0 ms +
Note the The GPU process has crashed 6 time(s)
The NodeJS process hangs infinitely in the last line shown in the code snippet above, in const page = await context.newPage();
.
No further log output produced by playwright.
That is, await context.newPage()
does not resolve, as was for example reported here (without root-causing this): https://github.com/microsoft/playwright/issues/3939
I then changed the browser instantiation to use the --disable-gpu
arg:
browser = await chromium.launch({
args: ["--disable-gpu"]
});
resulting in
2020-12-18T11:51:26.862Z info: chromium.launch()
pw:browser <launching> /test/node_modules/playwright/.local-browsers/chromium-833159/chrome-linux/chrome --disable-background-networking --enable-features=NetworkService,NetworkServiceInProcess --disable-background-timer-throttling --disable-backgrounding-occluded-windows --disable-breakpad --disable-client-side-phishing-detection --disable-component-extensions-with-background-pages --disable-default-apps --disable-dev-shm-usage --disable-extensions --disable-features=TranslateUI,BlinkGenPropertyTrees,ImprovedCookieControls,SameSiteByDefaultCookies,LazyFrameLoading --disable-hang-monitor --disable-ipc-flooding-protection --disable-popup-blocking --disable-prompt-on-repost --disable-renderer-backgrounding --disable-sync --force-color-profile=srgb --metrics-recording-only --no-first-run --enable-automation --password-store=basic --use-mock-keychain --user-data-dir=/tmp/playwright_chromiumdev_profile-lKflzS --remote-debugging-pipe --headless --hide-scrollbars --mute-audio --blink-settings=primaryHoverType=2,availableHoverTypes=2,primaryPointerType=4,availablePointerTypes=4 --no-sandbox --disable-dev-shm-usage --disable-gpu --no-startup-window +0ms
pw:browser <launched> pid=107 +13ms
pw:browser [err] [1218/115127.182152:ERROR:bus.cc(393)] Failed to connect to the bus: Failed to connect to socket /var/run/dbus/system_bus_socket: No such file or directory +107ms
2020-12-18T11:51:27.186Z info: suite setup done
2020-12-18T11:51:27.188Z info: browser.newContext()
2020-12-18T11:51:27.195Z info: context.newPage()
Here, the await context.newPage()
resolved quickly and the test runner could move on. The browser output shows
pw:browser [err] Calling _exit(1). Core file will not be generated. +0ms
pw:browser [err] [1218/115128.810815:WARNING:gpu_process_host.cc(1275)] The GPU process has crashed 3 time(s) +1ms
pw:browser [err] [1218/115128.816207:WARNING:gpu_process_host.cc(999)] Reinitialized the GPU process after a crash. The reported initialization time was 0 ms
That is, even with --disable-gpu
The GPU process has crashed 3 time(s). But that wasn’t deadly.
Discussion / conclusions
await context.newPage()
can hang indefinitely, and should get some error handling love. It should error out instead of hanging indefinitely. Maybe there should be a timeout; and when that hits in the browser log should be emitted – usingDEBUG=pw:browser
should not be necessary to get further information.- Should
--disable-gpu
be the default in headless mode? To me it seems like https://github.com/microsoft/playwright/issues/2698 needs more discussion maybe.
Issue Analytics
- State:
- Created 3 years ago
- Comments:8 (3 by maintainers)
Top Results From Across the Web
1198567 - Headless browser freezes on Windows unless ...
const browser = await puppeteer.launch({ ... This script will freeze at the `browser.newPage()` step after r870496 when not using `--disable-gpu`.
Read more >Puppeteer Hangs In Headless Mode - Stack Overflow
createIncognitoBrowserContext(); const page = await context.newPage(); // Create new instance of puppet page.on('error', err => ...
Read more >Changelog - Cypress Documentation
This command caches and restores cookies , localStorage , and sessionStorage in order to recreate a consistent browser context between tests. Addresses #20977....
Read more >How to Enable and Disable GPU Acceleration in Google ...
Article guide on the different methods to enable and disable the GPU acceleration through Google Chrome settings, Windows registry editor, and Chrome flags ......
Read more >mozilla-release: changeset 564654 ... - Mercurial
remote/test/puppeteer/test/golden-chromium/screenshot-offscreen-clip.png ... 6']; puppeteer.launch().then(async browser => { const page = await browser.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Ran into the same problem on a Ubuntu 20.04 server, while another Ubuntu 20.04 server didn’t have this issue. Saw this log as wel
pw:browser [err] [1218/115224.069551:FATAL:xlib_support.cc(44)] Check failed: xlib_xcb_loader->Load("libX11-xcb.so.1"). +250ms
Not being a Linux professional, I installedlibx11-xcb1
and it seems to have fixed the problem.Lol, sorry, I’m in the wrong place! 😄 I’m only using Puppeteer, but of course this helped immensely 😃