Nw.js: headless version

28

It would be great that if node-webkit are made into headless version...

Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.

megablue picture megablue  ·  7 Jun 2013

Most helpful comment

10

My main need for headless is the ability to run my NW.js app (with nwjc-compiled modules) on the command line in Linux without an X11 server running. So far my workaround has been to start an Xvfb server but I'd much prefer to not rely on that.

polpo picture polpo  ·  11 Nov 2016

All comments

0

You mean, like, the same Node.js engine and API, but without any browser-alike HTML+CSS interfaces?

But that's what original Node.js is. Maybe you should just get it instead of node-webkit then.

Mithgol picture Mithgol  ·  7 Jun 2013
0

Sounds like you're looking for www.phantomjs.org

tommoor picture tommoor  ·  10 Jun 2013
0
dhendo picture dhendo  ·  8 Jul 2013
0

I would very much like to see a headless option for node-webkit.
And yes I know that is like phantomjs, but phantomjs does not have the nodejs integration that node-webkit has.
Also it can them mean just the one code base and not having to testing to see which environment you are running under etc.
A must have feature! IMHO

ronward picture ronward  ·  2 Dec 2013
0

I didn't get the point of this feature. What exactly you are expecting out of headlessness? Why today node-webkit with hidden main window is not the solution?

szwacz picture szwacz  ·  3 Dec 2013
0

The reason that node-webkit with just the main window hidden is not a solution is because it still expects a display (XWindow/XOrg). e.g. you cannot run it on a server because there is no display. (this is on Linux)
When I try this I get the message: Gtk-WARNING **:cannot open display
[25522:0100/000000:ERROR:zygote_linux.cc(498)] write: Broken pipe

ronward picture ronward  ·  3 Dec 2013
0

@ronward ...then just run node?

damianb picture damianb  ·  3 Dec 2013
1

