WebKitGTK+ 2.8.0

We are excited and proud of announcing WebKitGTK+ 2.8.0, your favorite web rendering engine, now faster, even more stable and with a bunch of new features and improvements.

Gestures

Touch support is one the most important features missing since WebKitGTK+ 2.0.0. Thanks to the GTK+ gestures API, it’s now more pleasant to use a WebKitWebView in a touch screen. For now only the basic gestures are implemented: pan (for scrolling by dragging from any point of the WebView), tap (handling clicks with the finger) and zoom (for zooming in/out with two fingers). We plan to add more touch enhancements like kinetic scrolling, overshot feedback animation, text selections, long press, etc. in future versions.

HTML5 Notifications

notifications

Notifications are transparently supported by WebKitGTK+ now, using libnotify by default. The default implementation can be overridden by applications to use their own notifications system, or simply to disable notifications.

WebView background color

There’s new API now to set the base background color of a WebKitWebView. The given color is used to fill the web view before the actual contents are rendered. This will not have any visible effect if the web page contents set a background color, of course. If the web view parent window has a RGBA visual, we can even have transparent colors.

webkitgtk-2.8-bgcolor

A new WebKitSnapshotOptions flag has also been added to be able to take web view snapshots over a transparent surface, instead of filling the surface with the default background color (opaque white).

User script messages

The communication between the UI process and the Web Extensions is something that we have always left to the users, so that everybody can use their own IPC mechanism. Epiphany and most of the apps use D-Bus for this, and it works perfectly. However, D-Bus is often too much for simple cases where there are only a few  messages sent from the Web Extension to the UI process. User script messages make these cases a lot easier to implement and can be used from JavaScript code or using the GObject DOM bindings.

Let’s see how it works with a very simple example:

In the UI process, we register a script message handler using the WebKitUserContentManager and connect to the “script-message-received-signal” for the given handler:

webkit_user_content_manager_register_script_message_handler (user_content, 
                                                             "foo");
g_signal_connect (user_content, "script-message-received::foo",
                  G_CALLBACK (foo_message_received_cb), NULL);

Script messages are received in the UI process as a WebKitJavascriptResult:

static void
foo_message_received_cb (WebKitUserContentManager *manager,
                         WebKitJavascriptResult *message,
                         gpointer user_data)
{
        char *message_str;

        message_str = get_js_result_as_string (message);
        g_print ("Script message received for handler foo: %s\n", message_str);
        g_free (message_str);
}

Sending a message from the web process to the UI process using JavaScript is very easy:

window.webkit.messageHandlers.foo.postMessage("bar");

That will send the message “bar” to the registered foo script message handler. It’s not limited to strings, we can pass any JavaScript value to postMessage() that can be serialized. There’s also a convenient API to send script messages in the GObject DOM bindings API:

webkit_dom_dom_window_webkit_message_handlers_post_message (dom_window, 
                                                            "foo", "bar");

 

Who is playing audio?

WebKitWebView has now a boolean read-only property is-playing-adio that is set to TRUE when the web view is playing audio (even if it’s a video) and to FALSE when the audio is stopped. Browsers can use this to provide visual feedback about which tab is playing audio, Epiphany already does that 🙂

ephy-is-playing-audio

HTML5 color input

Color input element is now supported by default, so instead of rendering a text field to manually input the color  as hexadecimal color code, WebKit now renders a color button that when clicked shows a GTK color chooser dialog. As usual, the public API allows to override the default implementation, to use your own color chooser. MiniBrowser uses a popover, for example.

mb-color-input-popover

APNG

APNG (Animated PNG) is a PNG extension that allows to create animated PNGs, similar to GIF but much better, supporting 24 bit images and transparencies. Since 2.8 WebKitGTK+ can render APNG files. You can check how it works with the mozilla demos.

webkitgtk-2.8-apng

SSL

The POODLE vulnerability fix introduced compatibility problems with some websites when establishing the SSL connection. Those problems were actually server side issues, that were incorrectly banning SSL 3.0 record packet versions, but that could be worked around in WebKitGTK+.

