I would like to write a summary of the work we have been doing in wpe-android in the last year, where this port of WPE comes from and where it is now. The details deserve their own posts and I plan to write more about specifics. Now that WPEPlatform is going to be released as stable in the next few days seems a good example of how to use it, we have been actively using to test the API in the last months.
wpe-android started in 2017 as an experiment of running WPE WebKit on Android. The engine communicated with the system through libwpe, the abstraction library WPE used before WPEPlatform. It used an Android backend living in its own separate library, libWPEBackend-android, and the Java side exposed the API with the WPEView, WPEContext and the other proxy classes. It was a useful experiment. It was enough to show the engine running in a phone. The problem is a good part of the Android specific code, in particular the rendering path sending buffers to a SurfaceControl, was placed in the application side instead of in the platform layer of the engine. Also Android developers had to learn an API that did not look like anything they already had in the platform, it was close to the Linux WPE API.
Since then we have been implementing WPEPlatform, a new platform abstraction that has been added inside WebKit. It gave us the chance to fix both problems at the same time. During this spring we implemented a proper Android backend on top of it, so now the display system of Android looks like a regular WPE platform to the engine. WPEDisplayAndroid registers as a display extension point and sets up an AHardwareBuffer configuration, WPEToplevelAndroid follows the ANativeWindow lifecycle from the SurfaceHolder callbacks, WPEViewAndroid submits the frames with SurfaceTransaction and explicit sync fences, and WPEScreenSyncObserverAndroid uses AChoreographer so the engine renders aligned with vsync. On top of that we added a thin JNI bridge that mirrors the WebKit and WPEPlatform objects in Java, and a new convenience API that looks like android.webkit.WebView, with WebView, WebContext, WebSettings, CookieManager, WebViewClient and WebChromeClient. This way people can reuse the Android documentation and the knowledge they already have instead of learning something new.
We ported the tools used to the new API, the MiniBrowser, the media player sample, the instrumented tests and WebDriver. We were able to delete the legacy stack.
After that, the only thing keeping libwpe in the build was process management: Android cannot simply fork() and exec(), since auxiliary processes are Android services that need to be launched explicitly. To solve this, we implemented a WPEProcessManager API for WPEPlatform inside WebKit, which landed upstream and is now used by the port.
With that in place, we were able to remove libwpe entirely, and WPE WebKit now talks to Android the same way it talks to any other platform. In parallel, we kept improving other parts of the platform, implementing new API features and fixing bugs along the way. One notable example is a scroll jank issue on the Mali driver, which was resolved largely thanks to the Skia DDL architecture upstream (a story that deserves its own write-up).
There is still plenty work to do, for our small team this project is still a very valuable experiment and we would like to keep exploring the options.
The code is here if you want to give it a try or help:
I will try to write about our work around WebKit and wpe-android in more detail in the next weeks, hopefully the next post will not take another fourteen years …