But node does not have the browser context!
What I want is more like PhantomJS (yes I know, then just use PhantomJS), but it would be very nice to have the combination of node and the browser context (e.g. node-webkit) in one. (and there may be other solution e.g. https://github.com/deanmao/node-chimera/ as mentioned above, but this would mean rewriting code or having two code bases)

ronward picture ronward  ·  3 Dec 2013
1

This is on my plan. Before that you can use xvfb, xvnc or other X server which don't need a physical display on your server.

rogerwang picture rogerwang  ·  3 Dec 2013
0

Thanks, that a very good idea that I had completely forgotten about. (used xvfb to run OpenOffice ages ago when there headless option still had some bugs)
By the way I just love the node-webkit idea/system/setup! Thanks

ronward picture ronward  ·  3 Dec 2013
1

+1
valid use cases for a headless node-webkit are:

  1. provide automated browser testing and code coverage on a build server
  2. running a web-scraper on a server
kaizhu256 picture kaizhu256  ·  10 Jan 2014
0

headless should help develop background apps?
or
We can set show to false in the manifest of your application with similar purpose?

edwardchanjw picture edwardchanjw  ·  22 Jan 2014
0

To me this dilutes the projects aims. Phantomjs does absolutely fine for 99% of purposes.

tommoor picture tommoor  ·  22 Jan 2014
1

I was the first here to point to another project that looks like a headless node-webkit, but today I myself encountered a perfectly valid case for using a headless node-webkit — a case where nothing else would suffice.

That's Travis CI testing of a Node.js addon-containing module. There's no other way to test if a module runs on node-webkit; the module has to be built by nw-gyp and run on node-webkit to see what happens.

And, almost like @ronward said above, I saw precisely the following:

node-pre-gyp ERR! stack Error: Command failed:
node-pre-gyp ERR! stack (nw:2106): Gtk-WARNING **: cannot open display:
node-pre-gyp ERR! stack [2109:0100/000000:ERROR:zygote_linux.cc(478)] write: Broken pipe

You also may look into the my Travis CI log (lines 1271—1273) for an example.

Mithgol picture Mithgol  ·  13 Feb 2014
0

@rogerwang

Before that you can use xvfb, xvnc or other X server which don't need a physical display on your server.

Sounds like a good plan.

Travis CI even provides a script for starting xvfb.

Now how do I run node-webkit on xvfb?

(Unless it already does that automagically based on $DISPLAY, which I am going to check soon.)

Mithgol picture Mithgol  ·  13 Feb 2014
0

Got Package appears valid on this log, line 1272. It seems that xvfb is enough for a headless node-webkit on a Travis CI server.

Mithgol picture Mithgol  ·  13 Feb 2014
0

Running 32bit node-webkit on 64bit Travis CI Linux is also possible (though a bit tricky), see #1566 for details.

Mithgol picture Mithgol  ·  13 Feb 2014
0

@Mithgol I get a:

Xlib:  extension "RANDR" missing on display ":99".
[1183:0215/113833:ERROR:breakpad_linux.cc(1225)] crash dump file written to /tmp/chromium-renderer-minidump-5d9a40a22d7d15b8.dmp

when running v0.9.1 - Feb 11, 2014(64bit) on a digitalocean 5$ instance. I started xvfb like this:

/usr/bin/Xvfb +extension RANDR :99 -ac -screen 0 1024x768x8 &

Any idea?

FWeinb picture FWeinb  ·  15 Feb 2014
0

No idea, sorry. My experience does not tell me anything about that. Two days ago I've run xvfb for the first time in my life. I suppose there's some difference between digitalocean and Travis, because in Travis docs they write something very similar to your attempt (except that +extension RANDR thing and bit depth).

Mithgol picture Mithgol  ·  15 Feb 2014
0

Thanks for your quick answer. I could get it to work. There where some font's missing

sudo apt-get install -y xfonts-100dpi xfonts-75dpi xfonts-scalable xfonts-cyrillic
sudo apt-get install -y x-ttcidfont-conf cabextract ttf-mscorefonts-installer # accept the EULA
sudo dpkg-reconfigure --default-priority x-ttcidfont-conf

The +extension RANDR isn't needed.

FWeinb picture FWeinb  ·  15 Feb 2014
0

For those looking for another usecase here, a headless WebRTC peer would be very nice. From what I can tell, PhantomJS does not support this Chromum feature and https://github.com/js-platform/node-webrtc seems not to be up to par yet for cross-OS and easy installation for users. I very much look forward to headless node-webkit.

cretz picture cretz  ·  16 Feb 2014
0

Another future use-case would be for PDF rendering. PhantomJS is nice but it is dependent on QTWebkit for updates. I like the idea of doing PDF rendering from a library that runs on chromium and node than one that runs on QTWebkit.

CooCooCaCha picture CooCooCaCha  ·  10 Mar 2014
0

A brief follow-up on the RANDR problem. Todd Wolfson says that it's fine to ignore the Xlib error about RANDR. I guess we all have to expect (from now on) that stderr of node-webkit can be non-empty even if everything else is fine (including the application's exit code).

Mithgol picture Mithgol  ·  14 Mar 2014
0

Also, I tried +extension RANDR on Travis CI's version of Xvfb today.

It does not seem to prevent the same node-webkit's RANDR-related Xlib error.

Useless.

Mithgol picture Mithgol  ·  14 Mar 2014
0

Reasons that Node-Webkit would be the better headless browser:

  1. PhantomJs is based on Webkit whereas Node-webkit is based on Blink. Will Apple
    maintain Webkit on non Apple platforms? Opera, Qt and others are moving away
    and Safari is discontinued on non Apple platforms.
  2. V8 performance is much better than JavaScriptCore in PhantomJs
  3. One of the uses of headless browsers is crawlable Ajax. PhantomJs does not support web components or Polymer making PhantomJs a non-option for this use case.
Starcounter-Jack picture Starcounter-Jack  ·  24 Mar 2014
0

With WebRTC entering the mainstream a headless chromium api would help create services based on WebRTC. Just saying there is a need not what the best solution is.

jcrubino picture jcrubino  ·  28 Mar 2014
0

+1

Rameshv picture Rameshv  ·  2 Apr 2014
0

"To me this dilutes the projects aims. Phantomjs does absolutely fine for 99% of purposes."

This is not a valid counter argument. In what way does PhantomJS share a V8 context with Node as the project aim of Node-webkit does?

tbranyen picture tbranyen  ·  12 Apr 2014
0

