[wpe-webkit] Debugging options with wpewebkit

Adrian Perez de Castro aperez at igalia.com
Wed Oct 3 08:12:55 PDT 2018


Hello Aras,

On Wed, 03 Oct 2018 10:24:35 +0100, Aras Vaichas <aras.vaichas at gmail.com> wrote:
> Hi,
> 
> what are my Javascript debugging options with wpewebkit?   e.g. where can i
> see the output of console.log("my message"); ?
> 
> I'm using wpe on a standalone device that will not always have a network
> connection, and I would like to be able to collect logs on running devices.
> 
> Is there a way to redirect this console to a file, or the terminal that
> webkit is running in?

For console logs there are two possibilities. The simplest is to use
“webkit_settings_set_enable_write_console_messages_to_stdout()” [0] in your
application. The other option is more complicated, but would allow you to
do anything you want with the messages: you would need to implement a
WebKitWebExtension [1] and connect to the “console-message-sent” signal [2].

With the second option you could do amusing things like e.g. sending the
log to some log collector service or anything else you can imagine; but
unless you already have an extension, I would rather go with the simpler
option and redirect the output to a file (or just follow the messages on
the terminal).

> I understand there is the Webkit Inspector Server, and that I can start
> this by setting:
> export WEBKIT_INSPECTOR_SERVER=127.0.0.1:<port number>

The remote inspector is well supported since version 2.20.0. You need to
call “webkit_settings_set_enable_developer_extras()” [4] — otherwise the
“WEBKIT_INSPECTOR_SERVER” environment variable is ignored.

> Is there a Python/shell client that I could run on the target in order to
> collect the logs?
> 
> I tried running the Webkit Inspector, and connecting via netcat, but I
> wasn't able to get a response from the server. I imagine that I need to
> send it a JSON string to start subscribing to console logs, etc.

Please don't use netcat and don't try to roll your own client for the remote
inspector protocol. The protocol is not documented because it may change
between major versions (in practice, it has not changed since the times of the
WebKitGTK+ 2.18.x releases, though).

The client for the remote inspector service has to be an actual WebKit
inspector. Currently the easiest way is to use a similar version of a
WebKitGTK+ based browser, like the MiniBrowser or GNOME Web (Epiphany),
and use an URL of the form “inspector://<address>:<port>”. It will show
you a list of the inspectable Web views running on that host, each one of
them with a button that opens the inspector for it.

Right now, the version of the protocol spoken by the existing WPE WebKit
stable releases (2.20.x, 2.22.x) is the same for WebKitGTK+ between version
2.18.x and 2.22.x.

I hope this helps you debug your Web content. Please ask if you have any
more doubts.

Best regards,


-Adrián
 
---
[0] https://webkitgtk.org/reference/webkit2gtk/stable/WebKitSettings.html#webkit-settings-set-enable-write-console-messages-to-stdout
[1] https://webkitgtk.org/reference/webkit2gtk/stable/WebKitWebExtension.html
[2] https://webkitgtk.org/reference/webkit2gtk/stable/WebKitWebPage.html#WebKitWebPage-console-message-sent
[3] https://webkitgtk.org/reference/webkit2gtk/stable/WebKitSettings.html#webkit-settings-set-enable-developer-extras
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 195 bytes
Desc: not available
URL: <http://lists.webkit.org/pipermail/webkit-wpe/attachments/20181003/8a78a23f/attachment.bin>


More information about the webkit-wpe mailing list