SlideShare une entreprise Scribd logo
1  sur  29
Télécharger pour lire hors ligne
WebKit2 and You
WebKit2 for Application Developers
Martin Robinson
Igalia
Quick Review
WebKit
· Web content engine
· Processes and renders web content
· Started as a fork of KTHML and KJS
· Open source since 2005
· Goals: open source, compatibility, compliance, stability, performance,
security, portability, usability, hackability
· Non-goals: being a full web browser, being a science project, having
reusable components, unlimited scope
· Split into ports: GTK+, Qt, EFL, Mac, Windows

4/29
WebKitGTK+
· Each WebKit port is composed of
- Platform interfaces
- API layer
· WebKitGTK+ platform layer:
- libsoup for networking
- cairo for rasterization
- OpenGL for making the scene graph and WebGL
- GStreamer for media
- Various GTK+ APIs for talking with the system
· API layer is a GtkWidget and a set of GObject APIs
· WebKitGTK+ is used by Epiphany, Midori, yelp, devhelp

5/29
Architecture

6/29
Minor Philosophical Point
· Code has bugs that crash the program.
· Code has bugs that allow arbitrary code execution.
· Code relies on dependencies with bugs.
· Code handles fonts and images that are essentially small programs.
· WebKit2 is a pragmatic response

7/29
Why WebKit2?
·
·
·
·

The web platform is huge

Make crashes less inconvenient for users
Prevent bugs and crashes from exposing user data
Prevent bugs and crashes from damaging the system or executing
arbitrary code
· Stop web applications from blocking each other

8/29
WebKit2
· Give the web rendering parts of WebKit their own process
· Page crashes don't crash the browser
· Can put vulnerable data into a separate address space
· Sandbox web rendering
· Prevent pages from accessing the disk and operating system
interface

9/29
WebKit2 Architecture

10/29
Details
IPC
· IPC glues the different processes together
· Three types of IPC in use in Webkit
- Messaging: Unix domain socket for sending messages
synchronously or asynchronously
- Shared memory: shmem for passing large messages and bitmaps
- Shared surfaces: XComposite/XDamage for passing hardware
accelerated surfaces cheaply

12/29
Accelerated Compositing
· WebKit has its own hardware-accelerated scene graph of page content
- Prevent unnecessary redraw
- 3D CSS transforms
- WebGL
· Scene graph is in the WebProcess, but drawing happens in the
UIProcess
· XComposite/XDamage allows compositing and final paint in different
processes

13/29
Practical Bits
Should I port my application to WebKit2?

Yes
Why Port?
· WebKit1 development has moved to maintenance mode
· WebKit1 will be deprecated in the future
· The WebKit2GTK+ API is richer and better tested
· Porting to WebKit2 brings immediate performance, security, and
stability benefits

16/29
Porting Challenges
· There is not yet a porting guide
- Extensive API documentation
· Many synchronous APIs with return values are now asynchronous
void webkit_web_view_save (WebKitWebView *web_view,
WebKitSaveMode save_mode,
GCancellable *cancellable,
GAsyncReadyCallback callback,
gpointer user_data);

C

· Two-way communication from the page is more complicated
- Injected script source
- Custom protocols
- GObject DOM bindings
- Page access via the JSC API

17/29
Injected Script Source
· Strings of JavaScript source code executed asynchronously in the
WebProces
· Can return a value which is serialized and sent across the IPC
messaging channel

18/29
Injected Script Source
webkit_web_view_run_javascript (web_view, "window.document.body.textContent;", 0,
run_javascript_finished_callback, NULL);

static void
run_javascript_finished_callback (GObject *source_object, GAsyncResult *result, gpointer user_data)
{
GError *error;
WebKitJavaScriptResult *javascript_result =
webkit_web_view_run_javascript_finish (WEBKIT_WEB_VIEW(source_object), result, &error);

C

C

JSStringRef string_value = JSValueToStringCopy (
webkit_javascript_result_get_global_context (javascript_result),
webkit_javascript_result_get_value (javascript_result), NULL);
char *string = g_malloc (JSStringGetMaximumUTF8CStringSize (string_value));
JSStringGetUTF8CString (string_value, string, JSStringGetMaximumUTF8CStringSize (string_value));
printf ("result: %sn", string);
...
}