I just got node webkit running off a fresh amazon ec2 server running ubuntu 12.04.

Here is my complete terminal history to get this running. Thanks for all the help on this thread!

# Freshen up ubuntu
sudo apt-get update
sudo apt-get dist-upgrade

# Grab node - add it to the apt listings then install
sudo add-apt-repository ppa:chris-lea/node.js
sudo apt-get update
sudo apt-get install nodejs

# get xvfb
sudo apt-get install xvfb

# get n unpack node-webkit
wget http://dl.node-webkit.org/v0.9.2/node-webkit-v0.9.2-linux-x64.tar.gz
tar -xvzf node-webkit-v0.9.2-linux-x64.tar.gz 

# some initial depencies
sudo apt-get update && sudo apt-get install -y xfonts-100dpi xfonts-75dpi xfonts-scalable xfonts-cyrillic x11-apps imagemagick

# a lot of libraries are missing (libXtst, libgtk2.0, libnss3, libgconf2-4, libasound2)
# I had success in just installing chrome instead of trying to install the libraries
wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb
sudo dpkg -i google-chrome-stable_current_amd64.deb
sudo apt-get -f install
sudo dpkg -i google-chrome-stable_current_amd64.deb


## install some fonts
# to install the mscorefonts, allow apt to grab files from multiverse
# Do this by uncommenting two lines in /etc/apt/sources.list:
# deb http://us-east-1.ec2.archive.ubuntu.com/ubuntu/ precise multiverse
# deb http://us-east-1.ec2.archive.ubuntu.com/ubuntu/ precise-updates multiverse
sudo -e /etc/apt/sources.list
sudo apt-get update
sudo apt-get install ttf-mscorefonts-installer
sudo apt-get install -y x-ttcidfont-conf cabextract
sudo dpkg-reconfigure --default-priority x-ttcidfont-conf

# run a simple example with xvfb - running `hellonodewebkit` here
sudo xvfb-run --server-args='-screen 0, 1024x768x24' node-webkit-v0.9.2-linux-x64/nw hellonodewebkit

# restart by killing xvfb and nw
pkill [X,x]vfb
pkill nw
chriddyp picture chriddyp  ·  18 Apr 2014
0

...sudo xvfb-run? Is root really required there? Also, dist-upgrade in that right off the bat, not the best idea.

damianb picture damianb  ·  18 Apr 2014
0

node is not chromium at all. no webgl, no webrtc, no indexeddb, no html5 in general. and phantom has no node/module-system.

so a headless node-webkit would be cool for a _lot_ of usecases.

another idea: being able to use webworkers (with transferable objects) would be cool on the server :D

guybrush picture guybrush  ·  2 Jun 2014
0

Agreed, headless node-webkit would be cool. A project I'm currently working on would benefit from the ability to run a headless WebRTC peer and use Chromium's storage APIs, so :+1: from me.

jure picture jure  ·  17 Jun 2014
0

+1

warpech picture warpech  ·  11 Jul 2014
0

+1

yuriyp picture yuriyp  ·  22 Jul 2014
0

+1, in my case I want to run node.js as a stand alone binary which pulls in all the required binary modules as well. Something like nexe which bundles in binary modules too perhaps headless node-webkit might be an overkill?

opensourcegeek picture opensourcegeek  ·  23 Jul 2014
0

:+1:

buschtoens picture buschtoens  ·  28 Jul 2014
0

+1

pirog picture pirog  ·  30 Aug 2014
0

late, but +1 for building GUI apps using CI systems in turn using a headless node-webkit. awesomesauce defined.

michahell picture michahell  ·  14 Sep 2014
0

+1 as a step towards a replacement of phantomjs.

johntitus picture johntitus  ·  15 Oct 2014
0

+1 for this feature. I want to get rid of XServer to run node-webkit

michalliu picture michalliu  ·  12 Nov 2014
0

this would be a beautiful thing, perhaps looking into what phantomjs did in the early days? (i think it was a simpler patch that didn't completely remove the xserver dependency, but didn't require a screen)

:+1: for the team. phantomjs has never been a preferential tool for me due to the loss of flexibility having a strictly headless browser. ideally when things don't work i'd like to see the state of the page / debug with devtools. would make development of such automated testing scripts much easier from a workflow point of view.