Last week I attended the European WebKit Hackathon, the organization and the location were awesome (Bucharest). We had the opportunity to meet with other WebKit teams and know about their work and plans. Adobe, Samsung, Intel, University of Szeged and Igalia were there represented. And of course we spend time hacking in some topics where we could collaborate together. Considering all the specifications the Adobe people are pushing (CSS Regions, CSS Exclusions, CSS Shaders, etc.) it was a great opportunity to try some of their work in WebKitGTK+ and help them with some compilation and testing tricks in the port. I think we can continue helping with some of those specs and make WebKitGTK+ a good port for checking web framework new features.
We also could catch up with Intel EFL hacker Dominik Röttsches. EFL port uses a lot of code from the WebKitGTK+ and our goals are quite similar so it is always good we can spend sometime hacking together. Ossy from the Szeged University explained their testing infrastructure and methods for the WebKitQt port, very interesting points about how to deal with a big project like WebKit.
I would like to thank organization and I hope we can make it next year.
Also in the last year we celebrated Igalia’s 10th anniversary, the truth is that we started working on the project in the beginning of 2001, so I have been working here for more than 11 years already. We use the legal date to celebrate it for technical reasons. It has been a very long trip already, and I feel I’ve changed a lot because all the experiences we had, good and bad. Best thing is that I was able to work in a challenging project with great people, and learn a lot from them.
I think that was all for the wrap-up, probably I’m missing something someone will remind me, sorry about it Internet. I almost forgot, another interesting experience was the time off I had in the beginning of this year, for a little bit more than one month, it was a good way to celebrate the 10 years working.
The 3.6 release is going to bring the WebKit2 support and we will try to have Epiphany integration ready at that point, that would close a great development cycle. I’ll try to blog more from now on and give more information about this (/me smiles), probably explaining some of that work more in detail would make a lot of sense.
By the way, I’ll attend GUADEC this year again, see you there.
It is always a good moment to catch up with the people in the WebKit community and think about your position and motivation in the project. I would like to thank the Apple team for making it happen. We talked about WebKit2, not all the decisions are made and things like C API could change its design in the future, stay tuned. We are pushing WebKit2GTK+ and now it is more complete and it is easier to contribute to. We even have landed the test runner patch, and now running tests is possible.
We also did some hacking, fixed some issues in WebKitGTK and prepared 1.4.0 release, the new stable release that includes most of the work we have done the last year. All the tests that are passing now have made this new stable release a better library, it is easy to realize about it after spending some time using the browser. It is clear that software needs taking care of the small details, if you want someone to use it, and that takes time and effort. Our team in Igalia has made a good work creating the best WebKitGTK+ release so far. We have come from a big file with skipped tests to more than 22.000 tests passed and that is a huge difference that the final user can check.
I hope more people can enjoy the software and contribute to the code, this is one of the reasons free software rocks.
Basic feature of this new API is that it uses a split process architecture, the UI is separated from the web content in a different process. It means a lot of pros and some cons, currently at Igalia we are ready to face the cons so we can get all the pros, creating more stable and responsive applications using the port. Our plan is to add the complete support and make Epiphany work with it at some point.
We are also adding WebKitTestRunner support which will help a lot with the development. Besides the C API we are implementing a GTK+ friendly API, basically we are using the WebKit1 API over the WebKit2 C API, so you can even test it with the GtkLauncher and your own GNOME application easily.
Of course we are not going to forget about all the gardening work we are doing, maintaining, releasing and improving the core GTK+ port.
The code and APIs are still development status, there is still a lot of work to do, so just use them for testing purposes, this is just the initial step and we hope after this a lot of people can contribute to make the port rock even more.
It has been a very intense week, we are all tired but I think all the energy spent in the work and discussions during this week has paid off in the end. We have worked in a lot of topics: rendering (performance, leaks, WebGL patches), cleaning tests and bots, networking, JSC, Epiphany, a11y support, gstreamer, plugins, etc.. And we have crossed off a lot of things from the TODO list.
Thanks to everybody that helped to make this real and see you all the next year.
]]>In this post I’ll be talking about the shadows rendering in WebKitGTK+. If you are not interested in the details skip the rest of the post, the summary is: yes, shadows are not a problem anymore in the usual cases for WebKitGTK+, and we plan to improve even more the situation.
CSS, SVG and HTML5 Canvas specifications allow to render shadows around elements. This is a small mess, as all the three standards did not pay much attention to each other when defining about the shadows API, so now we have different APIs and some confusion for the implementors. We could check it after having to solve some issues in the current blur algorithm, actually I even proposed a change to the HTML5 spec trying to help clarifying it. The main problem with these shadows is that huge boxes could add visually nice offset shadows, like what happens in identi.ca, causing huge computations to blur a big rectangle as the recommended algorithm basically approximates a gaussian blur using 3 box blurs. Gtk and Qt ports use the SVG implementation of this algorithm, coded inside WebKit because neither cairo nor Qt implement this filter; Chrome/Skia does less box blurs, it is faster but it gets poorer results in my opinion. Firefox also uses the 3 box blurs as recommended in SVG and tries to reduce the area as much as possible using clipping.
When we profiled this problem we could easily spot a couple of issues that could be solved: the algorithm is using C++ objects instead of accessing directly to the pixels to operate, and it is copying the surfaces in memory more than required. A patch fixing these issues showed a big improvement, that is nice but still not enough to get good user experience. Calculating the destination value for every pixel is still very costly for huge rectangles, so the best option seemed to be to try to avoid the blurring as much as possible instead of just improving the algorithm. The options: clipping and reducing even more using a smaller shadow to create a big one using tiling (for rectangles which are the main use case). We created both patches both patches but after the tests the result was that just the tiling one was enough to fix the main uses cases like identi.ca, even with the issues in the blur algorithm and not clipping, the reduction in those cases fixed the main issue we were trying to fix. Of course we are interested in those patches and we are working to integrate a better algorithm because we want all the shadows to work better.
By the way, our WebKit team in Igalia has defined a wiki with our goals with regard to rendering, you can check them and propose us other ideas or discuss them, we are very interested in your experience and feedback using WebKitGTK+
Regarding software, we had the incredible opportunity to meet with a lot of WebKit engineers in the WebKit Contributors Meeting, it was very interesting to attend to the discussions and comment about the current situation of the project with the people there. Personally I would stress the debates about: WebKit2, Javascript engine performance and hardware acceleration drawing. I’ve also spend some time with Eric creating a version of the new-run-webkit-tests for Gtk+, I still have to check the patch and upload it. We also participated in the green bots hackathon, which allowed Gtk+ bots to enter in the core bots group, it took a little bit more time but now it should be easier to control the bots. Related with WebKit we also met some people in the bay are that are using WebKitGTK+, it is nice to check how the work we are doing is useful for those products.
I’ve also attended the Linux Collaboration Summit (just after the WebKit Meeting), it was not a bad experience, Google gave us a Nexus One after all. I was at the MeeGo workgroup where Nokia and Intel presented their agendas for the platform. I also was at the Desktop workgroup, the main topic was desktop technologies and the integration with Internet services, it is going to be interesting to check how the desktop will evolve to integrate Internet services, and what role free software plays in that environment.
Of course I have to mention I really enjoyed the city, we did not have much time but Martin helped us to discover very nice places and food.
[ # ] backend test min(s) median(s) stddev. count [ 0] null epiphany 0.644 0.652 2.06% 6/6 [ 0] gl epiphany 7.121 8.770 8.91% 15/15 [ 0] skia epiphany 2.106 2.110 0.11% 5/6 [ 0] xlib epiphany 1.874 1.903 1.41% 5/6 [ 0] image epiphany 2.154 2.180 1.09% 6/6 [ 0] image16 epiphany 3.721 3.752 0.59% 6/6
If this is correct we have to look inside WebKit for improvements, which means we have to review the rendering process carefully.
I would like to add that cairo-trace is an awesome tool, Cairo people deserve a lot of kudos for implementing it. I will use cairo-trace to check the tiled backing store and how the solution of the form controls rendering behaves with regard to performance.
Regarding the other part of the topic, next week some of us will be in San Francisco for the Webkit meeting, we will also attend the Linux Collaboration Summit and meet some people there; so if you are in the bay area and you want to have a drink just sent us an email. With the last WebKit2 announcement I think it would be a very interesting meeting.
I almost forgot, our WebKit team in Igalia has grown and we have more motivated people working with us (currently Xan, Philippe, Sergio, Mario, Juanjo and me, and Diego doing his internship), this is good because we could work in more interesting topics inside the project.