What is WebKit2 ?
WebKit2 is a substantial architectural enhancement to WebKit that allows clients/embedders of the framework to harness operating system (OS) level "features" for a more responsive and secure application. The "UI Process" is the application that uses the WebKit2 API C API to render web views. The "Web Process" are the one of the many processes that primarily run the web engine responsible for the downloading, parsing and rendering of content.
The main upsides of WebKit2 for client applications are :
- more responsive application UIs that farm out CPU intensive web processing to a worker process
- improved crash tolerance by isolating crash-prone code outside the UI process
- better OS enforced security for memory accesses, file access, sensor access
The multi-process browser landscape
Microsoft's IE8 and Google's Chromium Browser was the pioneers in separating the UI process from the engine process. WebKit2 is Apple's fully public domain implementation of the same essential architectural concepts.
The UI Process and its APIs
Debugging tips (gdb)
Multiprocess architecture needs multiprocess debugging. Usually we are interested about what is happening in the web process. To debug the web process you need a way to attach to it. You can tell gdb to attach to a given pid at startup with the --pid=$pid switch or you can use the attach command. In newer versions you can use "set follow-fork-mode" command as well (i.e. "set follow-fork-mode child" means that the debugger will automatically attach to the child process on a fork.) For special cases some helper functionality had been added:
- If you need to see what's going on at program startup (for example you are debugging an initialization crash) then attaching is not good. That is the motivation behind http://trac.webkit.org/changeset/70760. Read the Changelog and follow the instructions if you need to stop execution at startup. (Tip: use the -s switch of pidof at the end of the command to restrict the output to the main thread pid.)
- There is a minor issue with the "set follow-fork-mode" command: you cannot interrupt the web process and return to the debugger by pressing Ctrl-C because the it will immediately terminate (due to how we set up the web process). To work around this behavior, see http://trac.webkit.org/changeset/81507.