19/29
Custom Protocols
· Page to WebKit communication by accessing a resourcess across a
custom protocol
· Example of this approach are about: pages
· Communicate without reloading the page via AJAX
· Subject to same-origin security restrictions

20/29
Custom Protocols
WebKitContext *context = webkit_web_context_get_default ();
webkit_web_context_register_uri_scheme (context, "about", about_uri_scheme_request_cb, NULL, NULL);

static void
about_uri_scheme_request_cb (WebKitURISchemeRequest *request,
gpointer
user_data)
{
GInputStream *stream;
const gchar *path;
gchar
*contents;

C

C

path = webkit_uri_scheme_request_get_path (request);
contents = g_strdup_printf ("Loaded about:%s page", path);
stream = g_memory_input_stream_new_from_data (contents, strlen (contents), g_free);
webkit_uri_scheme_request_finish (request, stream, stream_length, "text/html");
g_object_unref (stream);
}

21/29
Web Extensions
· Web extensions are shared objects that execute in the WebProcess
· No IPC penalties
- Synchronous behavior does not block the UI
- Direct access to page state including the DOM
- Timing is less of an issue
· Written on top of the port-independent WebKit InjectedBundle
· No IPC API, but you can use DBus for communication with the
UIProcess

22/29
Web Extensions
C

void
webkit_web_extension_initialize (WebKitWebExtension *extension)
{
printf ("Hello from a WebProcessn");
}

$ gcc -c -Wall -Werror -fpic web-extension.c
$ gcc -shared -o web-extension.so web-extension.o

SHELL

webkit_web_context_set_web_extensions_directory (webkit_web_context_get_default (),
"/path/to/shared-object");

C

23/29
GObject DOM Bindings via Web Extensions
· GObject DOM bindings allow accessing page DOM using GObject APIs
· Cannot run in the UIProcess, the DOM is in a different address space
· In WebKit2, these are only accessible via Web Extensions
static void
document_loaded_callback (WebKitWebPage *page, gpointer user_data)
{
printf ("title: %sn", webkit_dom_document_get_title (webkit_web_page_get_dom_document (page)));
}

C

static void
page_created_callback (WebKitWebExtension *extension, WebKitWebPage *page, gpointer user_data)
{
g_signal_connect (page, "document-loaded", G_CALLBACK(document_loaded_callback), 0);
}
void
webkit_web_extension_initialize (WebKitWebExtension *extension)
{
g_signal_connect (extension, "page-created", G_CALLBACK(page_created_callback), NULL);
}

24/29
Injected JavaScript via Web Extensions
· Similar to the GObject DOM bindings approach
· Instead of using the GObject API, use the JSC C API
· Can interact with the page as well as insert JavaScript objects backed
by native code
· The most flexible approach
· Necessary Web Extension API should appear soon in a future release

25/29
The Near Future
More Processes

27/29
WebKit2
· Multiple WebProcesses
- Isolate applications from each other as well as from the UI
- Prevents crash from crashing every tab
· Networking Process
- Necessary for multiple web processes
- Avoids complexity of caches/databases with multiple writers
· Offline Storage Process
· Disk access blocking and insecure
· More easily sandbox WebProcesses

28/29
Thank You!
(q&a)

twitter @abandonedwig
www abandonedwig.info
29/29

Contenu connexe

Tendances

Android Chromium Rendering Pipeline
Android Chromium Rendering PipelineAndroid Chromium Rendering Pipeline
Android Chromium Rendering Pipeline
Hyungwook Lee
 
WebKit Clutter Port Present and Future; WebKitGtk Status and Roadmap to WebKi...
WebKit Clutter Port Present and Future; WebKitGtk Status and Roadmap to WebKi...WebKit Clutter Port Present and Future; WebKitGtk Status and Roadmap to WebKi...
WebKit Clutter Port Present and Future; WebKitGtk Status and Roadmap to WebKi...
Igalia
 

Tendances (19)

WebKit and GStreamer
WebKit and GStreamerWebKit and GStreamer
WebKit and GStreamer
 
