mcatanzaro at igalia.com
Tue Sep 12 07:56:10 PDT 2017
On Tue, Sep 12, 2017 at 9:29 AM, Ludovic Brenta
<ludovic at ludovic-brenta.org> wrote:
> I am extending a multi-million-line-of-code application written
> in Ada with a new WebKitGTK browser window, using the WebKit2GTK
> After reading  and  I am trying to expose an Ada (or C,
>  http://www.davedoesdev.com/wrapping-webkit-part-1-gtk+-vala/
This first blog post is very old and a trap (see below). The second one
might be useful, but notice the warning that it has omitted memory
management and error handling....
> The gist of it is: attach a callback to the "load-changed" signal
> of the WebKitWebView. If the Load_Event is "finished", create a
> new function object (by calling JSObjectMakeFunctionWithCallback);
> add to the global object of the WebView a new property whose name
> is the function object.
This is your problem, because in WebKit2 the JSC API is not really
useful in the UI process. You want to use it in the web process
instead. See  for some documentation of how to write a web
extension. You basically compile your web process code into a shared
object that will be dlopened by the web process at runtime. Then you
can communicate between the web process and the UI process using any
form of IPC you prefer (we recommend D-Bus). It's a lot of work to set
up, unfortunately, but the advantage is your whole application does not
crash when the web process crashes.
> If I try to call the function thus exported (and aptly named
> ReferenceError: Can't find variable: exported
> I am suspecting that I'm attaching the property to the wrong
> global object. Since I'm stuck with Red Hat Enterprise Linux
> and the webkitgtk3-devel-2.4.9-6.el7.x86_64 package, I have no
> debugging info available for WebKit itself (only for the host
> application), so I can't easily debug what's happening.
Surely there should be debuginfo available... do you not see any
results from 'debuginfo-install webkitgtk3'?
> All I
> and that Exceptions remain null after the call to Set_Property.
> Am I doing something wrong? Is this feature even supported with
> WebKit2 or should I switch to the deprecated WebKit 1 that does not
> use a separate process?
You should definitely not use the WebKit1 API, unless you are content
to target RHEL 7 forever.
More information about the webkit-gtk