News for hackers. Stuff that matters.
Re:Chrome 59 has cross-platform headless support by bluepnume on Wednesday April 12, 2017 @06:33PM (#14102356)
This is fantastic. I'm using a combination of Chrome and PhantomJS for karma testing right now, for https://github.com/paypal/paypal-checkout and https://github.com/krakenjs/xcomponent. There are hundreds of tests opening up hundreds of iframes and popup windows, and sending a lot of cross-window messages, and that ends up being really memory hungry.

Chrome deals pretty well with garbage collection, so long as I'm careful to de-reference closed windows properly¹, and only uses a maximum of 150mbs. PhantomJS eats up almost 6GB of memory before it's done, which makes it almost unusable on machines with less memory or CI boxes. Travis is a no-go.

I'm hoping running Chrome in headless mode should give a nice speedup for our tests.

-----

¹ Turns out even a closed popup window or iframe keeps a huge amount of memory hanging around. Who knew.

Re:Chrome 59 has cross-platform headless support by paulirish on Wednesday April 12, 2017 @09:48PM (#14103443)
We (Chrome) have reached out to PhantomJS to inquire if they're interested in collaborating: https://groups.google.com/d/msg/phantomjs-dev/S-mEBwuSgKQ/tU...

The DevTools Protocol is the primary API for headless Chrome, but we are excited for higher-level abstractions like PhantomJS & NightmareJS's API to manipulate the browser as well. Plenty of details to work out, but hopefully sometime this year you'll get a drop-in solution for some of your testing to upgrade from Phantom's older QTWebKit to the latest Chromium.

Re:Chrome 59 has cross-platform headless support by flanbiscuit on Wednesday April 12, 2017 @09:56PM (#14103486)
Thank you for being willing to work with them and not just rolling your own version of Phantomjs. I hope they respond positively to your inquiry
Re:Chrome 59 has cross-platform headless support by 2T1Qka0rEiPr on Thursday April 13, 2017 @06:23AM (#14105624)
Re:Chrome 59 has cross-platform headless support by yamaneko on Thursday April 13, 2017 @07:38AM (#14105942)
After his announcement, Vitaly answered to the team: https://groups.google.com/d/msg/phantomjs-dev/S-mEBwuSgKQ/PQ...

> >Is there interest on your side in adopting Chromium as a runtime? There's some existing documentation [2] around the API and embedding, but admittedly, this would be some work.

> We are interested. But I am afraid not in the current state. Currently, PhantomJS heavily relies on Qt and QtWebKit. It's not that easy to adopt Chrome as a new runtime.

> But I think we could implement PhantomJS as a completely new (with the same API) project that will use Chrome - Phantomium!

Re:Chrome 59 has cross-platform headless support by Naracion on Thursday April 13, 2017 @02:26PM (#14109627)
Re:Chrome 59 has cross-platform headless support by shouldbworking on Wednesday April 12, 2017 @11:31PM (#14103931)
It was my understanding that Google's crawler literally is Chrome. Does Google have any plans to open source those parts of the browser to make integration easier? Maybe I was mistaken
Re:Chrome 59 has cross-platform headless support by tracker1 on Thursday April 13, 2017 @01:53PM (#14109320)
That seems unlikely... It would seem they have two sets of crawlers... one that does typical/advanced scraping, and another that runs the JS (Chromium) and takes DOM snapshots. This is reflected by changing certain properties (window title etc) and seeing them reflected in Google's search results. A couple years ago, the lag was several days to a week behind on new content via as-rendered from the server vs. via JS.
Re:Chrome 59 has cross-platform headless support by shouldbworking on Friday April 14, 2017 @04:23PM (#14116987)
Interesting! I find it puzzling that insider knowledge on how google search works never seems to leak into the public domain. Is google killing leaks in their search algorithms or do they pay the search team such ungodly amounts of cash that nobody has ever left?
Re:Chrome 59 has cross-platform headless support by tracker1 on Sunday April 16, 2017 @03:42PM (#14127145)
Well, the point of their engine is to make it harder to game the system... everytime someone figures out a trick, someone takes advantage of it... that alone would discourage leaks.

We laypeople can only find out things via word of mouth or observational tests on assumptions.

Re:Chrome 59 has cross-platform headless support by masklinn on Thursday April 13, 2017 @06:10AM (#14105563)
> The DevTools Protocol is the primary API for headless Chrome

Why not the WebDriver protocol? That seems to be exactly what it's intended for…

Re:Chrome 59 has cross-platform headless support by KayL on Thursday April 13, 2017 @06:45AM (#14105707)
WebDriver protocol has limited APIs. For example, no networking status. (WebDriver rejected to implement it, they told you to use Proxy for debugging)
Re:Chrome 59 has cross-platform headless support by LoSboccacc on Thursday April 13, 2017 @02:23AM (#14104591)
We're using xvfb and selenium* for testing and a proper headless support would be a hundred time more stable than the self restarting framebuffer can't wait to move to headless chrome

*Yeah I know phantomjs is more cool these days but phantom doesn't support windows height so there's that.

Re:Chrome 59 has cross-platform headless support by akras14 on Thursday April 13, 2017 @04:19AM (#14105126)
+1 for xvfb
Re:Chrome 59 has cross-platform headless support by PatrickAuld on Wednesday April 12, 2017 @07:53PM (#14102846)
We also did a POC with PhantomJS and found similar issues, as well as generally flakiness causing too many false negatives. Ended up not using it; I'm hoping this can simplify things are give something more solid to build on.
Re:Chrome 59 has cross-platform headless support by seanp2k2 on Wednesday April 12, 2017 @10:12PM (#14103577)
Same, ended up using ChromeDriver + XVFB on Jenkins. Works but it's still pretty slow.
Re:Chrome 59 has cross-platform headless support by akras14 on Thursday April 13, 2017 @04:18AM (#14105115)
I replied to you on Twitter, but for the sake of discussion, there is a third option that may be worth exploring - using Chrome running in virtualized Windows Manager - https://www.alexkras.com/running-chrome-and-other-browsers-i...
Re:Chrome 59 has cross-platform headless support by amclennon on Friday April 14, 2017 @03:17PM (#14116481)
Hello, former SDC coworker!

The official Selenium Docker image uses the same technique to run headless Chrome / Firefox.

From there you can just run

  docker run -d -P selenium/standalone-chrome
and you'll get something a lot more lightweight than spinning up a new Vagrant VM.
Re:Chrome 59 has cross-platform headless support by bluepnume on Thursday April 13, 2017 @02:02PM (#14109406)
Very cool. Gonna have to check this out.
Re:Chrome 59 has cross-platform headless support by Rumudiez on Wednesday April 12, 2017 @07:35PM (#14102736)
What do you do to ensure the resources for closed windows are released?
Re:Chrome 59 has cross-platform headless support by bluepnume on Wednesday April 12, 2017 @10:59PM (#14103789)
A combination of:

- Making sure all promises are fulfilled or rejected, so window objects don't get caught indefinitely in closure scope for any .then() or .catch() handler functions.

- Using WeakMaps as much as possible, when we have things that are tied to a particular window, like message listeners or response handlers in post-robot

- Manually clearing up any global references to windows when we destroy an xcomponent instance

Finding the references was the tricky bit. A lot of the effort was finding a leaky test-case, running in 100 times in succession, and deleting code until the memory graph was flat -- then figuring out what I'd just deleted that caused the leak.

The problem started manifesting as I added more and more tests -- so now I'm actually checking my tests' memory usage on the fly and failing if they cross a threshold. Hopefully that should avoid getting into this kind of sticky situation ever again.

https://github.com/paypal/paypal-checkout/blob/master/test/t...

Re:Chrome 59 has cross-platform headless support by sbuccini on Wednesday April 12, 2017 @07:18PM (#14102631)
I've been using post-robot and xcomponent a lot recently as I'm solving a bunch of similar challenges. Just wanted to say thank you for sharing your solutions and expertise.
Re:Chrome 59 has cross-platform headless support by bluepnume on Wednesday April 12, 2017 @11:04PM (#14103812)
Glad they're working out for you! Let me know if you encounter any interesting situations they don't support.
Re:Chrome 59 has cross-platform headless support by jslove on Thursday April 13, 2017 @06:20AM (#14105608)
But can you run headless chrome on Chromeos? if not why not?
Re:Chrome 59 has cross-platform headless support by nreece on Wednesday April 12, 2017 @09:59PM (#14103503)
I've been testing Chrome headless extensively for the past few months, and while it's a good step, but it's not stable for high-volume or even diverse set of webpages.

Memory usage is pretty high, lot of heavy webpages result in crashes/hangs, there are many inconsistencies between features available in full version and headless, their debugging protocol has different APIs that work on headless/non-headless in Linux or Windows, and so on.

Of the bugs I've submitted, some have been fixed in the upcoming M59, so other critical ones may take longer due to their backlog. I suppose for now (maybe until M61-62), Chrome full with xvfb or even PhantomJS are better options. When you realize that Chrome is about the same size (by LoC) as the Linux kernel [1], you can't help but wish for a leaner & faster headless browser.

There seems to be some work going on building Firefox pure headless as well. Great overall, as long as all the browsers try to follow the RemoteDebug initiative [2].

[1] https://josephg.com/blog/electron-is-flash-for-the-desktop/

[2] http://remotedebug.org

Re:Chrome 59 has cross-platform headless support by jotto on Thursday April 13, 2017 @01:24AM (#14104359)
I've been successfully using Chrome headless in a 500MB Docker container for dumping the DOM for https://www.prerender.cloud/ for months (rendering a large variety of sites without restarts for weeks at a time)

Run it with:

  --js-flags="--max_old_space_size=500"
to force the VM to keep it GC'd below 500

Chrome v55 was a 30% memory savings, before that I used 1GB containers.

It's not perfect, but I am definitely pushing high volume (multiple tabs, concurrent activity) and I am not having any significant stability issues and I am pushing diverse sets of webpages.

Re:Chrome 59 has cross-platform headless support by vvoyer on Thursday April 13, 2017 @03:23AM (#14104852)
What the best strategy that worked for you on high volumes, multiple tabs or multiple docker instances? I am wondering if multiple tabs is as efficient as multiple windows/instances.

Thanks.

Re:Chrome 59 has cross-platform headless support by heipei on Thursday April 13, 2017 @03:50AM (#14104979)
I'm using more than one Chrome process so I can kill the processes every so often (e.g. after timeout or when they get stuck). Inside each Chrome instance I use 16 tabs, there might be a number of factors at play:

- Are you worried about same-origin pollution if you run multiple tabs from the same origin in the same process? If so -> Extra process - Do you have to take screenshots? You can only take screenshots of the tab that's in the foreground, so you have to activate it first to take the screenshot. This might fail if you have lots of tabs which roughly trigger at once.

You can see what I've built at https://urlscan.io btw.

Re:Chrome 59 has cross-platform headless support by 19eightyfour on Thursday April 13, 2017 @04:33AM (#14105182)
That ought actually be:

  --js-flags="--max-old-space-size=500"
Hyphens not underscores.

A list of V8 flags can be found with:

  --js-flags="--help"
Re:Chrome 59 has cross-platform headless support by brazzledazzle on Thursday April 13, 2017 @05:53AM (#14105493)
I think it may accept both the underscore and hyphen and just normalizes it.
Re:Chrome 59 has cross-platform headless support by 19eightyfour on Thursday April 13, 2017 @10:57AM (#14107471)
This is correct, it does accept both, and the help lists it as underscores not hyphens. So the comment about it ought to be hyphens not underscores is incorrect. Either is fine.
Re:Chrome 59 has cross-platform headless support by brazzledazzle on Friday April 14, 2017 @01:37AM (#14112881)
When I went digging through the code for v8 I believe I saw examples of it both ways. I'm not dead sure though because I don't know very much C. I just checked because I was hoping they weren't actually using an invalid flag for all that time.
Re:Chrome 59 has cross-platform headless support by pacuna on Thursday April 13, 2017 @09:20AM (#14106586)
what Docker image are you using?
Re:Chrome 59 has cross-platform headless support by chrissnell on Wednesday April 12, 2017 @10:36PM (#14103685)
Yes, this exactly. I wrote Crabby [1] a few months back to schedule automated page testing using Chrome and webdriver but doing anything automated with Chrome is really atrocious. You can't expect to load more than one page every 10-15 seconds on the average 8GB instance and it occasionally crashes or otherwise stops working completely.

I ended up writing a simple check using Go's net/http library to do basic performance profiling but it doesn't measure DOM loading like the Chrome checks do. Such a bummer

What I really want is an easy, cross-platform way to collect the network timings for each object like you get in Chrome's dev tools network waterfall graphs.

[1] https://github.com/chrissnell/crabby

Re:Chrome 59 has cross-platform headless support by heipei on Thursday April 13, 2017 @03:46AM (#14104960)
Thanks for that information. I've been putting off moving over to Chrome headless for https://urlscan.io and haven't had the time to do extensive testing yet. Right now Xvfb works fine for me. Still, I'm running 3 Chrome instances with 16 tabs each in parallel and have to kill the processes every so often because they get "stuck".
Re:Chrome 59 has cross-platform headless support by fastest963 on Wednesday April 12, 2017 @10:04PM (#14103528)
Unfortunately, I have to agree, though they have been very helpful and vigilant on the bugs that have been filed. Most of mine have been fixed in a few days.
Re:Chrome 59 has cross-platform headless support by nreece on Wednesday April 12, 2017 @10:11PM (#14103568)
Hey James, I did come across some of your bug submissions, and our joint discussions on the headless-dev Google Group.
Re:Chrome 59 has cross-platform headless support by callumprentice on Wednesday April 12, 2017 @07:38PM (#14102759)
https://bitbucket.org/lindenlab/dullahan

I've been working on a fully open source Windows/macOS library (via Chromium Embedded Framework) that allows you to render pages to memory (and then of course to bitmaps, textures etc.) as well as inject synthesized mouse/keyboard/JavaScript events. It currently uses (what amounts to) Chrome 57.

Looks like this might make my project obsolete.

Re:Chrome 59 has cross-platform headless support by keville on Wednesday April 12, 2017 @09:50PM (#14103452)
Thank you anyway for your efforts; I hope you interpret this as a validation of your having correctly identified a sorely-needed tool.
Re:Chrome 59 has cross-platform headless support by callumprentice on Wednesday April 12, 2017 @09:54PM (#14103472)
Thanks keville - I've poured my heart into this on nights and weekends after I'm done with my day job for a long time now but what you say is so true - hopefully we'll get access to a more robust solution compared to my modest hacks.
Re:Chrome 59 has cross-platform headless support by MichaelApproved on Wednesday April 12, 2017 @08:02PM (#14102880)
A lot of phantom js talk here makes me want to recommend http://ghostinspector.com

It's a phantom js (and other headless browser) web service. Using the site, you can quickly create different tests, scheduled tests, chained tests, keep screen shots, create videos of multi step tests, and have historical information of it all.

Can't say enough good things about the site.

Edit: also there's a great chrome extension that will record your mouse clicks and keyboard commands to make creating a test that much simpler.

Re:Chrome 59 has cross-platform headless support by guiambros on Wednesday April 12, 2017 @10:32PM (#14103669)
+1 to GhostInspector; I used them at a previous company a few years ago, and it was very useful.

They were just starting, but service was rather reliable, and their tech support was excellent (maybe because we were early customers). We used to run a bunch of automated tests for monitoring and compliance, archiving hourly screenshots over different builds for later comparison.

Re:Chrome 59 has cross-platform headless support by rgrieselhuber on Wednesday April 12, 2017 @09:24PM (#14103327)
I'm the co-founder of a startup that provides an enterprise solution in this space (https://functionize.com).

I agree with your sentiment regarding these types of tools. It has been a long time coming but this release and the tools available now are things I wish I had years ago when I was building my first company.

Re:Chrome 59 has cross-platform headless support by vvoyer on Wednesday April 12, 2017 @06:37PM (#14102371)
Also checkout https://github.com/cyrus-and/chrome-remote-interface for an easy way to fully control those headless instances
Re:Chrome 59 has cross-platform headless support by kenshaw on Wednesday April 12, 2017 @07:18PM (#14102634)
If you're using Go, https://github.com/knq/chromedp

It's also worth noting that the 57+ series has a nice embedded viewer you can use to view the actual viewport via devtools.

Re:Chrome 59 has cross-platform headless support by chrissnell on Wednesday April 12, 2017 @10:42PM (#14103711)
WOW. That's fantastic. As I noted in a comment above, I wrote a tool called crabby that uses Selenium and Chrome headless to do automated page testing and to report results back to metrics engines like Graphite, Datadog, Prometheus, and Riemann. The biggest problem I have is the unreliability of chromedriver and the extreme resource consumption of Chrome + Selenium. It's really too much for your average public cloud instance if you want to test any more than, say, one or two pages a minute.

Do you know if chromedp can access any of the timing measurements?

Re:Chrome 59 has cross-platform headless support by kenshaw on Thursday April 13, 2017 @04:44AM (#14105237)
Yes, you can access everything via the underlying APIs. chromedp is a relatively new project (only about 4 months old), so there isn't much yet in the way of high level timing / profiling, but we hope to add that to the code base when we have some bandwidth to do so.
Re:Chrome 59 has cross-platform headless support by nojvek on Wednesday April 12, 2017 @10:16PM (#14103597)
If you want great code completion for chrome's large devtools api with lots of different kinds of object then https://www.npmjs.com/package/chrome-remote-debug-protocol

It dynamically generates Typescript definitions for intelligence and type checking from their protocol.json files.

Vscode chrome debugger uses a fork of it.

I'm the author. /shamelessplug

Re:Chrome 59 has cross-platform headless support by vvoyer on Thursday April 13, 2017 @03:56AM (#14105013)
Can you detail what is the embedded viewer and how/when you access it? Thanks.
Re:Chrome 59 has cross-platform headless support by kenshaw on Thursday April 13, 2017 @04:43AM (#14105231)
With either Chrome in headless mode, or "headless_shell" (a minimal Chrome app part of the Chromium source tree), you first enable the remote debugging port (via --remote-debugging-port=9222), and then you can then simply browse to http://localhost:9222/. That web page will list the various Chrome "pages" (ie, tabs) which you can then click on. Clicking on those tabs will open the Chrome DevTools inside of Chrome, as a web app served from http://localhost:9222/.

This is the internal API that DevTools uses, and is what is referred to as the "Chrome Debugging Protocol" (ie, chromedp). Since 57+, the built in DevTools UI displays whatever the active viewport Chrome "sees" using the screencast APIs. It's just a PNG that's updated every couple hundred milliseconds with the output of Chrome's headless renderer.

Re:Chrome 59 has cross-platform headless support by vvoyer on Thursday April 13, 2017 @05:22AM (#14105384)
Thanks, also did not quite understood what exactly was headless_shell: how to run it, pro/cons, when to use it versus chrome headless.
Re:Chrome 59 has cross-platform headless support by swah on Friday April 14, 2017 @07:59AM (#14113930)
The documentation seems to be the source at this moment: https://chromium.googlesource.com/chromium/src/+/lkgr/headle...

Its a binary that I suppose runs the Chrome in headless mode, supports some command line options like --screenshot to take screenshots, etc.

I'm having a hard time understanding why its hanging on some runs, and how --timeout and --virtual-time-budget could help me with this.

Re:Chrome 59 has cross-platform headless support by oceanswave on Thursday April 13, 2017 @07:15AM (#14105839)
If you're using c#/dotnetcore https://github.com/BaristaLabs/chrome-dev-tools

Will generate a project file you can use in your own solution. Generated protocol is customizable via mustache templates too

Re:Chrome 59 has cross-platform headless support by skibz on Wednesday April 12, 2017 @06:53PM (#14102497)
The feature I was most interested in when they announced this last year was virtual time. The Developer Resources link has it listed (https://chromium.googlesource.com/chromium/src/+/lkgr/headle...) but it's a broken link, unfortunately.

Mostly, I'd like to know how the control of the virtual time system would be exposed. Would it be through the C++ API, or could it be made available through the debugging protocol?

Re:Chrome 59 has cross-platform headless support by ctphipps on Wednesday April 12, 2017 @06:27PM (#14102326)
Any way of scripting this to automate button clicks etc? I use PhantomJS for this now but found it to be incredibly unstable for complex pages.
Re:Chrome 59 has cross-platform headless support by vvoyer on Wednesday April 12, 2017 @06:33PM (#14102359)
Yes: https://github.com/cyrus-and/chrome-remote-interface/wiki/Tr...

But ultimately selenium and webdriver.io will do a better job at this

Re:Chrome 59 has cross-platform headless support by kenshaw on Wednesday April 12, 2017 @07:22PM (#14102658)
If you're using Go, you might want to check out https://github.com/knq/chromedp ... There is also a similar package for NodeJS. Otherwise, you can use Selenium in other languages.
Re:Chrome 59 has cross-platform headless support by sandstrom on Wednesday April 12, 2017 @07:06PM (#14102577)
There is an excellent library called nightmare (based on electron). If you need print-screens you can use xvfb

or wait for this issue: https://github.com/segmentio/nightmare/issues/224

Re:Chrome 59 has cross-platform headless support by symtos on Wednesday April 12, 2017 @07:57PM (#14102865)
it should be noted that nightmare isn't safe for untrusted websites: https://github.com/segmentio/nightmare/issues/1060
Re:Chrome 59 has cross-platform headless support by RandomBookmarks on Thursday April 13, 2017 @02:33AM (#14104631)
For complex pages, there is Kantu, which is based on Chromium: https://www.a9t9.com/kantu/web-automation

Not headless, but ideally suited for automating complex websites (date controls, etc).

Re:Chrome 59 has cross-platform headless support by bcherny on Wednesday April 12, 2017 @06:32PM (#14102349)
You can use ChromeDriver, the same as you would for headed Chrome.
Re:Chrome 59 has cross-platform headless support by fake-name on Wednesday April 12, 2017 @09:03PM (#14103206)
Shamelessly bumping my project to produce a nice python API for the Chromium/Chrome-remote-debugger-protocol: https://github.com/fake-name/ChromeController

I'm trying to replace PhantomJS in my infrastructure with chromium. Not having to build my own chromium will be a very nice thing.

Re:Chrome 59 has cross-platform headless support by vmasto on Wednesday April 12, 2017 @07:52PM (#14102841)
I've been trying to test audio and video with headless browsers (namely PhantomJS) but have experienced extreme difficulty, I wonder if headless Chrome is able to support/supports already HTMLAudioElement or HTMLVideoElement or any media interface that would make, for example, testing YouTube or SoundCloud embeds easier.
Re:Chrome 59 has cross-platform headless support by swah on Thursday April 13, 2017 @06:39AM (#14105687)
Related: I want to take screenshots of a few news websites for a little fake news project of mine, and most approaches return something completely different than what I'm seeing when I open Chrome.

Limited height would be better/ok (something like the first 3000 pixels).

Low volume / can be slow (30 seconds would be ok).

Those news websites many times have infinite scrolling.

I've tried:

- phantomJS (rendering sucked, tried every technique I could find to wait for JS to load)

- wkhtmltopdf (almost ok, generates a huge 30M image with all the height, no antialiasing it seems)

- https://github.com/gen2brain/url2img (this was the best so far, uses Qt bindings but not the latest version)

- actually run a headless browser in DigitalOcean with xvfb-run and take a screenshot: I failed at this

What I didn't tried was Selenium, because it seemed even harder.

How would you guys do it?

Re:Chrome 59 has cross-platform headless support by oceanswave on Thursday April 13, 2017 @07:06AM (#14105802)
Create a chrome extension for yourself that automates the process
Re:Chrome 59 has cross-platform headless support by stangls on Thursday April 13, 2017 @07:09AM (#14105814)
I use xvfb for selenium testing. It is really easy to set up and can take screenshots or videos while automatically browsing websites.
Re:Chrome 59 has cross-platform headless support by swah on Thursday April 13, 2017 @08:36AM (#14106247)
Thanks - I tried Selenium (on the desktop) with geckodriver now and it rendered well. The only thing is that long screenshots didn't work but there is probably a workaround for that.
Re:Chrome 59 has cross-platform headless support by yarp on Wednesday April 12, 2017 @06:46PM (#14102445)
Any chance for webgl here? Would be nice for automatic screenshots and webgl tests.
Re:Chrome 59 has cross-platform headless support by jevinskie on Wednesday April 12, 2017 @07:05PM (#14102569)
Re:Chrome 59 has cross-platform headless support by colordrops on Wednesday April 12, 2017 @07:44PM (#14102792)
WebGL is supposedly a first class citizen of the browser and is used in a ton of pages, but it gets left out or deferred in many tooling packages. There are many tools that are nearly useless to us because they don't support WebGL. It's disappointing.
Re:Chrome 59 has cross-platform headless support by Bahamut on Wednesday April 12, 2017 @08:15PM (#14102929)
Oh my goodness I have been waiting for this day for a while - we ran into PhantomJS problems with keyboard/mouse eventing and the HTMLVideoElement for testing, this sounds like it should be the cure for our woes of having to hack around PhantomJS's deficiencies.
Re:Chrome 59 has cross-platform headless support by iAm25626 on Wednesday April 12, 2017 @07:00PM (#14102548)
Nice!! Would creating WebRTC data channel be possible?

server side SCTP to client(p2p over SCTP/data channel) would be cool.

Re:Chrome 59 has cross-platform headless support by stcredzero on Wednesday April 12, 2017 @09:05PM (#14103221)
It's already possible. I'm using webrtc and node-electron to connect a golang server for my MMO project. I have a farm of 4 nodejs processes running under tmux acting as proxies for unreliable communications.

https://www.emergencevector.com

Re:Chrome 59 has cross-platform headless support by unmole on Thursday April 13, 2017 @12:30AM (#14104175)
Which WebRTC library are you using on the golang server? Last time I looked, I couldn't find anything stable.
Re:Chrome 59 has cross-platform headless support by stcredzero on Friday April 14, 2017 @06:21PM (#14117885)
I am using electron-webrtc. You need xvfb installed. I was able to get this running under node, but only running the processes under tmux. You will also need to install some random shared libraries Chromium needs, but which node-electron doesn't install, but these are obvious from error messages.

Then I'm using simple-peer on top of that. There's also a library for UDP communications from the node process to the golang process.

Re:Chrome 59 has cross-platform headless support by arrowgunz on Wednesday April 12, 2017 @06:48PM (#14102464)
What does this mean for Electron and other apps that depend on Electron?
Re:Chrome 59 has cross-platform headless support by JepZ on Wednesday April 12, 2017 @08:27PM (#14102999)
I am looking forward to cli tools powered by electron. Imagine the beauty of a grep writting in js, executed by a chrome binary. :D
Re:Chrome 59 has cross-platform headless support by ryeguy on Thursday April 13, 2017 @03:29PM (#14110186)
Imagine the terrible performance of grep written in js, executed by a chrome binary.
Re:Chrome 59 has cross-platform headless support by Spivak on Wednesday April 12, 2017 @09:51PM (#14103459)
I mean honestly Electron running React-CLI with React-Arg-Router is the only way to write a cross platform CLI tools these days.
Re:Chrome 59 has cross-platform headless support by sandstrom on Wednesday April 12, 2017 @07:05PM (#14102573)
There is an issue on headless here: https://github.com/electron/electron/issues/228
Re:Chrome 59 has cross-platform headless support by ericb on Wednesday April 12, 2017 @09:36PM (#14103377)
Would this run as a chrome driver for Selenium? What is needed to make this work with Selenium?
Re:Chrome 59 has cross-platform headless support by onion2k on Thursday April 13, 2017 @03:25AM (#14104865)
It should be possible, but as a browser rather than a driver so you'd still need Chromedriver to glue Chrome and Selenium together. In Karma with karma-chrome-launcher[1] you can pass options to the browser using the flags option, eg;

customLaunchers: { chrome_headless: { base: 'Chrome', flags: ['--headless'] } }

I've not tested that yet but I can't really see a reason why it wouldn't work.

[1] https://github.com/karma-runner/karma-chrome-launcher

Re:Chrome 59 has cross-platform headless support by kuahyeow on Thursday April 13, 2017 @03:50AM (#14104978)
Yes, it does. Tried it out with our Selenium based test suite. Just have to pass in the `--headless` switch to Chrome
Re:Chrome 59 has cross-platform headless support by vvoyer on Thursday April 13, 2017 @03:53AM (#14104997)
Almost one year old but there was a talk on headless chrome at the Blink conference (BlinkOn 6):

Video: https://youtu.be/GivjumRiZ8c

Slides: https://docs.google.com/presentation/d/1gqK9F4lGAY3TZudAtdcx...

More links: Headless Chrome architecture: https://docs.google.com/document/d/11zIkKkLBocofGgoTeeyibB2T...

Mailing list: https://groups.google.com/a/chromium.org/forum/#!forum/headl...

All of those links are on https://chromium.googlesource.com/chromium/src.git/+/master/...

Re:Chrome 59 has cross-platform headless support by mstade on Wednesday April 12, 2017 @08:36PM (#14103047)
Fantastic news, not a minute too soon! Can't wait to get rid of PhantomJS. Now if only this was a standard feature of all browsers...
Re:Chrome 59 has cross-platform headless support by est on Thursday April 13, 2017 @02:08AM (#14104529)
Is it possible to install Chromium on a server without X environment? Last time I checked it requires a shit ton of dependencies.
Re:Chrome 59 has cross-platform headless support by livoras on Thursday April 13, 2017 @12:52AM (#14104256)
PhantomJS has plenty unsolved issues(up to 1.7k+), a replacement instead of combination might be a better choice.
Re:Chrome 59 has cross-platform headless support by tianlins on Thursday April 13, 2017 @01:55PM (#14109341)
How fast is headless vs. normal? According to

https://developers.google.com/web/fundamentals/performance/c...

the chrome browser spends a decent amount of time on other steps such as parsing HTML. I wonder how much time could be saved by not rendering pages into pixels.

Re:Chrome 59 has cross-platform headless support by retube on Thursday April 13, 2017 @07:00AM (#14105773)
This page doesn't load for me (IE behind corp firewall). How does one drive/automate a headless browser? What kind of API is there?
Re:Chrome 59 has cross-platform headless support by tonyblundell on Thursday April 13, 2017 @07:05AM (#14105795)
Re:Chrome 59 has cross-platform headless support by dkastner on Friday April 21, 2017 @03:45PM (#14168804)
I put together an example of how to run chromium with --headless driven by cucumber/capybara: https://dkastner.github.io/2017/04/21/headless-chrome.html
Re:Chrome 59 has cross-platform headless support by brendandahl on Thursday April 13, 2017 @01:02PM (#14108802)
For those interested, Firefox is also going to support a headless mode. The current nightly supports headless SlimerJS on Linux and more platforms will come soon.

https://bugzilla.mozilla.org/show_bug.cgi?id=1338004

Re:Chrome 59 has cross-platform headless support by hackcasual on Thursday April 13, 2017 @01:09PM (#14108876)
Re:Chrome 59 has cross-platform headless support by smackfu on Wednesday April 12, 2017 @07:54PM (#14102849)
Have people found many issues that come up in Chrome but aren't found in PhantomJS? We used to use a headless browser but switched to PhantomJS and haven't had any real issues.

(We should probably run under the real IE but jut haven't been bothered.)

Re:Chrome 59 has cross-platform headless support by adzicg on Wednesday April 12, 2017 @08:10PM (#14102907)
Phantom does not support more recent JS syntax/tweaks. We have an app that is aimed at more recent browsers only so can use latest ES6 features, and had to move from Phantom to in-browser tests (the alternative would be to use babel for transpilation, but then we wouldn't be testing the code that is actually released to users)
Re:Chrome 59 has cross-platform headless support by kageneko on Wednesday April 12, 2017 @07:56PM (#14102862)
I've run into some problems with some of the more ... creative jasmine tests I've done. Mostly, it's been around object mocks. I've found places where I can do things with Object.defineProperty() in Chrome that throw exceptions in PhantomJS :(
Re:Chrome 59 has cross-platform headless support by laurencei on Thursday April 13, 2017 @06:38AM (#14105684)
Can anyone confirm - would this work with a Flash/SWF application? i.e. could I use the headless mode to interact with the Flash Application to run some commands and retrieve the output?

I tried googling around but didnt find much to say either way...

Re:Chrome 59 has cross-platform headless support by du_bing on Friday April 14, 2017 @07:06AM (#14113740)
It seems that Chromium 59 still can not be installed on Raspberry Pi, or anyone has done it?

It will be great to use this headless Chromium on Raspberry Pi to execute some routine web browser jobs.

Does it support the extensions installed on Chromium? Curious.

Re:Chrome 59 has cross-platform headless support by amingilani on Wednesday April 12, 2017 @07:41PM (#14102772)
Does this mean I no longer need to use phantomjs for my tests?
Re:Chrome 59 has cross-platform headless support by wslh on Thursday April 13, 2017 @10:10AM (#14107029)
How fast is the debugging mode? I tried the first debugging protocol when Chrome added it and it was very difficult to use. I assume this time is different?
Re:Chrome 59 has cross-platform headless support by armitron on Wednesday April 12, 2017 @08:42PM (#14103088)
Doesn't seem to work on OSX. Connecting to debug port from a different chrome brings up an empty page.

Running Version 59.0.3069.0 (Official Build) canary (64-bit)

Re:Chrome 59 has cross-platform headless support by vvoyer on Thursday April 13, 2017 @03:29AM (#14104877)
Re:Chrome 59 has cross-platform headless support by kawsper on Thursday April 13, 2017 @04:30AM (#14105167)
Looking at https://developer.chrome.com/devtools/docs/debugging-clients, it seems we are missing a Ruby client. Last time I tried it gave me some headaches trying to talk to the websockets, but hopefully someone smarter than me can pick it up.
Re:Chrome 59 has cross-platform headless support by llimllib on Wednesday April 12, 2017 @09:21PM (#14103313)
same for me. Wonder if we're doing something wrong?
Re:Chrome 59 has cross-platform headless support by notatoad on Wednesday April 12, 2017 @09:38PM (#14103389)
Has it actually landed in the builds yet, or just been marked as targeting 59 in the platform docs?
Re:Chrome 59 has cross-platform headless support by dvallet on Wednesday April 12, 2017 @10:49PM (#14103739)
We are targeting 59. A fix for Mac OS X is on its way: https://codereview.chromium.org/2811633002
Re:Chrome 59 has cross-platform headless support by llimllib on Thursday April 13, 2017 @09:38AM (#14106728)
Thanks! It looks like that has been closed... is there any way to know what release # the fix is in, or when it gets released?
Re:Chrome 59 has cross-platform headless support by dvallet on Monday April 17, 2017 @06:42PM (#14135057)
It'll be released in 59.0.3071.3
Re:Chrome 59 has cross-platform headless support by llimllib on Wednesday April 12, 2017 @09:39PM (#14103396)
I tried to figure that out but was unable to
Re:Chrome 59 has cross-platform headless support by _pdp_ on Wednesday April 12, 2017 @08:54PM (#14103152)
This is great if the headless mode supports the web extension API because it means that we can run our security tools almost as command line tools.
Re:Chrome 59 has cross-platform headless support by hbakhtiyor on Thursday April 13, 2017 @11:01AM (#14107526)
i use when they announced headless mode on linux, and built generating thumbnails from captured screenshots of websites and uncovering the technologies used on websites

and the api is available for free, https://github.com/letsvalidate/api

Re:Chrome 59 has cross-platform headless support by 0xFFC on Thursday April 13, 2017 @02:18AM (#14104572)
Can somebody explain to me what is this good for?

Thank you.

Re:Chrome 59 has cross-platform headless support by vacri on Thursday April 13, 2017 @02:36AM (#14104641)
Headless browsers are frequently used in buildserver testing of web apps.
Re:Chrome 59 has cross-platform headless support by jamesgeck0 on Friday April 14, 2017 @10:49AM (#14114759)
I'll be using it to generate printable PDF reports. It's a huge pain getting highcharts graphs to look identical in every browser's print view.
Re:Chrome 59 has cross-platform headless support by stheakanath on Friday April 14, 2017 @12:56PM (#14115539)
Is this confirmed to work with Flash? I know selenium did not support Flash so it caused some dev issues.
Re:Chrome 59 has cross-platform headless support by MR4D on Wednesday April 12, 2017 @08:33PM (#14103027)
Given the rough comments on the Electron story earlier, this should be welcome by all.
Re:Chrome 59 has cross-platform headless support by zigomir on Thursday April 13, 2017 @02:09PM (#14109462)
Not sure if this can enable SSR (server side rendering) for any client side lib?
Re:Chrome 59 has cross-platform headless support by unixhero on Thursday April 13, 2017 @10:38AM (#14107308)
What is the use case for headless Chrome?
Re:Chrome 59 has cross-platform headless support by ntaylor on Thursday April 13, 2017 @12:40PM (#14108586)
> Headless mode allows running Chromium in a headless/server environment. Expected use cases include loading web pages, extracting metadata (e.g., the DOM) and generating bitmaps from page contents -- using all the modern web platform features provided by Chromium and Blink.

Practically speaking, software developers will use headless Chrome to automate testing of product functionality. Today, developers use systems like Selenium or PhantomJS to accomplish this feat, but it's a painful process to maintain these headless browser execution engines. Adding headless support into Chrome means that developers can count on the presentation of their application on a given version of the Blink engine run within Chrome.

Re:Chrome 59 has cross-platform headless support by softwarelimits on Thursday April 13, 2017 @03:59AM (#14105027)
is this is chromium, too?
Re:Chrome 59 has cross-platform headless support by masterleep on Wednesday April 12, 2017 @06:17PM (#14102248)
Please let this be capable of generating PDFs from HTML from the command line.
Re:Chrome 59 has cross-platform headless support by vvoyer on Wednesday April 12, 2017 @06:32PM (#14102350)
Re:Chrome 59 has cross-platform headless support by jzfeng on Thursday April 13, 2017 @12:13AM (#14104113)
The print to pdf command currently only support default print settings. Adding support for customized page size, header and footer, dpi, etc. is in progress.

Please see bug: https://bugs.chromium.org/p/chromium/issues/detail?id=603559 for updates.

Re:Chrome 59 has cross-platform headless support by masterleep on Thursday April 13, 2017 @12:46AM (#14104240)
Excellent news, thanks!
Re:Chrome 59 has cross-platform headless support by erikig on Wednesday April 12, 2017 @09:01PM (#14103192)
https://wkhtmltopdf.org/

You can download the two tools wkhtmltopdf and wkhtmltoimage which use WebKit to generate pdfs/images.

Re:Chrome 59 has cross-platform headless support by ashkulz on Thursday April 13, 2017 @12:14AM (#14104116)
I'm the maintainer of wkhtmltopdf, and it's hopelessly out of date. There's still some bugs in the Chrome print-to-PDF support as support was added just a few days ago:

https://bugs.chromium.org/p/chromium/issues/detail?id=603559

Not sure if all the full functionality that wkhtmltopdf can be ported, it had patches to Qt/WebKit to enable that ... probably will need API enhancements in Chrome. Don't have the time right now, but I registered http://crhtmltopdf.org a while ago hoping that I'd get around to it.

Re:Chrome 59 has cross-platform headless support by adam77 on Wednesday April 12, 2017 @10:33PM (#14103672)
Sadly wkhtmltopdf's version of Webkit is ancient :( No flexbox, no es6, etc...
Re:Chrome 59 has cross-platform headless support by codedokode on Thursday April 13, 2017 @06:17AM (#14105583)
I think it just means that the site is poorly designed. I think websites should work correctly everywhere where CSS2.1 and ES3 is supported. Otherwise some users won't be able to view those sites.
Re:Chrome 59 has cross-platform headless support by Derbasti on Thursday April 13, 2017 @12:12AM (#14104112)
No paged media makes page formatting much too painful.
Re:Chrome 59 has cross-platform headless support by michael_miller on Wednesday April 12, 2017 @06:49PM (#14102474)
Any idea if you can configure the page DPI with this API?
Re:Chrome 59 has cross-platform headless support by kenshaw on Wednesday April 12, 2017 @07:19PM (#14102643)
Yes, the emulation domain has APIs for changing that.
Re:Chrome 59 has cross-platform headless support by mixu on Wednesday April 12, 2017 @07:42PM (#14102777)
If you're willing to wait until Electron releases a Chrome 59 -based build, I'll be updating https://github.com/mixu/electroshot which handles screenshots and print-to-PDF along with a bunch of other niceties.
Re:Chrome 59 has cross-platform headless support by Derbasti on Thursday April 13, 2017 @12:11AM (#14104107)
Does it support paged media?
Re:Chrome 59 has cross-platform headless support by pizza on Wednesday April 12, 2017 @06:55PM (#14102515)
Is there an easy way to do the opposite? e.g. read PDFs as HTML (intended to be read through a remote shell), or text?
Re:Chrome 59 has cross-platform headless support by kccqzy on Wednesday April 12, 2017 @07:18PM (#14102630)
Extracting text from PDF is not hard, though PDF only contains low-level formatting instructions so the result might not be nice, especially if the original PDF has any non-trivial formatting, like pull quotes, multi-column text, etc. If you don't care about that or the correct "flow" of text, it should be easy enough to just find all the Tj and TJ operators and extract their operands. You might also need to reverse some ligatures though.

Producing nice semantic HTML is much harder, though also easy if you don't mind every word in a separate absolutely positioned div.

Many PDF reader software already contains empirically tuned routines to infer the text flow and generate text files (because the software needs to handle Select All and Copy), but they often produce bad results.

But if you just want to read a PDF on a remote machine over ssh, the easiest solution might be just transferring the file and then opening it locally, or use X forwarding and open the PDF with a graphic reader.

Re:Chrome 59 has cross-platform headless support by jevinskie on Wednesday April 12, 2017 @07:08PM (#14102589)
You might be able to tweak this pdf.js example to dump out its canvas element after it renders.

https://github.com/mozilla/pdf.js/blob/master/examples/learn...

Re:Chrome 59 has cross-platform headless support by desdiv on Wednesday April 12, 2017 @08:44PM (#14103105)
Re:Chrome 59 has cross-platform headless support by ufmace on Wednesday April 12, 2017 @10:19PM (#14103605)
Easy, not so much, depending on exactly what you want to get out of it. I did a project with this once https://www.idrsolutions.com/jpdf2html5/. Last I checked, they only supported it as a Java library that could generate rather nice looking and complete HTML pages from PDF documents. The output was great, but it was kinda pricey and difficult to work with.

On the opposite side of the complexity level, I have also used this http://www.pdfsharp.com/PDFsharp/ to extract bits of text from PDFs. It's free, but you only get access to the raw PDF text with formatting codes. It works fine if you just want to grab a short string, but you got your work cut out for you if you want to do anything more sophisticated.

Re:Chrome 59 has cross-platform headless support by uptown on Wednesday April 12, 2017 @06:53PM (#14102499)
Not sure of your exact use-case, but mPDF does this well.

https://github.com/mpdf/mpdf

Re:Chrome 59 has cross-platform headless support by frik on Thursday April 13, 2017 @12:37AM (#14104201)
Especially it should adhere to CSS3 page break properties.
Re:Chrome 59 has cross-platform headless support by zwerdlds on Wednesday April 12, 2017 @06:19PM (#14102261)
FWIW, you can do that now, using phantomjs (which is chrome) http://phantomjs.org/screen-capture.html
Re:Chrome 59 has cross-platform headless support by dasmoth on Wednesday April 12, 2017 @06:28PM (#14102332)
It's a useful tool (and huge thanks to those who built it -- and SlimerJS for that matter) but whenever I've reached for there's always been some issue to resolve, generally relating to the exact version and/or set of APIs supported. Headless mode (with PDF support -- which it looks like the latest version of the Chromium remote protocol does indeed have) built into a mainstream browsers is nearly guaranteed to be a smoother experience.
Re:Chrome 59 has cross-platform headless support by velodrome on Wednesday April 12, 2017 @06:23PM (#14102288)
> FWIW, you can do that now, using phantomjs (which is chrome) http://phantomjs.org/screen-capture.html

It's based on webkit.

Re:Chrome 59 has cross-platform headless support by theandrewbailey on Wednesday April 12, 2017 @06:50PM (#14102478)
Once upon a time, but not anymore.

https://www.chromium.org/blink

Re:Chrome 59 has cross-platform headless support by rubber_duck on Wednesday April 12, 2017 @07:24PM (#14102673)
PhantomJS is based on webkit (and an outdated version IIRC + a shitty JS interpreter)
Re:Chrome 59 has cross-platform headless support by chickenfries on Wednesday April 12, 2017 @06:37PM (#14102379)
Re:Chrome 59 has cross-platform headless support by erichurkman on Wednesday April 12, 2017 @08:27PM (#14102997)
And, if you need much higher fidelity and control of HTML/CSS -> PDF, there's the fantastic Prince library, http://princexml.com/ (nonfree)

(I've been using Prince for over a decade, rendering everything from prescription labels, packing slips, receipts, resumes, books, and more. It's great.)

Re:Chrome 59 has cross-platform headless support by jamespaden on Thursday April 13, 2017 @11:45AM (#14107974)
That's also an API service, http://docraptor.com, with a different pricing model that uses the Prince library for PDF rendering.
Re:Chrome 59 has cross-platform headless support by pharrlax on Wednesday April 12, 2017 @06:55PM (#14102509)
Tried all of these and haven't found any as good as http://www.nightmarejs.org/
Re:Chrome 59 has cross-platform headless support by swah on Thursday April 13, 2017 @06:45AM (#14105714)
Thats just phantomJS though..
Re:Chrome 59 has cross-platform headless support by pharrlax on Thursday April 13, 2017 @08:20AM (#14106148)
It switched to Electron under the hood a while back.
Re:Chrome 59 has cross-platform headless support by chews on Wednesday April 12, 2017 @06:25PM (#14102304)
specifically it's qtwebkit and an old version of it.
Re:Chrome 59 has cross-platform headless support by eppsilon on Wednesday April 12, 2017 @10:42PM (#14103709)
They recently released a beta version based on a newer version of QtWebKit:

https://bitbucket.org/ariya/phantomjs/downloads/

Re:Chrome 59 has cross-platform headless support by zwerdlds on Thursday April 13, 2017 @04:16PM (#14110566)
Tough crowd.