Gtk3::WebKit on Ubuntu

After some really fantastic help & support from potyl I got Gtk3::WebKit to pass it's installation tests on Ubuntu 12.04 (precise, LTS).

Given that this requires one step that cpan/cpanm won't deal with out of the box, in the interests of documenting for the interwebs ...

Dependencies ... at least on Ubuntu 12.04:

aptitude install xvfb libgirepository1.0-dev pkg-config libgtk-3-dev libglib2.0-dev libglib2.0-0 gir1.2-webkit-3.0

Gtk3::WebKit isn't intended to run "headless", which might be one response to the comments on Web Scraping with Perl & PhantomJS about why you'd want to use PhantomJS instead.

However, having been enlighted by potyl, you CAN run it sorta pseudo headless, by using framebuffer display. And thus, no X server is required.

But this is the bit that's going to throw cpanm and naive installs off. Here's the voodoo that you do:

xvfb-run --server-args="-screen 0 1024x768x24" cpanm Gtk3::WebKit

or, if you're doing it old school

perl Makefile.PL
xvfb-run --server-args="-screen 0 1024x768x24" make test

For the benefit of Google et al:

*** Cannot use generic signal marshallers for signal insert-text of Gtk3::Editable unless gobject-introspection >= 1.33.10; any handlers connected to the signal might thus be invoked incorrectly

This one (appears) mostly harmless. You can ignore it. At least as far as installation goes, I've not gotten any further as yet.

(webkit.t:17298): Gtk-WARNING **: cannot open display:
t/webkit.t ..

That's what indicates there is no X Display and hence that you need to "wrap" things with xvfb-run if you want a "psuedo headless" frame buffer. (or run it under an X environment).

Any advice on what the right way to test for this is? Is it just checking that $ENV{DISPLAY} is set? Should that be a test, or in the module code? (I'm outta my depth on this point, so suggestions welcomed & I'll marshal them into a pull request if someone can point me in the right direction).

# Failed test 'use Gtk3::WebKit;'
# at t/webkit.t line 14.
# Tried to use 'Gtk3::WebKit'.
# Error: Typelib file for namespace 'WebKit', version '3.0' not found at /home/minty/perl5/perlbrew/perls/perl-5.16.2/lib/site_perl/5.16.3/i686-linux/Glib/Object/ line 92.
# BEGIN failed--compilation aborted at (eval 4) line 2.
Can't locate object method "new" via package "Gtk3::WebKit::WebView" (perhaps you forgot to load "Gtk3::WebKit::WebView"?) at t/webkit.t line 19.

This was the last hurdle I tripped up on, and is fixed by installing gir1.2-webkit-3.0 debian/ubuntu apt package.

cpan support rocks! potyl is awesome :) I <3 WebKit

Now, back to coding ....

ps. Gtk3::WebKit is, in turn, a dependency for WWW::WebKit, which is ultimately what I'm wanting to play with.

1 Comment

Leave a comment

About minty

user-pic I blog about Perl.