Phantomjs on Ubuntu 10.04 without xvfb

Affichage de 117 messages sur 17
Phantomjs on Ubuntu 10.04 without xvfb Jani Kajala 09/01/12 03:03
Hi,

Is there any step-by-step style instructions for building Phantomjs on Ubuntu 10.04 to run without xvfb?

I'd like to build from bleeding edge version since I'd need the latest POST fixes.

Thanks for any pointers :)


Jani

Re: Phantomjs on Ubuntu 10.04 without xvfb Jani Kajala 09/01/12 03:04
Ok now I saw this thread:

I will try those instructions as well.


Br,
Jani
Re: Phantomjs on Ubuntu 10.04 without xvfb Leo Franchi 09/01/12 05:27
Hello Jani,

Additionally, if you pass -qpa to the build-linux.sh script (along
with --qt-4.8) you'll get a lighthouse build of Qt. This means when
you run phantomjs you'll have to run it like so:

./phantomjs -platform Minimal <normal phantomjs args>

but you'll have a headless phantomjs with no X server or Xvfb needed.

cheers,
leo
Re: Phantomjs on Ubuntu 10.04 without xvfb Jani Kajala 09/01/12 11:47
Thanks Leo! I think the second option is "--headless", at least the build script seems to be checking if '--headless' is set as second param and then enables the -qpa which you pointed out. At least this did started to do something:

./build-linux --qt4.8 --headless


Thanks,
Jani
Re: Phantomjs on Ubuntu 10.04 without xvfb Leo Franchi 09/01/12 11:55
You are right! I should even check the code before I write, I already
forgot what I had named the parameter...

Let us know how it goes!

cheers,
leo

On Jan 9, 2:47 pm, Jani Kajala <kaj...@gmail.com> wrote:
> Thanks Leo! I think the second option is "--headless", at least the build
> script seems to be checking if '--headless' is set as second param and then
> enables the -qpa which you pointed out. At least this did started to do
> something:
>
> ./build-linux --qt4.8 --headless
>
> Thanks,
> Jani
>
>
>
>
>
>
>
Re: Phantomjs on Ubuntu 10.04 without xvfb Jani Kajala 09/01/12 17:17
I had one typo in the command line, it should have been --qt-4.8 --headless (so '-' was missing in the middle). However, I still got some errors related Qt/X11, see below

/usr/lib/gcc/i486-linux-gnu/4.4.3/../../../../lib/libQtWebKit.so: undefined reference to `QWidget::x11Info() const'
/usr/lib/gcc/i486-linux-gnu/4.4.3/../../../../lib/libQtWebKit.so: undefined reference to `QX11Info::depth() const'
/usr/lib/gcc/i486-linux-gnu/4.4.3/../../../../lib/libQtWebKit.so: undefined reference to `QX11Info::screen() const'
/usr/lib/gcc/i486-linux-gnu/4.4.3/../../../../lib/libQtWebKit.so: undefined reference to `QX11Info::display()'
/usr/lib/gcc/i486-linux-gnu/4.4.3/../../../../lib/libQtWebKit.so: undefined reference to 
....

Do I need some more flags or what packages I should apt-get install?

Thanks!


Jani
Re: Phantomjs on Ubuntu 10.04 without xvfb Xavi Beumala 10/01/12 01:34
Sorry I can't help, but I've found the topic very interesting. 

Should the performance be much better with a completely headless build compared to using xvfb?

many thanks
Xavi
--
Xavi Beumala

Re: Phantomjs on Ubuntu 10.04 without xvfb Martin Brochhaus 10/01/12 07:18
Sorry for a possibly stupid question, I'm not an expert about Qt...

I tried to install it on my webfaction server a while ago but after 2 hours or so they killed my process because it ate too much RAM. Now they have upped the RAM from 80MB to 256MB so I might give it another try, but this --headless options sounds like the build might go a lot faster as well.

My question is: Will I still be able to rasterize a site into a PDF?

Best regards,
Martin
Re: Phantomjs on Ubuntu 10.04 without xvfb Ariya Hidayat 10/01/12 08:22
> I had one typo in the command line, it should have been --qt-4.8 --headless
> (so '-' was missing in the middle). However, I still got some errors related
> Qt/X11, see below
>
> /usr/lib/gcc/i486-linux-gnu/4.4.3/../../../../lib/libQtWebKit.so: undefined
> reference to `QWidget::x11Info() const'
> /usr/lib/gcc/i486-linux-gnu/4.4.3/../../../../lib/libQtWebKit.so: undefined
> reference to `QX11Info::depth() const'
> /usr/lib/gcc/i486-linux-gnu/4.4.3/../../../../lib/libQtWebKit.so: undefined
> reference to `QX11Info::screen() const'
> /usr/lib/gcc/i486-linux-gnu/4.4.3/../../../../lib/libQtWebKit.so: undefined
> reference to `QX11Info::display()'
> /usr/lib/gcc/i486-linux-gnu/4.4.3/../../../../lib/libQtWebKit.so: undefined
> reference to

