nwjs/nw.js

headless version #769

megablue posted onGitHub

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

<bountysource-plugin>

Want to back this issue? Post a bounty on it! We accept bounties via Bountysource. </bountysource-plugin>


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.

posted by Mithgol almost 12 years ago

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

posted by tommoor almost 12 years ago
posted by dhendo almost 12 years ago

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

posted by ronward over 11 years ago

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?

posted by szwacz over 11 years ago

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

posted by ronward over 11 years ago

@ronward ...then just run node?

posted by damianb over 11 years ago

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)

posted by ronward over 11 years ago

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.

posted by rogerwang over 11 years ago

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

posted by ronward over 11 years ago

+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
posted by kaizhu256 over 11 years ago

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

posted by edwardchanjw over 11 years ago

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

posted by tommoor over 11 years ago

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.

posted by Mithgol about 11 years ago

@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.)

posted by Mithgol about 11 years ago

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.

posted by Mithgol about 11 years ago

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

posted by Mithgol about 11 years ago

@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?

posted by FWeinb about 11 years ago

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).

posted by Mithgol about 11 years ago

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.

posted by FWeinb about 11 years ago

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.

posted by cretz about 11 years ago

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.

posted by CooCooCaCha about 11 years ago

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).

posted by Mithgol about 11 years ago

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.

posted by Mithgol about 11 years ago

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.
posted by Starcounter-Jack about 11 years ago

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.

posted by jcrubino about 11 years ago

+1

posted by Rameshv about 11 years ago

"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?

posted by tbranyen about 11 years ago

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
posted by chriddyp about 11 years ago

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

posted by damianb about 11 years ago

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

posted by guybrush almost 11 years ago

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.

posted by jure almost 11 years ago

+1

posted by warpech almost 11 years ago

+1

posted by yuriyp over 10 years ago

+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?

posted by opensourcegeek over 10 years ago

:+1:

posted by buschtoens over 10 years ago

+1

posted by pirog over 10 years ago

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

posted by michahell over 10 years ago

+1 as a step towards a replacement of phantomjs.

posted by johntitus over 10 years ago

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

posted by michalliu over 10 years ago

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.

posted by gstack over 10 years ago

+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

posted by DinisCruz over 10 years ago

+1 so I can use Web Audio API from node

posted by simonbreak over 10 years ago

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

posted by sheerun over 10 years ago

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.

posted by Sesshomurai over 10 years ago

@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)

posted by DinisCruz over 10 years ago

@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.

posted by Sesshomurai over 10 years ago

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.

posted by EthraZa over 10 years ago

@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.

posted by loveencounterflow over 10 years ago

@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.

posted by Sesshomurai over 10 years ago

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

posted by vsemozhetbyt about 10 years ago

+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.

posted by dotproto about 10 years ago

Looking forward for this feature.

posted by MContagious about 10 years ago

+1

posted by jonnysamps about 10 years ago

+1

posted by jwerle about 10 years ago

+1

posted by xenyou about 10 years ago

+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.

posted by chrisdack about 10 years ago

+1

posted by iradul about 10 years ago

+1

posted by drom about 10 years ago

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

posted by michalliu about 10 years ago

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
posted by edwardchanjw about 10 years ago

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.

posted by polpo about 10 years ago

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.

posted by BenoitZugmeyer about 10 years ago

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:

posted by edwardchanjw about 10 years ago

+1

posted by monolithed about 10 years ago

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

posted by vsantosu almost 10 years ago

@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:

posted by steelbrain almost 10 years ago
posted by BenoitZugmeyer almost 10 years ago

Thanks,The problem has been solved

posted by yunqingmo almost 10 years ago

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?

posted by twilly86 over 9 years ago

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

posted by JohnnyMarnell over 9 years ago

+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.

posted by CaptEmulation about 9 years ago

+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.

posted by oknoorap about 9 years ago

+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.

posted by jssuttles about 9 years ago

+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.

posted by FeepingCreature about 9 years ago

+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

posted by ChrisWoodlief about 9 years ago

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.

posted by jssuttles about 9 years ago

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

posted by jssuttles about 9 years ago

+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 ?

posted by Cooker-Monster almost 9 years ago

:+1:

posted by ben-page almost 9 years ago

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:

posted by buschtoens almost 9 years ago
posted by vsemozhetbyt almost 9 years ago

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 notifications@github.com 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 .

posted by rogerwang almost 9 years ago

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

posted by damoebius almost 9 years ago

Problem solved!

Sent from my Verizon Wireless 4G LTE smartphone

-------- Original message -------- From: vsemozhetbyt notifications@github.com Date: 06/24/2016 6:38 AM (GMT-05:00) To: "nwjs/nw.js" nw.js@noreply.github.com Cc: Sesshomurai darren@ontrenet.com, Mention mention@noreply.github.com 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.

posted by Sesshomurai almost 9 years ago

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 :-)

posted by SantoshSrinivas79 almost 9 years ago

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.

posted by rogerwang over 8 years ago

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.

posted by polpo over 8 years ago

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

posted by drom over 8 years ago

@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

posted by damoebius over 8 years ago

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?

posted by tentone over 8 years ago

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)
posted by tekrat over 8 years ago

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.)

posted by Mithgol over 8 years ago

@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.

posted by jonnermut over 8 years ago

(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.

posted by kardianos over 8 years ago

Why can't you use Phantomjs?

posted by julmot over 8 years ago

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.

posted by kardianos over 8 years ago

Can you please share your Phantomjs settings?

posted by julmot over 8 years ago

@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.

posted by kardianos over 8 years ago

PhantomJS maintainer stepping down after Google's headless Chromium announcement

posted by damoebius about 8 years ago

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

posted by drom about 8 years ago

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.

posted by rogerwang about 8 years ago
posted by rogerwang almost 8 years ago

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

posted by VasiliyIsaichkin almost 8 years ago

@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

posted by wanjochan almost 8 years ago

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.

posted by tolrtd almost 8 years ago

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

posted by dmouton over 7 years ago

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.

posted by alFReD-NSH about 7 years ago

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

posted by IssueHuntBot over 6 years ago

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

posted by IssueHuntBot over 6 years ago

Any update on the issue?

posted by drom about 6 years ago

@0maxxam0 has funded $2.00 to this issue.


posted by IssueHuntBot about 6 years ago

Fund this Issue

Only logged in users can fund an issue

Pull requests

Recent activities

0maxxam0 funded 2.00 for nwjs/nw.js# 769
about 6 years ago
loadbalance-sudachi-kun funded 256.00 for nwjs/nw.js# 769
over 6 years ago