gstack picture gstack  ·  12 Nov 2014
0

+1 for the info on this thread (which help me when trying to run node-webkit without seeing the UI and in linux/travis scenarios)

Here is how I did it: https://github.com/rogerwang/node-webkit/issues/1966#issuecomment-65922211 and https://github.com/rogerwang/node-webkit/issues/1966#issuecomment-65923266

DinisCruz picture DinisCruz  ·  7 Dec 2014
0

+1 so I can use Web Audio API from node

simonbreak picture simonbreak  ·  13 Dec 2014
0

+1 phantomjs seem to have quite outdated WebKit. node-webkit is real-life Chromium.

sheerun picture sheerun  ·  22 Dec 2014
0

A fully browser compliant, headless mode node-webkit that can run web pages (including all the javascript in them) without xvfb or any GUI would be a great and wonderful thing. Nothing like this exists (that runs on node) and who wants to juggle 5 different tools to get close to doing this anyway. Please make this happen. The new possibilities will be exciting. Maybe there is a special "headless" renderer needed, that does not require any GUI of any kind.

Sesshomurai picture Sesshomurai  ·  29 Dec 2014
0

@Sesshomurai and others, so what is the definition of 'headless'?

Is it that it can run on server? or that it can run without been seen?

For both those scenarios I was able to make it work with https://github.com/o2platform/nwr and https://travis-ci.org/o2platform/nwr (travis is running the tests using xvfb)

DinisCruz picture DinisCruz  ·  29 Dec 2014
0

@DinisCruz. To me, true headless is A) run on a server B) Does not require X11 or any graphical libraries (which xvfb does) C) Does not expose any UI (either virtual or real). D) Is optimized. Yes, there may be workarounds, but a native headless solution is better (and node-webkit is 9/10ths of the way there). xvfb uses memory for screen buffers.

Sesshomurai picture Sesshomurai  ·  29 Dec 2014
0

I have an app that runs on Windows and Linux. But, everyone that think in run it on Linux, think about it as a service, starting at boot. The UI would be only to the one time configuration stuff.
So, I too think that a headless without xvfb nw, that just works, would be very cool indeed.

EthraZa picture EthraZa  ·  29 Dec 2014
1

@sheerun one thing that didn't work in phantomjs years ago and still didn't when i checked a few weeks ago is Unicode code points beyond 0xffff. This is unacceptable for me and yes it feels outdated.

And just as @gstack and other have said there's a huge difference between a strictly headless browser and a browser that _has the ability_ to run headless. To say that 'we don't need a headless nw we already have headless browsers' makes about as much sense as saying 'we don't need nodejs because JS already runs in the browser'. You either subscribe to both statements or to none if you want to make any sense.

To make another point, my use case for a nw-without-gui is rendering page contents to image / pdf files; for this i don't need user interaction which is great because i can then have a server or a Vagrant terminal-only VM do the work. But i _do_ need a display of the pages as long as i'm still fiddling with the layout. I did it before with phantom.js but that's a pain, not only for the lacking Unicode support but also because you have to either open a 'real' browser to get a look onto your design, or have phantom output some pages and then look at the images. Both ways are far from optimal: You can't interact with a static image the way you can interact with a page in a web browser with dev tools, and using another browser means your display will _never_ be accurate. Never. Other browser, other version, there _will_ be differences.

loveencounterflow picture loveencounterflow  ·  19 Jan 2015
0

@loveencounterflow Agree 100%. My use case is similar. I want to run the same code that runs in the browser in a node.js app that executes as a real browser sandbox. My javascript code is a lot of socket.io stuff and generally doesn't touch the DOM, but the client code for socket.io is entirely different within the browser vs. the node.js client package. Different code. So now I have to make a separate codebase and client to do the same thing to spawn off in a bunch of node apps to emulate browser connections. And that doesn't really test my browser-side code, does it? Because its not the exact same code nor a true browser sandbox. I think projects like this (node webkit) are "getting close" to realizing the need for a truly headless browser in Node. It would require interfacing with some frame buffer library I'm sure. But hopefully we can get there.