Maybe we need to patch those usages and remove the reference to
X11-specific stuff, when building in headless mode.

Leo, what do you think?


--
Ariya Hidayat, http://ariya.ofilabs.com

Re: Phantomjs on Ubuntu 10.04 without xvfb Ariya Hidayat 10/01/12 08:24
> I tried to install it on my webfaction server a while ago but after 2 hours
> or so they killed my process because it ate too much RAM. Now they have
> upped the RAM from 80MB to 256MB so I might give it another try, but this
> --headless options sounds like the build might go a lot faster as well.

You should really build locally in the same exact setup. Then upload
the resulting binary to your server.
Since building WebKit takes a lot of time and memory, this is the
recommended approach.

> My question is: Will I still be able to rasterize a site into a PDF?

Yes. PDF rasterizer works independently of everything else.


--
Ariya Hidayat, http://ariya.ofilabs.com

Re: Phantomjs on Ubuntu 10.04 without xvfb Leo Franchi 10/01/12 18:29
Sorry, traveling for work so a bit spotty with my responses. It's
definitely possible that there are some usages of X11 when compiling/
linking.. I must admit I didn't try building it on a server with no X
libs installed. So we could definitely patch that out when building --
headless.

That said, I can assure you it won't actually connect/use the X server
when *running* headless, so though you (right now, before we patch)
need X11 to link, it is not required to be running to run.

I can take a look, but probably not for a few weeks, so please don't
hesitate to wait for :)

cheers,
leo
Re: Phantomjs on Ubuntu 10.04 without xvfb Leo Franchi 10/01/12 18:39
Make sure you have fontconfig installed as usual, otherwise you'll get
issues with fonts---the modified Minimal platform plugin links
directly to fontconfig.

cheers,
leo
Re: Phantomjs on Ubuntu 10.04 without xvfb Jani Kajala 11/01/12 01:43
Thanks Leo for the tips. I managed to get normal phantom build working ok, so I guess I just ignore the headless stuff for now until official release.

This is how I got it compiled finally on Ubuntu 10.04:
sudo apt-get install libqt4-dev
sudo apt-get install qt4-qmake
cd phantomjs
qmake-qt4
make

Then I had to copy missing libs manually to /lib folder and run make again (there is bug in Qt 4.7 static build) but then it worked ok. :)

My main motivation for headless build would be to get rid of DISPLAY=:0 setup. I'm worried I cannot run multiple instances of phantom that easily (needs a separate display) if I'm running it through xvfb.


Br,
Jani
Re: Phantomjs on Ubuntu 10.04 without xvfb Ivan De Marino 11/01/12 10:29
Nice thread.

I might be wrong, but given that Xvfb simulates an XServer, there is nothing stopping you from running multiple PhantomJS instances against the same "simulated display". You shouldn't worry.

Ultimately, every instance will be a separate session against the same XServer, that is how a normal xserver works.

Did you try and got issues?

Ivan
--
Ivan De Marino
Coder, Technologist, Cook, Italian

blog.ivandemarino.me | www.linkedin.com/in/ivandemarino | twitter.com/detronizator
Re: Phantomjs on Ubuntu 10.04 without xvfb Jani Kajala 11/01/12 13:20
Ok,  I haven't tried multiple instances yet, but good to know it should work ok. :)


Jani
Re: Phantomjs on Ubuntu 10.04 without xvfb Andrea Giannangelo 21/02/12 16:15
What's better in terms of performance between running DISPLAY=:1 phantomjs with Xvfb always running and compiling phantomjs with "./build-linux --qt4.8 --headless"?
In my case I have to continuously run phantomjs, so it's not an occasional task.

Thanks in advance for replying :)
Re: Phantomjs on Ubuntu 10.04 without xvfb Ariya Hidayat 21/02/12 17:12
> What's better in terms of performance between running DISPLAY=:1 phantomjs
> with Xvfb always running and compiling phantomjs with "./build-linux --qt4.8
> --headless"?

The headless approach is in theory more efficient. However, the
difference is probably quite small compared to the actual tasks need
to be carried out by PhantomJS.


--
Ariya Hidayat, http://ariya.ofilabs.com