13

When trying to run Headless Chrome on both mac and linux, it fails with the following error

Chrome --headless --disable-gpu https://www.yahoo.com
[0505/072239.922334:ERROR:browser_process_sub_thread.cc(217)] Waited 5 ms for network service

I'm testing with version Google Chrome 74.0.3729.131

Anshuul Kai
  • 3,876
  • 2
  • 27
  • 48
  • 1
    yeah i'm having the same issue but if i add a URL like you did i get Segmentation fault

    google-chrome --headless http://www.google.com/

    [0510/173839.408209:ERROR:command_buffer_proxy_impl.cc(125)] ContextResult::kTransientFailure: Failed to send GpuChannelMsg_CreateCommandBuffer. [0510/173839.408083:WARNING:ipc_message_attachment_set.cc(49)] MessageAttachmentSet destroyed with unconsumed attachments: 0/1 [0510/173839.648167:ERROR:command_buffer_proxy_impl.cc(106)] ContextResult::kTransientFailure: Shared memory region is not valid

    Segmentation fault

    – imp May 10 '19 at 13:58
  • i've tried a myriad of things to get this to work myself, have you gotten it to work? – imp May 10 '19 at 13:59
  • Not really an answer. Had same problem, spent days. Some say downgrading chrome helps, but not for me. Ended up using Puppeteer: https://github.com/GoogleChrome/puppeteer – Rimski May 14 '19 at 15:53
  • I get the exact same error as @MistaWizard using cef 79.1.26 chromium embedded framework on ubuntu 19.04; it loads a webpage but none of the callbacks are called; I had this working 3 years ago on ubuntu 16.04 with the cef from then, but now that setup doesn't compile unless I create symlinks, such as /usr/include/gtk pointing to /usr/include/gtk-2.0/gtk and edit system includes; and once it compiled on 19.04, then it gets the above error – jmarina Jan 15 '20 at 16:05

1 Answers1

7

Try adding some of the following options:

chromeOptions.addArguments("--headless")
chromeOptions.addArguments("--no-sandbox")
chromeOptions.addArguments("--disable-dev-shm-usage")
chromeOptions.addArguments("--disable-gpu")
chromeOptions.addArguments("--disable-features=NetworkService") ##this did it for me
chromeOptions.addArguments("--window-size=1920x1080")
chromeOptions.addArguments("--disable-features=VizDisplayCompositor")
imp
  • 435
  • 6
  • 20
  • Specifically, `--disable-gpu` did it for me, but others might be helpful as well – KyleMit Dec 01 '20 at 13:43
  • 2
    The largest list of (hopefully updated) arguments I can find is here: https://peter.sh/experiments/chromium-command-line-switches/ Its exhaustive :) – imp Dec 03 '20 at 02:01