Sesshomurai picture Sesshomurai  ·  21 Jan 2015
0

+1. It would be great for automatic web data processing too.

vsemozhetbyt picture vsemozhetbyt  ·  24 Jan 2015
0

+1 with some background.

I'm looking for a way to create on a simple command line utility that I can use to communicate with a service I'm working on. Ideally the utility would be a cross-platform, single-file distributable I can pass someone. This would provide a turnkey way for them to leverage my service without having to install Node or any other tools.

dotproto picture dotproto  ·  5 Feb 2015
0

Looking forward for this feature.

MContagious picture MContagious  ·  5 Feb 2015
0

+1

jonnysamps picture jonnysamps  ·  7 Feb 2015
0

+1

jwerle picture jwerle  ·  9 Feb 2015
0

+1

xenyou picture xenyou  ·  19 Feb 2015
0

+1. I'm having issues with PhantomJS as my webApp utilises a huge amount of socket.io and the two don't play nice. A NW solution would be fantastic.

chrisdack picture chrisdack  ·  23 Feb 2015
0

+1

iradul picture iradul  ·  23 Feb 2015
0

+1

drom picture drom  ·  12 Mar 2015
0

Sorry to bother, is there anyone knows what's the status of this feature now?

michalliu picture michalliu  ·  19 Mar 2015
0

It is like the feature for next version release update.
Even with talented contributor here, we giving huge backlog of bleeding edge request here on nwjs, we should wait patiently or help fix some bug.

I consolidate few advantages from @kaizhu256, @cretz, and many other that may give more insight that I overlook due to long page of comment:

  • Develop background apps with headless instead of hiding at startup
  • provide automated browser testing and code coverage on a build server
  • running a web-scraper on a server
  • WebRTC use case
edwardchanjw picture edwardchanjw  ·  19 Mar 2015
0

My use case is a single Linux executable that has a GUI but also can also be used from the command line on a system with no running X server.

polpo picture polpo  ·  19 Mar 2015
1

FYI:

Atom-shell closed their similar issue a few days ago. As stated, this is more a chromium issue than an atom-shell issue, and thus, should probably never be fixed.

Phantomjs 3 plans to be chromium based with the QtWebEngine widgets. I have no idea if the QtWebEngine supports the headless Qt platforms though.

BenoitZugmeyer picture BenoitZugmeyer  ·  19 Mar 2015
0

Graphical system is like legend for me,
Is that wayland or similar other is a choice to reduce dependency of Graphical component.

Chromium seem using an abstraction layers for existing Graphical system:
http://www.chromium.org/developers/design-documents/ozone

There is a line in that I read as dump people, because underlying it might have some magic happen.

Ozone Platforms
Internal platforms:
caca - Draws graphical output to text using libcaca. In case you ever wanted to test embedded content shell on tty. Add libcaca to your favourite Chromium development workstation and build like so:

edwardchanjw picture edwardchanjw  ·  20 Mar 2015
0

+1

monolithed picture monolithed  ·  4 Apr 2015
0

Yep, I need webrtc, this will save my life.

vsantosu picture vsantosu  ·  16 Jun 2015
0

@BenoitZugmeyer atom-shell now Electron supports headless version, 'cause they use that to run Atom Editor's tests in CI services and CI services don't have a monitor :wink:

steelbrain picture steelbrain  ·  3 Jul 2015
0
BenoitZugmeyer picture BenoitZugmeyer  ·  3 Jul 2015
0

Thanks,The problem has been solved

yunqingmo picture yunqingmo  ·  3 Jul 2015
0

I followed this post...
http://twolfson.com/2014-11-22-moving-from-phantomjs-to-node-webkit
and was able to mimic phantomjs functionality.

It's not headless in the sense that I can see node webkit's browser but I'm able to load a webpage and take a screenshot in the background.

What are the drawbacks/benefits of going from what's in that post to truly headless?

twilly86 picture twilly86  ·  25 Aug 2015
1