HTML5 Apps on AGL Platform with the Web Application Manager (Automotive Grade...
HTML5 Apps on AGL Platform with the Web Application Manager (Automotive Grade...HTML5 Apps on AGL Platform with the Web Application Manager (Automotive Grade...
HTML5 Apps on AGL Platform with the Web Application Manager (Automotive Grade...
 
Pairing WebKit and Wayland for Linux-Based Embedded Web Content Presentation ...
Pairing WebKit and Wayland for Linux-Based Embedded Web Content Presentation ...Pairing WebKit and Wayland for Linux-Based Embedded Web Content Presentation ...
Pairing WebKit and Wayland for Linux-Based Embedded Web Content Presentation ...
 
The Internal Architecture of Chrome Developer Tools
The Internal Architecture of Chrome Developer ToolsThe Internal Architecture of Chrome Developer Tools
The Internal Architecture of Chrome Developer Tools
 
Android Chromium Rendering Pipeline
Android Chromium Rendering PipelineAndroid Chromium Rendering Pipeline
Android Chromium Rendering Pipeline
 
WebKit Clutter Port Present and Future; WebKitGtk Status and Roadmap to WebKi...
WebKit Clutter Port Present and Future; WebKitGtk Status and Roadmap to WebKi...WebKit Clutter Port Present and Future; WebKitGtk Status and Roadmap to WebKi...
WebKit Clutter Port Present and Future; WebKitGtk Status and Roadmap to WebKi...
 
WebKit and Blink: open development powering the HTML5 revolution
WebKit and Blink: open development powering the HTML5 revolutionWebKit and Blink: open development powering the HTML5 revolution
WebKit and Blink: open development powering the HTML5 revolution
 
LCU14 208- Chromium-Blink Migration for RDK
LCU14 208- Chromium-Blink Migration for RDKLCU14 208- Chromium-Blink Migration for RDK
LCU14 208- Chromium-Blink Migration for RDK
 
Webkit Chromium Contribution Process
Webkit Chromium Contribution ProcessWebkit Chromium Contribution Process
Webkit Chromium Contribution Process
 
Chromium Ozone
Chromium OzoneChromium Ozone
Chromium Ozone
 
The WebKit project (LinuxCon North America 2012)
The WebKit project (LinuxCon North America 2012)The WebKit project (LinuxCon North America 2012)
The WebKit project (LinuxCon North America 2012)
 
2021 WebKit Contributors Meeting, Igalia
2021 WebKit Contributors Meeting, Igalia2021 WebKit Contributors Meeting, Igalia
2021 WebKit Contributors Meeting, Igalia
 
The pathway to Chromium on Wayland (Web Engines Hackfest 2018)
The pathway to Chromium on Wayland (Web Engines Hackfest 2018)The pathway to Chromium on Wayland (Web Engines Hackfest 2018)
The pathway to Chromium on Wayland (Web Engines Hackfest 2018)
 
A Browser for the Automotive: Introduction to WebKit for Wayland (Automotive ...
A Browser for the Automotive: Introduction to WebKit for Wayland (Automotive ...A Browser for the Automotive: Introduction to WebKit for Wayland (Automotive ...
A Browser for the Automotive: Introduction to WebKit for Wayland (Automotive ...
 
HTML5 on the AGL demo platform with Chromium and WAM (AGL AMM March 2021)
HTML5 on the AGL demo platform with Chromium and WAM (AGL AMM March 2021)HTML5 on the AGL demo platform with Chromium and WAM (AGL AMM March 2021)
HTML5 on the AGL demo platform with Chromium and WAM (AGL AMM March 2021)
 
Driving and virtualizing control systems: the Open Source approach used in Wh...
Driving and virtualizing control systems: the Open Source approach used in Wh...Driving and virtualizing control systems: the Open Source approach used in Wh...
Driving and virtualizing control systems: the Open Source approach used in Wh...
 
Inject the Web into your GStreamer pipeline with WPE using a GStreamer/WebKit...
Inject the Web into your GStreamer pipeline with WPE using a GStreamer/WebKit...Inject the Web into your GStreamer pipeline with WPE using a GStreamer/WebKit...
Inject the Web into your GStreamer pipeline with WPE using a GStreamer/WebKit...
 
WebKit and Blink: Bridging the Gap Between the Kernel and the HTML5 Revolution
WebKit and Blink: Bridging the Gap Between the Kernel and the HTML5 RevolutionWebKit and Blink: Bridging the Gap Between the Kernel and the HTML5 Revolution
WebKit and Blink: Bridging the Gap Between the Kernel and the HTML5 Revolution
 
GStreamer support in WebKit. what’s new?
GStreamer support in WebKit. what’s new?GStreamer support in WebKit. what’s new?
GStreamer support in WebKit. what’s new?
 

Similaire à WebKit2 And You (GUADEC 2013)

Add the power of the Web to your embedded devices with WPE WebKit
Add the power of the Web to your embedded devices with WPE WebKitAdd the power of the Web to your embedded devices with WPE WebKit
Add the power of the Web to your embedded devices with WPE WebKit
Igalia
 

Similaire à WebKit2 And You (GUADEC 2013) (20)

Igalia and WebKit: Status update and plans
Igalia and WebKit: Status update and plansIgalia and WebKit: Status update and plans
Igalia and WebKit: Status update and plans
 
Wayland support in WebKit2GTK+ (GUADEC 2014)
Wayland support in WebKit2GTK+ (GUADEC 2014)Wayland support in WebKit2GTK+ (GUADEC 2014)
Wayland support in WebKit2GTK+ (GUADEC 2014)
 
The WebKit project
The WebKit projectThe WebKit project
The WebKit project
 
WebKit and GStreamer (GStreamer Conference 2013)
WebKit and GStreamer (GStreamer Conference 2013)WebKit and GStreamer (GStreamer Conference 2013)
WebKit and GStreamer (GStreamer Conference 2013)
 
Developments in the Qt WebKit Integration
Developments in the Qt WebKit IntegrationDevelopments in the Qt WebKit Integration
Developments in the Qt WebKit Integration
 
WebKit and Blink: Bridging the Gap Between the Kernel and the HTML5 Revolutio...
WebKit and Blink: Bridging the Gap Between the Kernel and the HTML5 Revolutio...WebKit and Blink: Bridging the Gap Between the Kernel and the HTML5 Revolutio...
WebKit and Blink: Bridging the Gap Between the Kernel and the HTML5 Revolutio...
 
Add the power of the Web to your embedded devices with WPE WebKit
Add the power of the Web to your embedded devices with WPE WebKitAdd the power of the Web to your embedded devices with WPE WebKit
Add the power of the Web to your embedded devices with WPE WebKit
 
WPEWebKit, the WebKit port for embedded platforms (Linaro Connect San Diego 2...
WPEWebKit, the WebKit port for embedded platforms (Linaro Connect San Diego 2...WPEWebKit, the WebKit port for embedded platforms (Linaro Connect San Diego 2...
WPEWebKit, the WebKit port for embedded platforms (Linaro Connect San Diego 2...
 
WebKit and Blink: Open Development Powering the HTML5 Revolution (LinuxCon No...
WebKit and Blink: Open Development Powering the HTML5 Revolution (LinuxCon No...WebKit and Blink: Open Development Powering the HTML5 Revolution (LinuxCon No...
WebKit and Blink: Open Development Powering the HTML5 Revolution (LinuxCon No...
 
Next Generation Hybrid Applications with Qt - presentation for SEE 2009
Next Generation Hybrid Applications with Qt - presentation for SEE 2009Next Generation Hybrid Applications with Qt - presentation for SEE 2009
Next Generation Hybrid Applications with Qt - presentation for SEE 2009
 
Lessons from Contributing to WebKit and Blink
Lessons from Contributing to WebKit and BlinkLessons from Contributing to WebKit and Blink
Lessons from Contributing to WebKit and Blink
 
Update on the open source browser space (16th GENIVI AMM)
Update on the open source browser space (16th GENIVI AMM)Update on the open source browser space (16th GENIVI AMM)
Update on the open source browser space (16th GENIVI AMM)
 
Web 3.12: A browser to make us proud (GUADEC 2014)
Web 3.12: A browser to make us proud (GUADEC 2014)Web 3.12: A browser to make us proud (GUADEC 2014)
Web 3.12: A browser to make us proud (GUADEC 2014)
 
Transforming the web into a real application platform
Transforming the web into a real application platformTransforming the web into a real application platform
Transforming the web into a real application platform
 
[workshop] The Revolutionary WebRTC
[workshop] The Revolutionary WebRTC[workshop] The Revolutionary WebRTC
[workshop] The Revolutionary WebRTC
 
JooinK - DevFest Piemonte 2013
JooinK - DevFest Piemonte 2013JooinK - DevFest Piemonte 2013
JooinK - DevFest Piemonte 2013
 
Multimedia in WebKitGTK+ (FOSDEM 2010)
Multimedia in WebKitGTK+ (FOSDEM 2010)Multimedia in WebKitGTK+ (FOSDEM 2010)
Multimedia in WebKitGTK+ (FOSDEM 2010)
 
Serving QML applications over the network
Serving QML applications over the networkServing QML applications over the network
Serving QML applications over the network
 
Browsers and Web Runtimes for Automotive: Alternatives, Challenges, and Curre...
Browsers and Web Runtimes for Automotive: Alternatives, Challenges, and Curre...Browsers and Web Runtimes for Automotive: Alternatives, Challenges, and Curre...
Browsers and Web Runtimes for Automotive: Alternatives, Challenges, and Curre...
 
WebRTC in WPE/GTK Ports: Current status and challenges
WebRTC in WPE/GTK Ports: Current status and challengesWebRTC in WPE/GTK Ports: Current status and challenges
WebRTC in WPE/GTK Ports: Current status and challenges
 

Plus de Igalia

Building End-user Applications on Embedded Devices with WPE
Building End-user Applications on Embedded Devices with WPEBuilding End-user Applications on Embedded Devices with WPE
Building End-user Applications on Embedded Devices with WPE
Igalia
 
Automated Testing for Web-based Systems on Embedded Devices
Automated Testing for Web-based Systems on Embedded DevicesAutomated Testing for Web-based Systems on Embedded Devices
Automated Testing for Web-based Systems on Embedded Devices
Igalia
 
Running JS via WASM faster with JIT
Running JS via WASM      faster with JITRunning JS via WASM      faster with JIT
Running JS via WASM faster with JIT
Igalia
 
Introducción a Mesa. Caso específico dos dispositivos Raspberry Pi por Igalia
Introducción a Mesa. Caso específico dos dispositivos Raspberry Pi por IgaliaIntroducción a Mesa. Caso específico dos dispositivos Raspberry Pi por Igalia
Introducción a Mesa. Caso específico dos dispositivos Raspberry Pi por Igalia
Igalia
 

Plus de Igalia (20)

A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
Building End-user Applications on Embedded Devices with WPE
Building End-user Applications on Embedded Devices with WPEBuilding End-user Applications on Embedded Devices with WPE
Building End-user Applications on Embedded Devices with WPE
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
Automated Testing for Web-based Systems on Embedded Devices
Automated Testing for Web-based Systems on Embedded DevicesAutomated Testing for Web-based Systems on Embedded Devices
Automated Testing for Web-based Systems on Embedded Devices
 
Embedding WPE WebKit - from Bring-up to Maintenance
Embedding WPE WebKit - from Bring-up to MaintenanceEmbedding WPE WebKit - from Bring-up to Maintenance
Embedding WPE WebKit - from Bring-up to Maintenance
 
Optimizing Scheduler for Linux Gaming.pdf
Optimizing Scheduler for Linux Gaming.pdfOptimizing Scheduler for Linux Gaming.pdf
Optimizing Scheduler for Linux Gaming.pdf
 
Running JS via WASM faster with JIT
Running JS via WASM      faster with JITRunning JS via WASM      faster with JIT
Running JS via WASM faster with JIT
 
To crash or not to crash: if you do, at least recover fast!
To crash or not to crash: if you do, at least recover fast!To crash or not to crash: if you do, at least recover fast!
To crash or not to crash: if you do, at least recover fast!
 
Implementing a Vulkan Video Encoder From Mesa to GStreamer
Implementing a Vulkan Video Encoder From Mesa to GStreamerImplementing a Vulkan Video Encoder From Mesa to GStreamer
Implementing a Vulkan Video Encoder From Mesa to GStreamer
 
8 Years of Open Drivers, including the State of Vulkan in Mesa
8 Years of Open Drivers, including the State of Vulkan in Mesa8 Years of Open Drivers, including the State of Vulkan in Mesa
8 Years of Open Drivers, including the State of Vulkan in Mesa
 
Introducción a Mesa. Caso específico dos dispositivos Raspberry Pi por Igalia
Introducción a Mesa. Caso específico dos dispositivos Raspberry Pi por IgaliaIntroducción a Mesa. Caso específico dos dispositivos Raspberry Pi por Igalia
Introducción a Mesa. Caso específico dos dispositivos Raspberry Pi por Igalia
 
2023 in Chimera Linux
2023 in Chimera                    Linux2023 in Chimera                    Linux
2023 in Chimera Linux
 
Building a Linux distro with LLVM
Building a Linux distro        with LLVMBuilding a Linux distro        with LLVM
Building a Linux distro with LLVM
 
turnip: Update on Open Source Vulkan Driver for Adreno GPUs
turnip: Update on Open Source Vulkan Driver for Adreno GPUsturnip: Update on Open Source Vulkan Driver for Adreno GPUs
turnip: Update on Open Source Vulkan Driver for Adreno GPUs
 
Graphics stack updates for Raspberry Pi devices
Graphics stack updates for Raspberry Pi devicesGraphics stack updates for Raspberry Pi devices
Graphics stack updates for Raspberry Pi devices
 
Delegated Compositing - Utilizing Wayland Protocols for Chromium on ChromeOS
Delegated Compositing - Utilizing Wayland Protocols for Chromium on ChromeOSDelegated Compositing - Utilizing Wayland Protocols for Chromium on ChromeOS
Delegated Compositing - Utilizing Wayland Protocols for Chromium on ChromeOS
 
MessageFormat: The future of i18n on the web
MessageFormat: The future of i18n on the webMessageFormat: The future of i18n on the web
MessageFormat: The future of i18n on the web
 
Replacing the geometry pipeline with mesh shaders
Replacing the geometry pipeline with mesh shadersReplacing the geometry pipeline with mesh shaders
Replacing the geometry pipeline with mesh shaders
 
I'm not an AMD expert, but...
I'm not an AMD expert, but...I'm not an AMD expert, but...
I'm not an AMD expert, but...
 
Status of Vulkan on Raspberry
Status of Vulkan on RaspberryStatus of Vulkan on Raspberry
Status of Vulkan on Raspberry
 

Dernier

Dernier (20)

Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Tech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfTech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdf
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 

WebKit2 And You (GUADEC 2013)

  • 1.
  • 2. WebKit2 and You WebKit2 for Application Developers Martin Robinson Igalia
  • 4. WebKit · Web content engine · Processes and renders web content · Started as a fork of KTHML and KJS · Open source since 2005 · Goals: open source, compatibility, compliance, stability, performance, security, portability, usability, hackability · Non-goals: being a full web browser, being a science project, having reusable components, unlimited scope · Split into ports: GTK+, Qt, EFL, Mac, Windows 4/29
  • 5. WebKitGTK+ · Each WebKit port is composed of - Platform interfaces - API layer · WebKitGTK+ platform layer: - libsoup for networking - cairo for rasterization - OpenGL for making the scene graph and WebGL - GStreamer for media - Various GTK+ APIs for talking with the system · API layer is a GtkWidget and a set of GObject APIs · WebKitGTK+ is used by Epiphany, Midori, yelp, devhelp 5/29
  • 7. Minor Philosophical Point · Code has bugs that crash the program. · Code has bugs that allow arbitrary code execution. · Code relies on dependencies with bugs. · Code handles fonts and images that are essentially small programs. · WebKit2 is a pragmatic response 7/29
  • 8. Why WebKit2? · · · · The web platform is huge Make crashes less inconvenient for users Prevent bugs and crashes from exposing user data Prevent bugs and crashes from damaging the system or executing arbitrary code · Stop web applications from blocking each other 8/29
  • 9. WebKit2 · Give the web rendering parts of WebKit their own process · Page crashes don't crash the browser · Can put vulnerable data into a separate address space · Sandbox web rendering · Prevent pages from accessing the disk and operating system interface 9/29
  • 12. IPC · IPC glues the different processes together · Three types of IPC in use in Webkit - Messaging: Unix domain socket for sending messages synchronously or asynchronously - Shared memory: shmem for passing large messages and bitmaps - Shared surfaces: XComposite/XDamage for passing hardware accelerated surfaces cheaply 12/29
  • 13. Accelerated Compositing · WebKit has its own hardware-accelerated scene graph of page content - Prevent unnecessary redraw - 3D CSS transforms - WebGL · Scene graph is in the WebProcess, but drawing happens in the UIProcess · XComposite/XDamage allows compositing and final paint in different processes 13/29
  • 15. Should I port my application to WebKit2? Yes
  • 16. Why Port? · WebKit1 development has moved to maintenance mode · WebKit1 will be deprecated in the future · The WebKit2GTK+ API is richer and better tested · Porting to WebKit2 brings immediate performance, security, and stability benefits 16/29
  • 17. Porting Challenges · There is not yet a porting guide - Extensive API documentation · Many synchronous APIs with return values are now asynchronous void webkit_web_view_save (WebKitWebView *web_view, WebKitSaveMode save_mode, GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data); C · Two-way communication from the page is more complicated - Injected script source - Custom protocols - GObject DOM bindings - Page access via the JSC API 17/29
  • 18. Injected Script Source · Strings of JavaScript source code executed asynchronously in the WebProces · Can return a value which is serialized and sent across the IPC messaging channel 18/29
  • 19. Injected Script Source webkit_web_view_run_javascript (web_view, "window.document.body.textContent;", 0, run_javascript_finished_callback, NULL); static void run_javascript_finished_callback (GObject *source_object, GAsyncResult *result, gpointer user_data) { GError *error; WebKitJavaScriptResult *javascript_result = webkit_web_view_run_javascript_finish (WEBKIT_WEB_VIEW(source_object), result, &error); C C JSStringRef string_value = JSValueToStringCopy ( webkit_javascript_result_get_global_context (javascript_result), webkit_javascript_result_get_value (javascript_result), NULL); char *string = g_malloc (JSStringGetMaximumUTF8CStringSize (string_value)); JSStringGetUTF8CString (string_value, string, JSStringGetMaximumUTF8CStringSize (string_value)); printf ("result: %sn", string); ... } 19/29
  • 20. Custom Protocols · Page to WebKit communication by accessing a resourcess across a custom protocol · Example of this approach are about: pages · Communicate without reloading the page via AJAX · Subject to same-origin security restrictions 20/29
  • 21. Custom Protocols WebKitContext *context = webkit_web_context_get_default (); webkit_web_context_register_uri_scheme (context, "about", about_uri_scheme_request_cb, NULL, NULL); static void about_uri_scheme_request_cb (WebKitURISchemeRequest *request, gpointer user_data) { GInputStream *stream; const gchar *path; gchar *contents; C C path = webkit_uri_scheme_request_get_path (request); contents = g_strdup_printf ("Loaded about:%s page", path); stream = g_memory_input_stream_new_from_data (contents, strlen (contents), g_free); webkit_uri_scheme_request_finish (request, stream, stream_length, "text/html"); g_object_unref (stream); } 21/29
  • 22. Web Extensions · Web extensions are shared objects that execute in the WebProcess · No IPC penalties - Synchronous behavior does not block the UI - Direct access to page state including the DOM - Timing is less of an issue · Written on top of the port-independent WebKit InjectedBundle · No IPC API, but you can use DBus for communication with the UIProcess 22/29
  • 23. Web Extensions C void webkit_web_extension_initialize (WebKitWebExtension *extension) { printf ("Hello from a WebProcessn"); } $ gcc -c -Wall -Werror -fpic web-extension.c $ gcc -shared -o web-extension.so web-extension.o SHELL webkit_web_context_set_web_extensions_directory (webkit_web_context_get_default (), "/path/to/shared-object"); C 23/29
  • 24. GObject DOM Bindings via Web Extensions · GObject DOM bindings allow accessing page DOM using GObject APIs · Cannot run in the UIProcess, the DOM is in a different address space · In WebKit2, these are only accessible via Web Extensions static void document_loaded_callback (WebKitWebPage *page, gpointer user_data) { printf ("title: %sn", webkit_dom_document_get_title (webkit_web_page_get_dom_document (page))); } C static void page_created_callback (WebKitWebExtension *extension, WebKitWebPage *page, gpointer user_data) { g_signal_connect (page, "document-loaded", G_CALLBACK(document_loaded_callback), 0); } void webkit_web_extension_initialize (WebKitWebExtension *extension) { g_signal_connect (extension, "page-created", G_CALLBACK(page_created_callback), NULL); } 24/29
  • 25. Injected JavaScript via Web Extensions · Similar to the GObject DOM bindings approach · Instead of using the GObject API, use the JSC C API · Can interact with the page as well as insert JavaScript objects backed by native code · The most flexible approach · Necessary Web Extension API should appear soon in a future release 25/29
  • 28. WebKit2 · Multiple WebProcesses - Isolate applications from each other as well as from the UI - Prevents crash from crashing every tab · Networking Process - Necessary for multiple web processes - Avoids complexity of caches/databases with multiple writers · Offline Storage Process · Disk access blocking and insecure · More easily sandbox WebProcesses 28/29