WebKitGTK+ already provided a WebKitWebView signal to notify about TLS errors when loading, but only for the connection of the main resource in the main frame. However, it’s still possible that subresources fail due to TLS errors, when using a connection different to the main resource one. WebKitGTK+ 2.8 gained WebKitWebResource::failed-with-tls-errors signal to be notified when a subresource load failed because of invalid certificate.

Ciphersuites based on RC4 are now disallowed when performing TLS negotiation, because it is no longer considered secure.

Performance: bmalloc and concurrent JIT

bmalloc is a new memory allocator added to WebKit to replace TCMalloc. Apple had already used it in the Mac and iOS ports for some time with very good results, but it needed some tweaks to work on Linux. WebKitGTK+ 2.8 now also uses bmalloc which drastically improved the overall performance.

Concurrent JIT was not enabled in GTK (and EFL) port for no apparent reason. Enabling it had also an amazing impact in the performance.

Both performance improvements were very noticeable in the performance bot:

webkitgtk-2.8-perf

 

The first jump on 11th Feb corresponds to the bmalloc switch, while the other jump on 25th Feb is when concurrent JIT was enabled.

Plans for 2.10

WebKitGTK+ 2.8 is an awesome release, but the plans for 2.10 are quite promising.

  • More security: mixed content for most of the resources types will be blocked by default. New API will be provided for managing mixed content.
  • Sandboxing: seccomp filters will be used in the different secondary processes.
  • More performance: FTL will be enabled in JavaScriptCore by default.
  • Even more performance: this time in the graphics side, by using the threaded compositor.
  • Blocking plugins API: new API to provide full control over the plugins load process, allowing to block/unblock plugins individually.
  • Implementation of the Database process: to bring back IndexedDB support.
  • Editing API: full editing API to allow using a WebView in editable mode with all editing capabilities.