+1 again for web-audio (without alternatives' overhead)

JohnnyMarnell picture JohnnyMarnell  ·  29 Aug 2015
0

+1 want to use chromium based instead of webkit based server side image rasterization. Is a huge pain to get nw running "headless" with xvfb. But it does work.

CaptEmulation picture CaptEmulation  ·  24 Feb 2016
0

+1 My experience with phantomjs is I'm very frustated, recently, I was scraping soundcloud, it's seems that soundcloud use webpack, and phantomjs not support webpack, I don't know, I can't ignore errors, and process stopped, :sigh. Btw, I've been using nwjs for 4 years and It will be great if nwjs has headless feature. Absolutely it will replace phantomjs.

oknoorap picture oknoorap  ·  25 Mar 2016
1

+1 for nwjs headless. I currently have Linux users running xvfb so that they can run my app as a service. However, most people are running it with the GUI, and I don't want to build an extra app just for people that want to run it as a service. Since this hasn't been implemented, I'm trying to create a windows service using nssm. However, I'm running into the same problem as I did on Linux. I need a windows alternative to xvfb.

jssuttles picture jssuttles  ·  26 Mar 2016
1

+1

A headless version of node.js that was capable of WebRTC usage would be exactly what I need. Xvfb does for now, but it's not great.

FeepingCreature picture FeepingCreature  ·  28 Mar 2016
0

+1 would be amazing for my use case. This would kill the need for 2 separate code bases and allow everything to be done with NWJS

ChrisWoodlief picture ChrisWoodlief  ·  28 Mar 2016
0

Currently trying cygwin -> cygrunsrv -> xvfb-run -> nw.js 0.13.1 on Windows. Xvfb-run does not work the same on Windows as on Linux. I get this message:
[4736:3124:0328/142826:ERROR:native_app_window_views.cc(490)] Failed initializing an ITaskbarList interface.

jssuttles picture jssuttles  ·  28 Mar 2016
0

Found winsw and node-windows. Looks to work. But we still don't like the workaround.

jssuttles picture jssuttles  ·  30 Mar 2016
0

+1 for nwjs headless ...
Not familiar with Xvfb and I'm wondering what is its overhead (memory+cpu) when we want to mimic headless with it ?

Cooker-Monster picture Cooker-Monster  ·  11 May 2016
0

:+1:

ben-page picture ben-page  ·  17 May 2016
0

Please refrain from +1-ing and that would be great, because...-ing this issue. This only clutters the participants inboxes.

The maintainers have understood that there is a demand for this feature. If you'd still like to express your appreciation, you can do so by adding a reaction emoji to the original issue (or to a comment).

If you have to add something of value, like a concrete implementation approach, feel free to do so. Even better yet, start a PR.

You can also post a bounty.

Thanks. :smile:

buschtoens picture buschtoens  ·  17 May 2016
3

Thanks, have been following the issue for a while. We need to migrate to GN
build before doing this.

On Sun, Jun 5, 2016, 5:30 AM vsemozhetbyt [email protected] wrote:

https://twitter.com/samccone/status/739166801427210240


You are receiving this because you were mentioned.

Reply to this email directly, view it on GitHub
https://github.com/nwjs/nw.js/issues/769#issuecomment-223779343, or mute
the thread
https://github.com/notifications/unsubscribe/AAKGGYm5m4TUVQSK8Z3_XWtAbreXiUMpks5qIe5WgaJpZM4At0L7
.

rogerwang picture rogerwang  ·  5 Jun 2016
0

+1 for a headless version running on a headless server
Today we use nwjs as a rendering server, so we need a but not a display output.

damoebius picture damoebius  ·  20 Jun 2016
0

Problem solved!

Sent from my Verizon Wireless 4G LTE smartphone

-------- Original message --------
From: vsemozhetbyt [email protected]
Date: 06/24/2016 6:38 AM (GMT-05:00)
To: "nwjs/nw.js" nw.[email protected]
Cc: Sesshomurai [email protected], Mention [email protected]
Subject: Re: [nwjs/nw.js] headless version (#769)

https://docs.google.com/presentation/d/1gqK9F4lGAY3TZudAtdcxzMQNEE7PcuQrGu83No3l0lw/preview


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub, or mute the thread.

Sesshomurai picture Sesshomurai  ·  24 Jun 2016
0

I'm still wrapping my head around this and wish someone would write a n00b guide .. but here is a video off the presentation. BlinkOn 6 Day 2 Talk 1: Headless Chrome - YouTube

Hope someone here will post a guide for dummies to get this working :-)

SantoshSrinivas79 picture SantoshSrinivas79  ·  24 Jun 2016
2

I'm collecting the feature requests here for our headless plan in future:

What do you need for a headless NW.js build flavor? Currently as I see all the need can be fulfilled by upstream headless project and a Node.js API for it

If no one brings any idea for a significant differentiation between NW and Chromium I'll close this issue as the feature is done by upstream.

rogerwang picture rogerwang  ·  11 Nov 2016
10

My main need for headless is the ability to run my NW.js app (with nwjc-compiled modules) on the command line in Linux without an X11 server running. So far my workaround has been to start an Xvfb server but I'd much prefer to not rely on that.

polpo picture polpo  ·  11 Nov 2016
2

@rogerwang I need NWJS application that combines Node and Browser DOM rendering and can run in pure CLI mode when needed. Agree with @polpo

drom picture drom  ·  11 Nov 2016
0

@rogerwang my NWJS application use the Node Api AND the DOM, Canvas, WebGL, WebWorker, to compute images at server side.
It could be run in pure CLI on a headless server

damoebius picture damoebius  ·  11 Nov 2016
0

I can see myself in the future using it for a webserver that processes image with webgl :)

