Tech —

Inside WebKit2: less waiting, less crashing

Get ready for WebKit2. The engine behind Safari and Chrome is going second- …

Anders Carlsson, an Apple employee, announced today on the WebKit mailing list an evolution of the WebKit project called WebKit2.

WebKit2's major aims are to bake both a "split process model" and a non-blocking API into the WebKit product—and by extension into Safari and any other client which takes advantage of the WebKit2 framework.

Google's Chrome browser launched in late 2008 with what's called a split process model, one in which each WebKit view runs in its own process. This means that when a bad plugin or a bug in the renderer causes an error, only that tab will crash instead of the entire browser.

IE8 has a similar system and Firefox is exploring one as well with Electrolysis. Apple's Safari 4 gained a related feature under Mac OS 10.6, which runs plugins like Adobe's Flash in a separate process and prevents the whole browser from crashing due to plugin faults. WebKit2 validates that approach by building support for split processes directly into the rendering engine.

Out of my way!

Another goal of WebKit2 is to implement the API to the framework in a completely non-blocking manner. This means that developers can hook into API methods with various kinds of callbacks in order to receive notifications from WebKit views.

For example, in my application I might want to load a webpage. I would call the loadWebsite method (which I just made up), pass it my URL, and additionally specify a callback method or block of code I would like to have attached to a particular event—say didFinishLoadForFrame (which I did not make up).

Whenever the webpage is done rendering, my code would be executed or my method called or pinged. This should result in much more responsive applications which hook into WebKit2. Theoretically, while the renderer is rendering something, the main application loop can move on to doing something else as requested by a user.

There are three techniques currently implemented to achieve this goal: notification-style client callbacks, policy-style client callbacks, and policy settings. A fourth method, code injection which can interact directly with the DOM, is proposed but not yet implemented. These are described in more detail on the project page.

The neat thing about Apple's implementation is that these abilities can be used and exploited by all downstream clients of WebKit2, since they are baked right into the framework—in contrast to the tack taken in Google Chrome. The end user of an application that uses WebKit2 will get a more stable product and developers can take advantage of these enhancements without having to implement their own solutions or jump through unnecessary hoops.

WebKit2 is currently supported on Windows and OS X—the two platforms on which Apple deploys Safari. Linux support is not mentioned at this time.

70 Reader Comments

The announcement link is a 404. I would like to know more details about the new API. There are some wrappers around webkit that make it effectively asynchronous already. For example if you use the GTK+ WebKitWebView, webkit runs off the main event thread and you get signals like resource-request-starting and load-finished, the latter of which has sub-statuses like WEBKIT_LOAD_FIRST_VISUALLY_NON_EMPTY_LAYOUT and WEKBIT_LOAD_FINISHED.

The existing API isn't as powerful as Gecko's HTTP observer model, so a move toward Gecko's API would be welcome.

The announcement link is a 404. I would like to know more details about the new API. There are some wrappers around webkit that make it effectively asynchronous already. For example if you use the GTK+ WebKitWebView, webkit runs off the main event thread and you get signals like resource-request-starting and load-finished, the latter of which has sub-statuses like WEBKIT_LOAD_FIRST_VISUALLY_NON_EMPTY_LAYOUT and WEKBIT_LOAD_FINISHED.

The existing API isn't as powerful as Gecko's HTTP observer model, so a move toward Gecko's API would be welcome.

I was wondering how this non-blocking API is different from the current. Right now I use WebView's -(void)loadRequest:(NSURLRequest *)request and get a -(void)webView:(WebView *)sender didFinishLoadForFrame:(WebFrame *)frame when it finishes.

OS X has consistently been cited as having around 10% market share, and that's rising. Linux, on the other hand, has had less than 1% share - even after the Linux netbook trend started. Nevermind that OS X has a longer support lifecycle than any distro of Linux and a more stable set of APIs and driver interfaces to boot.

It's interesting the dichotomy between accusations of Apple being closed and proprietary as in the iPhone ecosystem or being strict on patents and yet Apple also makes great contributions for the open source community or donating standards like Mini DisplayPort which ultimately enabled ATI's Eyefinity 6 graphics card to accommodate 6 display connectors. Apple might be focused on making money, but they do seem to genuinely care about pushing technology forward whether by tight control or open contributions.