28 comments

  1. @LRN There will be fixes, and new releases of 2.4 and 2.6 branches, but nothing planned for 2.2. Maintaining 3 branches is already a lot of work for the people we are, I recommend you to update to 2.4 branch.

  2. @carlos garcia campos
    I can’t, it’s not possible to build webkitgtk newer than 2.2.6 with gcc on Windows. At some point someone submitted patches to fix this for 2.3 or something like that, but then CMake migration happened, and the patches became obsolete.

  3. Sanity check: you don’t allow web pages to access the rendered contents of the page in any way, such that they’d have access to the image showing through a transparent area, right?

  4. Anonymous :

    Sanity check: you don’t allow web pages to access the rendered contents of the page in any way, such that they’d have access to the image showing through a transparent area, right?

    Right. We have always filled the backing store with a color before rendering the contents in the web process, either with white opaque, or with the color specified by the web page. So, the main difference is that now we have API to use a different color to fill the backing store in the case the web page doesn’t specify one. If the color you set is transparent, the backing store is cleared before the page contents are rendered in the web process. That transparent surface containing the page rendered is then painted into the web view. I’m not sure I’ve answered your question, though.

  5. @carlos garcia campos
    The patches in question are https://bugs.webkit.org/show_bug.cgi?id=133028 and https://bugs.webkit.org/show_bug.cgi?id=132856 . These, along with the patches from Fedora ( http://pkgs.fedoraproject.org/cgit/mingw-webkitgtk.git/ ) allows 2.4 to be built. And with https://bugs.webkit.org/show_bug.cgi?id=130122 it actually works.

    This might sound like a good thing (and i guess it is), but note that:

    1) Various features (webgl, accelerated composition) have to be disabled; enabling them requires more patches and extra dependencies (i.e. i wouldn’t say that “2.4.x works 100%”)

    2) WebKit2 API has to be disabled completely. AFAIU, this is due to its use of sockets for IPC, which does not have a Windows port (at all). Since WebKit1 API is not going to be available past 2.4.x, this makes 2.4.x the last WebKitGTK that builds on W32. Again.

    This situation makes WebKitGTK a *very* risky choice as a dependency for cross-platform projects.

    As for the transparent pages and access, i think the Anonymous means that some pages use JS to access the page as it is rendered (as an image), YouTube video rightclick menu being a prominent example. NoScript will warn you about such things. If your other applications or your desktop are showing through, will the page be able to see them as well? I.e. does the page JS get the window contents *before* WM composits them, or *after*?

  6. LRN :

    @carlos garcia campos
    The patches in question are https://bugs.webkit.org/show_bug.cgi?id=133028 and https://bugs.webkit.org/show_bug.cgi?id=132856 . These, along with the patches from Fedora ( http://pkgs.fedoraproject.org/cgit/mingw-webkitgtk.git/ ) allows 2.4 to be built. And with https://bugs.webkit.org/show_bug.cgi?id=130122 it actually works.

    Ok, I’ll look at those before the next 2.4 release.

    LRN :

    This might sound like a good thing (and i guess it is), but note that:

    1) Various features (webgl, accelerated composition) have to be disabled; enabling them requires more patches and extra dependencies (i.e. i wouldn’t say that “2.4.x works 100%”)

    2) WebKit2 API has to be disabled completely. AFAIU, this is due to its use of sockets for IPC, which does not have a Windows port (at all). Since WebKit1 API is not going to be available past 2.4.x, this makes 2.4.x the last WebKitGTK that builds on W32. Again.

    Yes, I think we could be smarter and disable the features not supported automatically when win32 is detected on configure.
    I would love to see WebKit2 ported to windows, but unfortunately we don’t have enough people, nor even the knowledge to work on that. We happily accept patches, of course.

    LRN :

    This situation makes WebKitGTK a *very* risky choice as a dependency for cross-platform projects.

    Why? we are going to maintain the 2.4 branch as long as WebKit2 doesn’t work on windows. It’s not like other branches that end up dying, but of course don’t expect major changes in that branch, because WebKit1 is deprecated. Again, any help adding windows support to WebKit2 would be welcome.

    LRN :

    As for the transparent pages and access, i think the Anonymous means that some pages use JS to access the page as it is rendered (as an image), YouTube video rightclick menu being a prominent example. NoScript will warn you about such things. If your other applications or your desktop are showing through, will the page be able to see them as well? I.e. does the page JS get the window contents *before* WM composits them, or *after*?

    Oh, I see, I don’t know, I would have to test it, if there’s a test case I could use.

  7. How do we disable opengl composting and the like in the 2.8 series , I am using it on machine that doesn’t have gpu’s or video card and the software opengl takes much cpu.

  8. @Chris Greenwell
    Yes, if opengl libs are not found, accelerated compositing, webgl, etc. are all disabled. Maybe we could add an option to explicitly disable it even when opengl libs are installed, but sooner or later opengl will be a requirement and accelerated compositing mode the default (and only) one.

  9. @carlos garcia campos
    Again thanks for your reply. We could really use the switch and hope that it doesn’t get forced to use opengl , as on headless, gpu-less systems they will be forced to use software -mesa which is much more cpu usage for our use.

  10. Hi Carlos – Do you have any idea when Debian will begin packaging 2.8.x instead of 2.4.x? I’m really interested in the new touch support.

    Thanks – Neil

  11. @carlos garcia campos
    Ah, thank you very much! My problem was that I was looking at the “webkitgtk” source package, instead of “webkit2gtk”.

    (So now I need to investigate what browsers or browsing-capable applications there are in Debian that use webkit2gtk…)

  12. @carlos garcia campos
    A further question, if you don’t mind… Do I need to do anything in order to enable the touch-based panning, or is this enabled automatically?

    FYI I will be running webkit2gtk 2.8.3 inside the Epiphany browser (because it appears that’s the only Debian browser using webkit2gtk, so far) on X11 on a GTA04 phone (gta04.org).

    Thanks – Neil

  13. @carlos garcia campos
    Hi Carlos! I’m afraid I’m finding that panning is not working for me. When I touch and move my finger up, in order to scroll, all that happens is that text in the Epiphany window is selected. There is no scrolling.

    I hope you won’t mind some further questions, which I hope will help me to understand this further.

    1. I looked for “gtk_gesture_” in the 2.8.3 tarball, and only found uses of GtkGestureDrag and GtkGestureZoom. Is that as expected? Is it GtkGestureDrag that is used to implement finger scrolling? (I would have guessed GtkGesturePan, instead, but that is not in the source code at all.)

    2. I note “gtk_gesture_single_set_touch_only(GTK_GESTURE_SINGLE(m_gesture.get()), TRUE)”. How can I check that Gtk+ is correctly interpreting my device as being a touch device?

    3. You say that recent enough versions of Xorg and Gtk+ are needed. I have the versions that are currently in Debian testing – are those OK? Does this functionality rely on any particular Xorg drivers?

    Many thanks! – Neil

  14. @Neil Jerram : I’m not the poster, but I’ll try to reply anyway. The Xorg/GTK+ versions in Debian testing are surely more than enough. The feature does not require an specific driver, but the touchscreen driver must be capable of delivering touch events itself (xf86-input-evdev and xf86-input-libinput do). You should be able to check the capabilities with xinput list , I eg. see:

    $ xinput list
    ⎡ Virtual core pointer id=2 [master pointer (3)]
    ⎜ ↳ Virtual core XTEST pointer id=4 [slave pointer (2)]
    ⎜ ↳ SynPS/2 Synaptics TouchPad id=12 [slave pointer (2)]
    ⎜ ↳ TPPS/2 IBM TrackPoint id=13 [slave pointer (2)]
    ⎜ ↳ eGalax Inc. eGalaxTouch EXC7903-66v03_T1 id=9 [slave pointer (2)]
    ⎣ Virtual core keyboard id=3 [master keyboard (2)]
    ↳ Virtual core XTEST keyboard id=5 [slave keyboard (3)]
    ↳ Power Button id=6 [slave keyboard (3)]
    ↳ Integrated Camera id=10 [slave keyboard (3)]
    ↳ AT Translated Set 2 keyboard id=11 [slave keyboard (3)]
    ↳ Video Bus id=7 [slave keyboard (3)]
    ↳ ThinkPad Extra Buttons id=14 [slave keyboard (3)]
    ↳ Sleep Button id=8 [slave keyboard (3)]
    $ xinput list 9 | grep “touches”
    Max number of touches: 15

  15. Many thanks to you both!

    I wonder if the problem might be that my touchscreen is too jittery – I’ll look into that, and also `xinput list`, this evening.

  16. Do all of the following outputs look right?

    root@neo:~# xinput
    ⎡ Virtual core pointer id=2 [master pointer (3)]
    ⎜ ↳ Virtual core XTEST pointer id=4 [slave pointer (2)]
    ⎜ ↳ TSC2007 Touchscreen id=7 [slave pointer (2)]
    ⎣ Virtual core keyboard id=3 [master keyboard (2)]
    ↳ Virtual core XTEST keyboard id=5 [slave keyboard (3)]
    ↳ twl4030_pwrbutton id=6 [slave keyboard (3)]
    ↳ gpio-keys-incoming id=8 [slave keyboard (3)]
    ↳ gpio-keys id=9 [slave keyboard (3)]
    root@neo:~# xinput –list 2
    Virtual core pointer id=2 [master pointer (3)]
    Reporting 4 classes:
    Class originated from: 7. Type: XIButtonClass
    Buttons supported: 10
    Button labels: “Button Unknown” “Button Unknown” “Button Unknown” “Button Wheel Up” “Button Wheel Down” “Button Horiz Wheel Left” “Button Horiz Wheel Right” None None None
    Button state:
    Class originated from: 7. Type: XIValuatorClass
    Detail for Valuator 0:
    Label: Abs X
    Range: 0.000000 – 4095.000000
    Resolution: 0 units/m
    Mode: absolute
    Current value: 3023.000000
    Class originated from: 7. Type: XIValuatorClass
    Detail for Valuator 1:
    Label: Abs Y
    Range: 0.000000 – 4095.000000
    Resolution: 0 units/m
    Mode: absolute
    Current value: 704.000000
    Class originated from: 7. Type: XIValuatorClass
    Detail for Valuator 2:
    Label: Abs Pressure
    Range: 0.000000 – 4095.000000
    Resolution: 0 units/m
    Mode: absolute
    Current value: 0.000000

    root@neo:~# xinput –list 4
    Virtual core XTEST pointer id=4 [slave pointer (2)]
    Reporting 3 classes:
    Class originated from: 4. Type: XIButtonClass
    Buttons supported: 10
    Button labels: “Button Left” “Button Middle” “Button Right” “Button Wheel Up” “Button Wheel Down” “Button Horiz Wheel Left” “Button Horiz Wheel Right” None None None
    Button state:
    Class originated from: 4. Type: XIValuatorClass
    Detail for Valuator 0:
    Label: Rel X
    Range: -1.000000 – -1.000000
    Resolution: 0 units/m
    Mode: relative
    Class originated from: 4. Type: XIValuatorClass
    Detail for Valuator 1:
    Label: Rel Y
    Range: -1.000000 – -1.000000
    Resolution: 0 units/m
    Mode: relative

    root@neo:~# xinput –list 7
    TSC2007 Touchscreen id=7 [slave pointer (2)]
    Reporting 4 classes:
    Class originated from: 7. Type: XIButtonClass
    Buttons supported: 5
    Button labels: “Button Unknown” “Button Unknown” “Button Unknown” “Button Wheel Up” “Button Wheel Down”
    Button state:
    Class originated from: 7. Type: XIValuatorClass
    Detail for Valuator 0:
    Label: Abs X
    Range: 0.000000 – 4095.000000
    Resolution: 0 units/m
    Mode: absolute
    Current value: 3023.000000
    Class originated from: 7. Type: XIValuatorClass
    Detail for Valuator 1:
    Label: Abs Y
    Range: 0.000000 – 4095.000000
    Resolution: 0 units/m
    Mode: absolute
    Current value: 704.000000
    Class originated from: 7. Type: XIValuatorClass
    Detail for Valuator 2:
    Label: Abs Pressure
    Range: 0.000000 – 4095.000000
    Resolution: 0 units/m
    Mode: absolute
    Current value: 0.000000

    root@neo:~# evtest
    No device specified, trying to scan all of /dev/input/event*
    Available devices:
    /dev/input/event0: TSC2007 Touchscreen
    /dev/input/event1: twl4030_pwrbutton
    /dev/input/event2: twl4030:vibrator
    /dev/input/event3: gpio-keys
    /dev/input/event4: gpio-keys-incoming
    Select the device event number [0-4]: 0
    Input driver version is 1.0.1
    Input device ID: bus 0x18 vendor 0x0 product 0x0 version 0x0
    Input device name: “TSC2007 Touchscreen”
    Supported events:
    Event type 0 (EV_SYN)
    Event type 1 (EV_KEY)
    Event code 330 (BTN_TOUCH)
    Event type 3 (EV_ABS)
    Event code 0 (ABS_X)
    Value 2896
    Min 0
    Max 4095
    Event code 1 (ABS_Y)
    Value 3195
    Min 0
    Max 4095
    Event code 24 (ABS_PRESSURE)
    Value 0
    Min 0
    Max 4095
    Properties:
    Testing … (interrupt to exit)
    C-c C-c
    root@neo:~#

    Thanks – Neil

  17. After reviewing a lot of code and web pages, I’m pretty sure the problem is that

    gtk_gesture_single_set_touch_only(GTK_GESTURE_SINGLE(m_gesture.get()), TRUE)

    line, combined with the fact that my touchscreen + input stack is not generating touch events. I believe inability to generate touch events is shown by the absence of any XITouchClass information in the xinput output above.

    It would be great if someone could confirm or deny whether that makes sense. In parallel I may try nobbling that line somehow, and see if it makes finger scrolling work for me.

  18. @Neil Jerram : Seeing the output for your touchscreen (“xinput list 7” above), then this is definitely because of your input driver not using touch events, these must be explicitly sent by the input driver (eg. http://cgit.freedesktop.org/xorg/driver/xf86-input-libinput/tree/src/libinput.c#n868) for GTK+ to know this is a touchscreen, otherwise it is just a “pointer” device to GTK+.

    The long term solution would be updating the input driver to something that reports touch events. For the short term, and seeing you have no further pointing devices, you could probaby get away setting the GTK_TEST_TOUCHSCREEN=1 envvar somewhere in your environment, that will trick GTK+ into emulating single-touch input out of pointer events, which is what we are getting here in the end.

Leave a Reply

Your email address will not be published. Required fields are marked *


*