Do code starts from an HTML file samr way as with the not headless one?

tentone picture tentone  ·  11 Nov 2016
0

After started headless we could we have a way for additional interactions. The 'console' could be extended to include something like the interactive function below. That would left it run as a full shell or console application and just command line switch. This maybe more useful if doing an SSH into a server. Some of these are things I look for from my BBS days :).

All of these are variation on the console.log() function. The main difference is that they extend the 'console' object for input and output in an interactive console/shell application:

  • console.read() - Read a single character from input, return the character value
  • console.readLine() - Read a line of text until you press Enter, return the character value
  • console.write(s) - Write some character _would not end_ with CRLF of LF
  • console.writeLine(s) - Write some character _would end_ with CRLF of LF
  • console.color(f,b) - Send an escape code to set a foreground (f) and an optional background color(b)
  • console.blink(b) - Turn blinking text on or off (b = 0 or 1, or true and false)
tekrat picture tekrat  ·  11 Nov 2016
0

I feel that a headless NW.js build flavor would be quite useful when it becomes necessary to test the behaviour of custom builds (builds made by nw-gyp and targeting NW.js specifically) of binary addons that reside in Node.js modules (such as sqlite3 or serialport for example).

Such modules cannot be tested merely on a headless Chromium (because the modules need Node.js API) or in NW-less Node.js (because the addons are rebuilt to have NW.js ABI).

Additionally, if the tests are running on Travis CI, then it's quite beneficial to migrate from their old infrastructure to their new container-based infrastructure (because then builds start much faster and they also run faster), but after such migration there's no sudo and thus (obviously) no sudo xvfb-run tricks (mentioned above by @chriddyp) are possible to run an unmodified NW.js headlessly.

(I must admit that Travis CI instances have xvfb installed and thus it's still possible to achieve something but I'd still be more comfortable with an NW.js build which is already headless.)

Mithgol picture Mithgol  ·  11 Nov 2016
1

@rogerwang the obvious differentiator is also the killer feature of nw.js itself - running nodejs and a full DOM in the same JS context. Having a headless mode opens up very useful server side rendering possibilities.

jonnermut picture jonnermut  ·  20 Dec 2016
0

(I apologize for the drive by comment.)

I'm looking for a replacement for wkhtmltopdf on windows server (no xvfb) for generating reports; the two major issues with wkhtmltopdf is it still uses the OS DPI settings (reports vary from dev to server) and isn't staying up to date with recent versions of webkit so old bugs are hurting more and more.

I'd like to note two interesting developments:

  1. Google chrome is growing a --headless flag in the standard build,
  2. The addition in NW.js of the win.print method.

I would also like to note I've seen phantomjs and I cannot use it for my purpose (generating PDF reports). Right now depending on wkhtmltopdf which depends on QT webkit isn't a sustainable option. It would be great to have an alternative.