It's interesting they don't mention the iPhone as a supported platform for WebKit2, so I guess it won't be coming with iPhone 4.

It's interesting to see Apple implement a feature into WebKit that Google already has. Apple is of course administering WebKit, and the project leads are all Apple employees. But Google has not only been using WebKit, their engineers also contributed to the project. I know google is using only WebCore and not the WebKit API for Chrome, but still I'm curios if google did contribute anything to WebKit2, or if Apple engineers did it on their own.

If you read Arstechnica, you would think Apple has about 95% market share and is doing all the work for others to benefit.Actually, it is just that Apple is good at making Arstechnica and other news sites write about them.Webkit gets some improvements and it is reported along with all the articles about iThings. There are hundreds of thousands of open source projects and hundreds of them get bigger improvements each week, but are not reported in the media. Apple is the king of the media.

If you read Arstechnica, you would think Apple has about 95% market share and is doing all the work for others to benefit.Actually, it is just that Apple is good at making Arstechnica and other news sites write about them.Webkit gets some improvements and it is reported along with all the articles about iThings. There are hundreds of thousands of open source projects and hundreds of them get bigger improvements each week, but are not reported in the media. Apple is the king of the media.

That's one view. Another would be to say that the vast majority of the 'hundreds of thousands' of other open source projects aren't particularly well used, as compared to webkit which is fairly ubiquitous. But I wouldn't want facts to get in the way of a good rant...

If you read Arstechnica, you would think Apple has about 95% market share and is doing all the work for others to benefit.Actually, it is just that Apple is good at making Arstechnica and other news sites write about them.Webkit gets some improvements and it is reported along with all the articles about iThings. There are hundreds of thousands of open source projects and hundreds of them get bigger improvements each week, but are not reported in the media. Apple is the king of the media.

That's one view. Another would be to say that the vast majority of the 'hundreds of thousands' of other open source projects aren't particularly well used, as compared to webkit which is fairly ubiquitous. But I wouldn't want facts to get in the way of a good rant...

linux, apache, vlc, symbian, openoffice, gecko, qt, ubuntu, openSSH, jQuery, python, gcc, java, libzip, vnc, xorg, bugzilla, wine, eclipse, gtk, glibc, ffmpeg, perl, rpm and I can go on and on.But I didn't praise Apple so I must be ranting and I must not "Get the facts". Maybe I should "Think different"(TM)?

If you read Arstechnica, you would think Apple has about 95% market share and is doing all the work for others to benefit.Actually, it is just that Apple is good at making Arstechnica and other news sites write about them.Webkit gets some improvements and it is reported along with all the articles about iThings. There are hundreds of thousands of open source projects and hundreds of them get bigger improvements each week, but are not reported in the media. Apple is the king of the media.

That's one view. Another would be to say that the vast majority of the 'hundreds of thousands' of other open source projects aren't particularly well used, as compared to webkit which is fairly ubiquitous. But I wouldn't want facts to get in the way of a good rant...

linux, apache, vlc, symbian, openoffice, gecko, qt, ubuntu, openSSH, jQuery, python, gcc, java, libzip, vnc, xorg, bugzilla, wine, eclipse, gtk, glibc, ffmpeg, perl, rpm and I can go on and on.But I didn't praise Apple so I must be ranting and I must not "Get the facts". Maybe I should "Think different"(TM)?

Note I said 'the vast majority'. Ars frequently posts updates on open source projects that have a user based dwarfed by webkit. Are you seriously suggesting they shouldn't mention a major architectural change in the rendering engine powering the vast majority of the worlds mobile browsers? Because you have a problem with anything tangentially related to Apple?

Note I said 'the vast majority'. Ars frequently posts updates on open source projects that have a user based dwarfed by webkit. Are you seriously suggesting they shouldn't mention a major architectural change in the rendering engine powering the vast majority of the worlds mobile browsers? Because you have a problem with anything tangentially related to Apple?

Note that I posted the post you replied to and that I did read correctly what you wrote.I'm not suggesting anything. I'm just observing and making a comment.I have no problem with Apple. You seem to have a problem with objective statements that do not ostentatiously praise Apple.If you don't see that Apple gets a far greater share of media coverage, especially from Ars, than what their market share would imply, it means that you are already brain washed. It looks normal when you are used to it.

If you read Arstechnica, you would think Apple has about 95% market share and is doing all the work for others to benefit.Actually, it is just that Apple is good at making Arstechnica and other news sites write about them.Webkit gets some improvements and it is reported along with all the articles about iThings. There are hundreds of thousands of open source projects and hundreds of them get bigger improvements each week, but are not reported in the media. Apple is the king of the media.

That's one view. Another would be to say that the vast majority of the 'hundreds of thousands' of other open source projects aren't particularly well used, as compared to webkit which is fairly ubiquitous. But I wouldn't want facts to get in the way of a good rant...

linux, apache, vlc, symbian, openoffice, gecko, qt, ubuntu, openSSH, jQuery, python, gcc, java, libzip, vnc, xorg, bugzilla, wine, eclipse, gtk, glibc, ffmpeg, perl, rpm and I can go on and on.But I didn't praise Apple so I must be ranting and I must not "Get the facts". Maybe I should "Think different"(TM)?

I'm not going to compound the argument that you are making. I must say though that I'd like for Ars to have articles on MySQL and PHP and Apache, covering new major versions. PHP 6 is due out sometime in the not too distant future.

I didn't even realise that MySQL had feature called parameterised queries until I was again researching recently in depth about SQL injection.

Why is every blog out there hyping up Chrome and their split process model when it was MS with IE8 that did it first.

Because it didn't? Unless you're talking public betas, of course. If you're talking actual releases, Chrome's first stable release was in December of 2008, and IE8 RTM didn't release until March of 2009.

Huh? According to the statistics you linked, OS X went from 4.73% in May 2009 to 5.33% in March 2010.... And I can't believe that you actually quite The Inquirer as a reliable source of news....

which part of the ars article that states -"Between November and December 2009, Windows market share dropped 0.31 percentage points (from 92.52 percent to 92.21 percent), Mac OS dipped 0.01 percentage points (from 5.12 percent to 5.11 percent)"is it that you have difficulties understanding? which is mirrored in theinq article. just because its inquirer doesnt make it less valid

which part of the ars article that states -"Between November and December 2009, Windows market share dropped 0.31 percentage points (from 92.52 percent to 92.21 percent), Mac OS dipped 0.01 percentage points (from 5.12 percent to 5.11 percent)"is it that you have difficulties understanding? which is mirrored in theinq article. just because its inquirer doesnt make it less valid

Month-to-month marketshare numbers are essentially meaningless. You need to look at more macro trends.

Month-to-month marketshare numbers are essentially meaningless. You need to look at more macro trends.

Marketshare numbers are meaningless anyway, let alone trends. You need to define the market, and how you measure the share you have in it (value in dollars, units sold, users, google searches, whatever) and it starts to be somewhat usefulish.

As a Safari user who finds the Chrome user interface less suited to my personal preferences but appreciates and desires some of the tech powering the browser, I am of course glad to read that Apple is adopting the split process model for Webkit2. This is welcome news for increasing stability on the platform. I am, however, more concerned with another major Chrome technology (technique?) that Safari badly needs: process sandboxing. As the recent Pwn to Own contest so embarrassingly demonstrated, Safari is vulnerable to attack in ways that Chrome (and, to preempt trolling, IE8, though that is irrelevant to the article and to my comment) is immune to due to its process sandboxing. Split processes are great for stability and are, of course, a prerequisite of process sandboxing, but, since the article and the trolls flinging poo at each other in the comments haven't mentioned sandboxing or security, I'm guessing that this essential next step hasn't been taken, or at least disclosed. I have read that the two best things Apple could do for security are to properly implement ASLR and to adopt Chrome-like browser sandboxing. Is there any word on sandboxing being developed for or implemented in Webkit2? I want the stability and security of Chrome's architecture, but I don't actually like using Chrome. Webkit2 and split processes are great for stability, but what about security?