kardianos picture kardianos  ·  24 Dec 2016
0

Why can't you use Phantomjs?

julmot picture julmot  ·  24 Dec 2016
0

phantomjs_long_page.pdf
wkhtmltopdf_long_page.pdf

phantomjs doesn't support page-breaks and doesn't go through a print pipeline in general. See attached files for differences.

kardianos picture kardianos  ·  24 Dec 2016
0

Can you please share your Phantomjs settings?

julmot picture julmot  ·  24 Dec 2016
0

@julmot You are correct, I may be able to use phantomjs using something like https://github.com/ariya/phantomjs/blob/master/examples/rasterize.js . I'm sorry for the distraction.

kardianos picture kardianos  ·  24 Dec 2016
0

PhantomJS maintainer stepping down after Google's headless Chromium announcement

damoebius picture damoebius  ·  13 Apr 2017
1

Announcement itself: https://www.chromestatus.com/features/5678767817097216
Excited to see this feature in NWJS

drom picture drom  ·  14 Apr 2017
6

Thanks. I've been watching the headless development in upstream closely. NW has been delivering whatever Chromium browser supports. So I'll see and make sure the --headless command line switch works in the first step.

Please note that in upstream, there are 2 browsers in the Chromium binary (headless, and the normal one which we've been using). When --headless is specified, Chromium will switch to and launch the headless browser instead of the normal one. The difference between the 2 browsers can be large for some users, in the same way as content shell vs the browser. It's not like that the normal browser has supported a headless mode.

So when NW supports the upstream switch in the first step, it will deliver the same thing as the upstream headless browser, not like NW apps will run in headless mode. In the 2nd step, the Node integration will be added. The NW application model and the NW API will be the last as the upstream headless browser doesn't support any extension mechanism.

rogerwang picture rogerwang  ·  14 Apr 2017
6
rogerwang picture rogerwang  ·  2 May 2017
-1

I still could not run code in headless mode (ubuntu 16.04/terminal), nw start and terminate, but code not start. I try to use script in html and set js file directly to main section in manifest:
Example:

require('fs').writeFileSync('test.test','TEST');

but file not created, express server also not started

VasiliyIsaichkin picture VasiliyIsaichkin  ·  4 May 2017
0

@rogerwang dear roger, i'd like to suggest that in the "headless" mode, some mthod should be added so that the caller can demand the instance back to GUI-mode (so that the user can switch to manually mode). Yup, let compare the headless as "Auto" mode and GUI as "Manual" mode when we "drive" the vehicle

mgttt picture mgttt  ·  28 May 2017
0

I'd love to see the ability to spawn a headless window using nw.Window.open - similar to how you have the "new-instance" flag currently.

tolrtd picture tolrtd  ·  13 Jul 2017
0

Hi,
Is it working ?
I get the latest nwjs version 0.25.4
I use headless args like that :
{ "name": "#name#", "version": "5.1.0", "main": "index.html", "chromium-args" : "--headless --disable-gpu --no-sandbox --disable-setuid-sandbox", "window": { "show": false } }

But i get a Gtk-WARNING : cannot open display

What's wrong ?

Thank you

dmouton picture dmouton  ·  29 Sep 2017
0

I had success running nwjs v0.18.6 with Xvfb thanks to hauptmedia/nwjs docker image, but I couldn't make it work with the latest version with Xvfb. If anyone made it work, it'd be nice if they publish their dockerfile.

alFReD-NSH picture alFReD-NSH  ·  2 Apr 2018
0

@boostio funded this issue with $10. Visit this issue on Issuehunt

IssueHuntBot picture IssueHuntBot  ·  9 Sep 2018
0

@loadbalance-sudachi-kun funded this issue with $256. Visit this issue on Issuehunt

IssueHuntBot picture IssueHuntBot  ·  17 Sep 2018
2

Any update on the issue?

drom picture drom  ·  1 Mar 2019
0

@0maxxam0 has funded $2.00 to this issue.


IssueHuntBot picture IssueHuntBot  ·  8 Apr 2019
2

Any news here ? No update since times

gahubaul picture gahubaul  ·  16 Sep 2019
0

I'm looking into it

denim2x picture denim2x  ·  27 Jan 2021