SlideShare a Scribd company logo
1 of 70
Download to read offline
Embedded WPE WebKit
From Bring-Up to Maintenance
Adrian Perez de Castro
aperez@igalia.com
1 / 34
About Me
CS Engineer, partner of Igalia.
Systems person turned web engine
developer.
WebKit jack of all trades since ~2012.
Current focus: platform layer,
hardware bringup, release
management.
I like old computers, too!
Embedded WPE WebKit
Adrian Perez de Castro, 2024-04-17
2 / 34
About Igalia
Specialized Open Source consultancy, founded in 2001
Fully remote, HQ in A Coruña (Spain). Flat structure.
Top contributors to all the main Web Rendering Engines
WebKit, Chromium, Gecko and Servo
Active contributor to other areas and OSS projects
V8, SpiderMonkey, JSC, LLVM, Node.js, GStreamer, Mesa,
Linux Kernel...
Members of several working groups:
W3C, WHATWG, WPT, TC39, OpenJS, Test262, Khronos...
Embedded WPE WebKit
Adrian Perez de Castro, 2024-04-17
3 / 34
Agenda
1. WPE WebKit 101
2. Adding WPE to your device
3. Done! Now what?
Embedded WPE WebKit
Adrian Perez de Castro, 2024-04-17
4 / 34
WPE WebKit 101
Embedded WPE WebKit
Adrian Perez de Castro, 2024-04-17
5 / 34
101: What is WebKit
Open Source Web Engine:
Ingests HTML/CSS/JavaScript/etc.
Produces rendered content.
Port-able:
Port = Adaptation for a specific platform.
Runs in more places than one may imagine.
The WPE port focuses on Linux-based embedded devices.
Multi-process architecture.
Embedded WPE WebKit
Adrian Perez de Castro, 2024-04-17
6 / 34
101: Why a Web Engine?
Software The Web is eating the world
Embedded WPE WebKit
Adrian Perez de Castro, 2024-04-17
7 / 34
101: Why a Web Engine?
Software The Web is eating the world
“There is an app a website for that.”
Embedded WPE WebKit
Adrian Perez de Castro, 2024-04-17
7 / 34
101: Why a Web Engine?
Software The Web is eating the world
“There is an app a website for that.”
Embedded hardware is powerful enough now since ~2013.
Embedded WPE WebKit
Adrian Perez de Castro, 2024-04-17
7 / 34
101: Why a Web Engine?
Software The Web is eating the world
“There is an app a website for that.”
Embedded hardware is powerful enough now since ~2013.
Prototype and iterate harder, better, faster stronger.
Embedded WPE WebKit
Adrian Perez de Castro, 2024-04-17
7 / 34
101: Why WPE WebKit?
Platformless WebKit port. Designed to be embeddable:
Embedded WPE WebKit
Adrian Perez de Castro, 2024-04-17
8 / 34
101: Why WPE WebKit?
Platformless WebKit port. Designed to be embeddable:
Extensible,
Embedded WPE WebKit
Adrian Perez de Castro, 2024-04-17
8 / 34
101: Why WPE WebKit?
Platformless WebKit port. Designed to be embeddable:
Extensible,
Adaptable,
Embedded WPE WebKit
Adrian Perez de Castro, 2024-04-17
8 / 34
101: Why WPE WebKit?
Platformless WebKit port. Designed to be embeddable:
Extensible,
Adaptable,
Minimal dependencies.
Embedded WPE WebKit
Adrian Perez de Castro, 2024-04-17
8 / 34
101: Why WPE WebKit?
Available yesterday:
Embedded WPE WebKit
Adrian Perez de Castro, 2024-04-17
9 / 34
101: Why WPE WebKit?
Available yesterday:
Build systems: Yocto, Buildroot, PTXdist;
Embedded WPE WebKit
Adrian Perez de Castro, 2024-04-17
9 / 34
101: Why WPE WebKit?
Available yesterday:
Build systems: Yocto, Buildroot, PTXdist;
Distributions: Debian, Ubuntu, Arch.
Embedded WPE WebKit
Adrian Perez de Castro, 2024-04-17
9 / 34
101: Why WPE WebKit?
Available yesterday:
Build systems: Yocto, Buildroot, PTXdist;
Distributions: Debian, Ubuntu, Arch.
WPE has existed for 6+ years.
Embedded WPE WebKit
Adrian Perez de Castro, 2024-04-17
9 / 34
101: Multiprocess WebKit
UI Process
Embeds a WebKitWebView.
This is your browser application.
WebProcess:
Handles Web content.
Many of them, per-site isolation.
Network Process
Embedded WPE WebKit
Adrian Perez de Castro, 2024-04-17
10 / 34
Adding WPE
to Your Device
Act I: Bringup
Embedded WPE WebKit
Adrian Perez de Castro, 2024-04-17
11 / 34
Check List
Is my ?
hardware supported
Embedded WPE WebKit
Adrian Perez de Castro, 2024-04-17
12 / 34
Check List
Is my ?
hardware supported
Yes
It's your lucky day!
☘️
Embedded WPE WebKit
Adrian Perez de Castro, 2024-04-17
12 / 34
Check List
Is my ?
hardware supported
Yes
It's your lucky day!
☘️
No
There are some
requirements.
Embedded WPE WebKit
Adrian Perez de Castro, 2024-04-17
12 / 34
Check List
Minimum
OpenGL ES 2.0
Buffer sharing
Desirable
64-bit CPU
EGL/GLES extensions
Embedded WPE WebKit
Adrian Perez de Castro, 2024-04-17
13 / 34
Check List
Minimum
OpenGL ES 2.0
Buffer sharing
Desirable
64-bit CPU
EGL/GLES extensions
EGL_KHR_image_base
EGL_KHR_surfaceless_context
EGL_EXT_image_dma_buf_import
EGL_EXT_image_dma_buf_import_modifiers
EGL_MESA_image_dma_buf_export
Embedded WPE WebKit
Adrian Perez de Castro, 2024-04-17
13 / 34
Pain Point: GPU Drivers 🖥️
Embedded WPE WebKit
Adrian Perez de Castro, 2024-04-17
14 / 34
Pain Point: GPU Drivers 🖥️
Wayland/DMA-BUF support
Lack of OpenGL ES 3+
Vulkan-only drivers
Unusable driver
Embedded WPE WebKit
Adrian Perez de Castro, 2024-04-17
14 / 34
Pain Point: GPU Drivers 🖥️
Wayland/DMA-BUF support
Lack of OpenGL ES 3+
Vulkan-only drivers
Unusable driver
Steadily improving
GLESv2 as baseline
Zink usable, seldom tested
Mesa swrast/llvmpipe
Embedded WPE WebKit
Adrian Perez de Castro, 2024-04-17
14 / 34
Pain Point: GPU Drivers 🖥️
Wayland/DMA-BUF support
Lack of OpenGL ES 3+
Vulkan-only drivers
Unusable driver
Steadily improving
GLESv2 as baseline
Zink usable, seldom tested
Mesa swrast/llvmpipe
Prefer Open Source drivers 💫
Embedded WPE WebKit
Adrian Perez de Castro, 2024-04-17
14 / 34
Pain Point: “Funny” HW 📟
Embedded WPE WebKit
Adrian Perez de Castro, 2024-04-17
15 / 34
Pain Point: “Funny” HW 📟
Not 32-bpp
RGB565
incantation.
DMA-BUF.
Little testing.
Embedded WPE WebKit
Adrian Perez de Castro, 2024-04-17
15 / 34
Pain Point: “Funny” HW 📟
Not 32-bpp
RGB565
incantation.
DMA-BUF.
Little testing.
Rotated/Flipped
Works on
Wayland.
Okay-ish on
DRM/KMS.
Embedded WPE WebKit
Adrian Perez de Castro, 2024-04-17
15 / 34
Pain Point: “Funny” HW 📟
Not 32-bpp
RGB565
incantation.
DMA-BUF.
Little testing.
Rotated/Flipped
Works on
Wayland.
Okay-ish on
DRM/KMS.
Bare metal
Exotic
connections.
Legacy:
fbdev 😓.
Embedded WPE WebKit
Adrian Perez de Castro, 2024-04-17
15 / 34
Pain Point: “Funny” HW 📟
Not 32-bpp
RGB565
incantation.
DMA-BUF.
Little testing.
Rotated/Flipped
Works on
Wayland.
Okay-ish on
DRM/KMS.
Bare metal
Exotic
connections.
Legacy:
fbdev 😓.
Prefer common technologies 💫
Embedded WPE WebKit
Adrian Perez de Castro, 2024-04-17
15 / 34
Adding WPE
to Your Device
Act II: Browser
Embedded WPE WebKit
Adrian Perez de Castro, 2024-04-17
16 / 34
Choosing a Browser
(In increasing order of complexity.)
Embedded WPE WebKit
Adrian Perez de Castro, 2024-04-17
17 / 34
Choosing a Browser
(In increasing order of complexity.)
Use .
Cog
Embedded WPE WebKit
Adrian Perez de Castro, 2024-04-17
17 / 34
Choosing a Browser
(In increasing order of complexity.)
Use .
Cog
Use .
libcogcore
Embedded WPE WebKit
Adrian Perez de Castro, 2024-04-17
17 / 34
Choosing a Browser
(In increasing order of complexity.)
Use .
Cog
Use .
libcogcore
Roll your own.
Embedded WPE WebKit
Adrian Perez de Castro, 2024-04-17
17 / 34
Browser: libcogcore
#include <cog/cog.h>
static const char *s_starturl = NULL;
static WebKitWebView* on_create_view(CogShell *shell, CogPlatform *platform) {
WebKitWebViewBackend *view_backend = cog_platform_get_view_backend(platform, NULL, NULL);
g_autoptr(WebKitWebView) web_view = g_object_new(WEBKIT_TYPE_WEB_VIEW,
"settings", cog_shell_get_web_settings(shell), "web-context", cog_shell_get_web_context(shell),
"backend", view_backend, NULL);
cog_platform_init_web_view(platform, web_view);
webkit_web_view_load_uri(web_view, s_starturl);
return g_steal_pointer(&web_view);
}
int main(int argc, char *argv[]) {
g_set_application_name("minicog");
if (argc != 2 && argc != 3) g_error("Usage: %s [URL [platform]]n", argv[0]);
s_starturl = cog_uri_guess_from_user_input(argv[1], TRUE, NULL);
cog_modules_add_directory(COG_MODULEDIR);
g_autoptr(GApplication) app = g_application_new(NULL, G_APPLICATION_DEFAULT_FLAGS);
g_autoptr(CogShell) shell = cog_shell_new("minicog", FALSE);
g_autoptr(CogPlatform) platform = cog_platform_new(g_getenv("COG_PLATFORM"), NULL);
cog_platform_setup(platform, shell, "", NULL);
g_signal_connect(shell, "create-view", G_CALLBACK(on_create_view), platform);
g_signal_connect_swapped(app, "shutdown", G_CALLBACK(cog_shell_shutdown), shell);
g_signal_connect_swapped(app, "startup", G_CALLBACK(cog_shell_startup), shell);
g_signal_connect(app, "activate", G_CALLBACK(g_application_hold), NULL);
return g_application_run(app, 1, argv);
}
Embedded WPE WebKit
Adrian Perez de Castro, 2024-04-17
18 / 34
Browser: WPE Platform API
#include <wpe/webkit.h>
int main(int argc, const char *argv[]) {
g_autoptr(GMainLoop) loop = g_main_loop_new(NULL, FALSE);
g_autoptr(WebKitWebView) view = webkit_web_view_new(NULL);
webkit_web_view_load_uri(view,
(argc > 1) ? argv[1] : "https://wpewebkit.org");
g_main_loop_run(loop);
return EXIT_SUCCESS;
}
Embedded WPE WebKit
Adrian Perez de Castro, 2024-04-17
19 / 34
Adding WPE
to Your Device
Act III: Integration
Embedded WPE WebKit
Adrian Perez de Castro, 2024-04-17
20 / 34
Motivation
Make Web content talk to your hardware
Embedded WPE WebKit
Adrian Perez de Castro, 2024-04-17
21 / 34
Motivation
Make Web content talk to your hardware
Local web server!
Local web server!
Embedded WPE WebKit
Adrian Perez de Castro, 2024-04-17
21 / 34
Motivation
Make Web content talk to your hardware
Embedded WPE WebKit
Adrian Perez de Castro, 2024-04-17
21 / 34
Integration:
URI Scheme Handler
Embedded WPE WebKit
Adrian Perez de Castro, 2024-04-17
22 / 34
Integration:
URI Scheme Handler
static void
configure_web_context(WebKitWebContext *context) {
webkit_web_context_register_uri_scheme(context,
"echo",
(WebKitURISchemeRequestCallback) handle_echo_scheme,
NULL /* userdata */,
NULL /* destroy_notify */);
}
Embedded WPE WebKit
Adrian Perez de Castro, 2024-04-17
22 / 34
Integration:
URI Scheme Handler
static void
configure_web_context(WebKitWebContext *context) {
webkit_web_context_register_uri_scheme(context,
"echo",
(WebKitURISchemeRequestCallback) handle_echo_scheme,
NULL /* userdata */,
NULL /* destroy_notify */);
}
static void
handle_echo_scheme(WebKitURISchemeRequest *r) {
const char *uri = webkit_uri_scheme_request_get_uri(r);
g_autoptr(GBytes) data = g_bytes_new(uri, strlen(uri));
g_autoptr(GInputStream) stream =
g_memory_input_stream_new_from_bytes(data);
webkit_uri_scheme_request_finish(request, stream,
g_bytes_get_size(data), "text/plain");
}
Embedded WPE WebKit
Adrian Perez de Castro, 2024-04-17
22 / 34
Integration:
URI Scheme Handler
static void
configure_web_context(WebKitWebContext *context) {
webkit_web_context_register_uri_scheme(context,
"echo",
(WebKitURISchemeRequestCallback) handle_echo_scheme,
NULL /* userdata */,
NULL /* destroy_notify */);
}
static void
handle_echo_scheme(WebKitURISchemeRequest *r) {
const char *uri = webkit_uri_scheme_request_get_uri(r);
g_autoptr(GBytes) data = g_bytes_new(uri, strlen(uri));
g_autoptr(GInputStream) stream =
g_memory_input_stream_new_from_bytes(data);
webkit_uri_scheme_request_finish(request, stream,
g_bytes_get_size(data), "text/plain");
}
Some fine print applies
⚠️CORS Ahead! ⚠️
Embedded WPE WebKit
Adrian Perez de Castro, 2024-04-17
22 / 34
Integration:
User Script Messages
Embedded WPE WebKit
Adrian Perez de Castro, 2024-04-17
23 / 34
Integration:
User Script Messages
static void
configure_content_manager(WebKitUserContentManager *mgr) {
webkit_user_content_manager_register_script_message_handler_with_reply(
mgr, "bluetooth", NULL);
g_signal_connect(mgr,
"script-message-with-reply-received::bluetooth",
G_CALLBACK(handle_bluetooth), NULL);
}
Embedded WPE WebKit
Adrian Perez de Castro, 2024-04-17
23 / 34
Integration:
User Script Messages
static void
configure_content_manager(WebKitUserContentManager *mgr) {
webkit_user_content_manager_register_script_message_handler_with_reply(
mgr, "bluetooth", NULL);
g_signal_connect(mgr,
"script-message-with-reply-received::bluetooth",
G_CALLBACK(handle_bluetooth), NULL);
}
static gboolean
handle_bluetooth(WebKitUserContentManager *mgr, JSCValue *value,
WebKitScriptMessageReply *reply) {
g_autoptr(JSCValue) result = /* ... */;
webkit_script_message_reply_return_value(reply, result);
}
Embedded WPE WebKit
Adrian Perez de Castro, 2024-04-17
23 / 34
Integration:
User Script Messages
static void
configure_content_manager(WebKitUserContentManager *mgr) {
webkit_user_content_manager_register_script_message_handler_with_reply(
mgr, "bluetooth", NULL);
g_signal_connect(mgr,
"script-message-with-reply-received::bluetooth",
G_CALLBACK(handle_bluetooth), NULL);
}
static gboolean
handle_bluetooth(WebKitUserContentManager *mgr, JSCValue *value,
WebKitScriptMessageReply *reply) {
g_autoptr(JSCValue) result = /* ... */;
webkit_script_message_reply_return_value(reply, result);
}
function PairBluetooth(btAddr) {
const m = { kind: "pair", target: btAddr };
return window.webkit.messageHandlers.bluetooth.postMessage(m);
}
// Elsewhere:
const device = await PairBluetooth("FD:FD:34:00:00:01");
console.log("Paired with:", device.name);
Embedded WPE WebKit
Adrian Perez de Castro, 2024-04-17
23 / 34
Integration:
User Script Messages
static void
configure_content_manager(WebKitUserContentManager *mgr) {
webkit_user_content_manager_register_script_message_handler_with_reply(
mgr, "bluetooth", NULL);
g_signal_connect(mgr,
"script-message-with-reply-received::bluetooth",
G_CALLBACK(handle_bluetooth), NULL);
}
static gboolean
handle_bluetooth(WebKitUserContentManager *mgr, JSCValue *value,
WebKitScriptMessageReply *reply) {
g_autoptr(JSCValue) result = /* ... */;
webkit_script_message_reply_return_value(reply, result);
}
function PairBluetooth(btAddr) {
const m = { kind: "pair", target: btAddr };
return window.webkit.messageHandlers.bluetooth.postMessage(m);
}
// Elsewhere:
const device = await PairBluetooth("FD:FD:34:00:00:01");
console.log("Paired with:", device.name);
📨Async
Involves message passing
Embedded WPE WebKit
Adrian Perez de Castro, 2024-04-17
23 / 34
Integration: JSC API
Embedded WPE WebKit
Adrian Perez de Castro, 2024-04-17
24 / 34
Integration: JSC API
static void native_print(JSCValue *value) {
g_autofree char *value_string =
jsc_value_to_string(value);
printf("%sn", value_string);
}
Embedded WPE WebKit
Adrian Perez de Castro, 2024-04-17
24 / 34
Integration: JSC API
static void native_print(JSCValue *value) {
g_autofree char *value_string =
jsc_value_to_string(value);
printf("%sn", value_string);
}
static void register_print(JSCContext *context) {
g_autoptr(JSCValue) func =
jsc_value_new_function(context, "print", G_CALLBACK(native_print),
NULL, NULL, G_TYPE_NONE, 1, JSC_TYPE_VALUE);
jsc_context_set_value(context, "print", func);
}
Embedded WPE WebKit
Adrian Perez de Castro, 2024-04-17
24 / 34
Integration: JSC API
static void native_print(JSCValue *value) {
g_autofree char *value_string =
jsc_value_to_string(value);
printf("%sn", value_string);
}
static void register_print(JSCContext *context) {
g_autoptr(JSCValue) func =
jsc_value_new_function(context, "print", G_CALLBACK(native_print),
NULL, NULL, G_TYPE_NONE, 1, JSC_TYPE_VALUE);
jsc_context_set_value(context, "print", func);
}
It works!
print(3 + 2);
Embedded WPE WebKit
Adrian Perez de Castro, 2024-04-17
24 / 34
Integration: JSCContext
Standalone program:
jsc_context_new().
Web process extension
In the Web Process:
WebKitWebExtension::page-created
webkit_script_world_get_default()
WebKitScriptWorld::window-object-cleared
webkit_frame_get_js_context_for_script_world()
In the IU Process (browser):
webkit_web_context_set_web_process_extensions_directory()
Embedded WPE WebKit
Adrian Perez de Castro, 2024-04-17
25 / 34
Integration: Resources
Blog: .
Reference: .
Reference: .
Reference: .
URI Scheme Handlers and Script Messages
WPE WebKit API
Web Process Extension API
JSC API
Embedded WPE WebKit
Adrian Perez de Castro, 2024-04-17
26 / 34
Done, now what?
Embedded WPE WebKit
Adrian Perez de Castro, 2024-04-17
27 / 34
Now What? Updates
We are trying hard to make updating WPE WebKit hassle-free:
Feature each March and September.
Documented dependencies , .
Recommended .
Stable API + ABI. New features typically backwards-compatible.
releases
policy GCC requirements
practices for security updates
Embedded WPE WebKit
Adrian Perez de Castro, 2024-04-17
28 / 34
Should I ship updates?
Embedded WPE WebKit
Adrian Perez de Castro, 2024-04-17
29 / 34
Should I ship updates?
YES
YES
YES
Embedded WPE WebKit
Adrian Perez de Castro, 2024-04-17
29 / 34
Updates — Some tips
Pick minor releases with security fixes. These rarely break.
Consider using WebDriver for automated testing.
Avoid patching WPE WebKit, follow upstream if possible.
Parallel integration queue that uses development releases.
Design your QA for testing updates, too!
Embedded WPE WebKit
Adrian Perez de Castro, 2024-04-17
30 / 34
Takeaways 🥡
Embedded WPE WebKit
Adrian Perez de Castro, 2024-04-17
31 / 34
Takeaways 🥡
WPE can fit your needs.
Hardware checklist.
Prefer OSS drivers.
Prefer common hardware.
Do ship updates.
Avoid rolling your browser.
Reuse parts of another.
Avoid local HTTP servers.
Try easier integration.
QA for WPE + Web apps.
Embedded WPE WebKit
Adrian Perez de Castro, 2024-04-17
31 / 34
Q&A
ℹ
Embedded WPE WebKit
Adrian Perez de Castro, 2024-04-17
32 / 34
Bonus Track
WPE WebKit can be used headless.
The JSC API can be used standalone.
Resource usage can be limited with cgroups
Memory limits.
CPU usage.
Hardening:
Run as non-root.
Use containers/namespaces.
Built-in Bubblewrap sandbox.
Embedded WPE WebKit
Adrian Perez de Castro, 2024-04-17
33 / 34
34 / 34

More Related Content

Similar to Embedding WPE WebKit - from Bring-up to Maintenance

Benefit of CodeIgniter php framework
Benefit of CodeIgniter php frameworkBenefit of CodeIgniter php framework
Benefit of CodeIgniter php framework
Bo-Yi Wu
 

Similar to Embedding WPE WebKit - from Bring-up to Maintenance (20)

Global domination with kentico
Global domination with kenticoGlobal domination with kentico
Global domination with kentico
 
A Love Story with Kubevirt and Backstage from Cloud Native NoVA meetup Feb 2024
A Love Story with Kubevirt and Backstage from Cloud Native NoVA meetup Feb 2024A Love Story with Kubevirt and Backstage from Cloud Native NoVA meetup Feb 2024
A Love Story with Kubevirt and Backstage from Cloud Native NoVA meetup Feb 2024
 
Igalia Focus and Goals 2020 (2019 WebKit Contributors Meeting)
Igalia Focus and Goals 2020 (2019 WebKit Contributors Meeting)Igalia Focus and Goals 2020 (2019 WebKit Contributors Meeting)
Igalia Focus and Goals 2020 (2019 WebKit Contributors Meeting)
 
Deploying windows containers with kubernetes
Deploying windows containers with kubernetesDeploying windows containers with kubernetes
Deploying windows containers with kubernetes
 
Moving Kentico Cms To The Azure
Moving Kentico Cms To The AzureMoving Kentico Cms To The Azure
Moving Kentico Cms To The Azure
 
Advanced coding & deployment for Cisco Video Devices - CL20B - DEVNET-3244
Advanced coding & deployment for Cisco Video Devices - CL20B - DEVNET-3244Advanced coding & deployment for Cisco Video Devices - CL20B - DEVNET-3244
Advanced coding & deployment for Cisco Video Devices - CL20B - DEVNET-3244
 
Quebec - 16 November 2022 - Canada CNCF Meetups.pdf
Quebec - 16 November 2022 - Canada CNCF Meetups.pdfQuebec - 16 November 2022 - Canada CNCF Meetups.pdf
Quebec - 16 November 2022 - Canada CNCF Meetups.pdf
 
Docker Enterprise Workshop - Technical
Docker Enterprise Workshop - TechnicalDocker Enterprise Workshop - Technical
Docker Enterprise Workshop - Technical
 
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
 
What should you know about Net Core?
What should you know about Net Core?What should you know about Net Core?
What should you know about Net Core?
 
Webex Devices xAPI - DEVNET_2071 - Cisco Live - San Diego 2019
Webex Devices xAPI - DEVNET_2071 - Cisco Live - San Diego 2019Webex Devices xAPI - DEVNET_2071 - Cisco Live - San Diego 2019
Webex Devices xAPI - DEVNET_2071 - Cisco Live - San Diego 2019
 
Javascript Essentials - Cisco Live Barcelona 2019
Javascript Essentials - Cisco Live Barcelona 2019Javascript Essentials - Cisco Live Barcelona 2019
Javascript Essentials - Cisco Live Barcelona 2019
 
Spring on Kubernetes
Spring on KubernetesSpring on Kubernetes
Spring on Kubernetes
 
Pivotal Platform - December Release A First Look
Pivotal Platform - December Release A First LookPivotal Platform - December Release A First Look
Pivotal Platform - December Release A First Look
 
Benefit of CodeIgniter php framework
Benefit of CodeIgniter php frameworkBenefit of CodeIgniter php framework
Benefit of CodeIgniter php framework
 
GCP - Continuous Integration and Delivery into Kubernetes with GitHub, Travis...
GCP - Continuous Integration and Delivery into Kubernetes with GitHub, Travis...GCP - Continuous Integration and Delivery into Kubernetes with GitHub, Travis...
GCP - Continuous Integration and Delivery into Kubernetes with GitHub, Travis...
 
Scaling Docker Containers using Kubernetes and Azure Container Service
Scaling Docker Containers using Kubernetes and Azure Container ServiceScaling Docker Containers using Kubernetes and Azure Container Service
Scaling Docker Containers using Kubernetes and Azure Container Service
 
[workshop] The Revolutionary WebRTC
[workshop] The Revolutionary WebRTC[workshop] The Revolutionary WebRTC
[workshop] The Revolutionary WebRTC
 
DevNetCreate Workshop - build a react app - React crash course
DevNetCreate Workshop - build a react app - React crash courseDevNetCreate Workshop - build a react app - React crash course
DevNetCreate Workshop - build a react app - React crash course
 
Link. apache wicket [santi caltabiano]
  Link. apache wicket [santi caltabiano]  Link. apache wicket [santi caltabiano]
Link. apache wicket [santi caltabiano]
 

More from 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
 

More from 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
 
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
 
Enable hardware acceleration for GL applications without glamor on Xorg modes...
Enable hardware acceleration for GL applications without glamor on Xorg modes...Enable hardware acceleration for GL applications without glamor on Xorg modes...
Enable hardware acceleration for GL applications without glamor on Xorg modes...
 

Recently uploaded

Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Victor Rentea
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
panagenda
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Victor Rentea
 

Recently uploaded (20)

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
 
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
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
Decarbonising Commercial Real Estate: The Role of Operational Performance
Decarbonising Commercial Real Estate: The Role of Operational PerformanceDecarbonising Commercial Real Estate: The Role of Operational Performance
Decarbonising Commercial Real Estate: The Role of Operational Performance
 
JohnPollard-hybrid-app-RailsConf2024.pptx
JohnPollard-hybrid-app-RailsConf2024.pptxJohnPollard-hybrid-app-RailsConf2024.pptx
JohnPollard-hybrid-app-RailsConf2024.pptx
 
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
 
Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
 
ChatGPT and Beyond - Elevating DevOps Productivity
ChatGPT and Beyond - Elevating DevOps ProductivityChatGPT and Beyond - Elevating DevOps Productivity
ChatGPT and Beyond - Elevating DevOps Productivity
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
Navigating Identity and Access Management in the Modern Enterprise
Navigating Identity and Access Management in the Modern EnterpriseNavigating Identity and Access Management in the Modern Enterprise
Navigating Identity and Access Management in the Modern Enterprise
 
Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
How to Check CNIC Information Online with Pakdata cf
How to Check CNIC Information Online with Pakdata cfHow to Check CNIC Information Online with Pakdata cf
How to Check CNIC Information Online with Pakdata cf
 

Embedding WPE WebKit - from Bring-up to Maintenance

  • 1. Embedded WPE WebKit From Bring-Up to Maintenance Adrian Perez de Castro aperez@igalia.com 1 / 34
  • 2. About Me CS Engineer, partner of Igalia. Systems person turned web engine developer. WebKit jack of all trades since ~2012. Current focus: platform layer, hardware bringup, release management. I like old computers, too! Embedded WPE WebKit Adrian Perez de Castro, 2024-04-17 2 / 34
  • 3. About Igalia Specialized Open Source consultancy, founded in 2001 Fully remote, HQ in A Coruña (Spain). Flat structure. Top contributors to all the main Web Rendering Engines WebKit, Chromium, Gecko and Servo Active contributor to other areas and OSS projects V8, SpiderMonkey, JSC, LLVM, Node.js, GStreamer, Mesa, Linux Kernel... Members of several working groups: W3C, WHATWG, WPT, TC39, OpenJS, Test262, Khronos... Embedded WPE WebKit Adrian Perez de Castro, 2024-04-17 3 / 34
  • 4. Agenda 1. WPE WebKit 101 2. Adding WPE to your device 3. Done! Now what? Embedded WPE WebKit Adrian Perez de Castro, 2024-04-17 4 / 34
  • 5. WPE WebKit 101 Embedded WPE WebKit Adrian Perez de Castro, 2024-04-17 5 / 34
  • 6. 101: What is WebKit Open Source Web Engine: Ingests HTML/CSS/JavaScript/etc. Produces rendered content. Port-able: Port = Adaptation for a specific platform. Runs in more places than one may imagine. The WPE port focuses on Linux-based embedded devices. Multi-process architecture. Embedded WPE WebKit Adrian Perez de Castro, 2024-04-17 6 / 34
  • 7. 101: Why a Web Engine? Software The Web is eating the world Embedded WPE WebKit Adrian Perez de Castro, 2024-04-17 7 / 34
  • 8. 101: Why a Web Engine? Software The Web is eating the world “There is an app a website for that.” Embedded WPE WebKit Adrian Perez de Castro, 2024-04-17 7 / 34
  • 9. 101: Why a Web Engine? Software The Web is eating the world “There is an app a website for that.” Embedded hardware is powerful enough now since ~2013. Embedded WPE WebKit Adrian Perez de Castro, 2024-04-17 7 / 34
  • 10. 101: Why a Web Engine? Software The Web is eating the world “There is an app a website for that.” Embedded hardware is powerful enough now since ~2013. Prototype and iterate harder, better, faster stronger. Embedded WPE WebKit Adrian Perez de Castro, 2024-04-17 7 / 34
  • 11. 101: Why WPE WebKit? Platformless WebKit port. Designed to be embeddable: Embedded WPE WebKit Adrian Perez de Castro, 2024-04-17 8 / 34
  • 12. 101: Why WPE WebKit? Platformless WebKit port. Designed to be embeddable: Extensible, Embedded WPE WebKit Adrian Perez de Castro, 2024-04-17 8 / 34
  • 13. 101: Why WPE WebKit? Platformless WebKit port. Designed to be embeddable: Extensible, Adaptable, Embedded WPE WebKit Adrian Perez de Castro, 2024-04-17 8 / 34
  • 14. 101: Why WPE WebKit? Platformless WebKit port. Designed to be embeddable: Extensible, Adaptable, Minimal dependencies. Embedded WPE WebKit Adrian Perez de Castro, 2024-04-17 8 / 34
  • 15. 101: Why WPE WebKit? Available yesterday: Embedded WPE WebKit Adrian Perez de Castro, 2024-04-17 9 / 34
  • 16. 101: Why WPE WebKit? Available yesterday: Build systems: Yocto, Buildroot, PTXdist; Embedded WPE WebKit Adrian Perez de Castro, 2024-04-17 9 / 34
  • 17. 101: Why WPE WebKit? Available yesterday: Build systems: Yocto, Buildroot, PTXdist; Distributions: Debian, Ubuntu, Arch. Embedded WPE WebKit Adrian Perez de Castro, 2024-04-17 9 / 34
  • 18. 101: Why WPE WebKit? Available yesterday: Build systems: Yocto, Buildroot, PTXdist; Distributions: Debian, Ubuntu, Arch. WPE has existed for 6+ years. Embedded WPE WebKit Adrian Perez de Castro, 2024-04-17 9 / 34
  • 19. 101: Multiprocess WebKit UI Process Embeds a WebKitWebView. This is your browser application. WebProcess: Handles Web content. Many of them, per-site isolation. Network Process Embedded WPE WebKit Adrian Perez de Castro, 2024-04-17 10 / 34
  • 20. Adding WPE to Your Device Act I: Bringup Embedded WPE WebKit Adrian Perez de Castro, 2024-04-17 11 / 34
  • 21. Check List Is my ? hardware supported Embedded WPE WebKit Adrian Perez de Castro, 2024-04-17 12 / 34
  • 22. Check List Is my ? hardware supported Yes It's your lucky day! ☘️ Embedded WPE WebKit Adrian Perez de Castro, 2024-04-17 12 / 34
  • 23. Check List Is my ? hardware supported Yes It's your lucky day! ☘️ No There are some requirements. Embedded WPE WebKit Adrian Perez de Castro, 2024-04-17 12 / 34
  • 24. Check List Minimum OpenGL ES 2.0 Buffer sharing Desirable 64-bit CPU EGL/GLES extensions Embedded WPE WebKit Adrian Perez de Castro, 2024-04-17 13 / 34
  • 25. Check List Minimum OpenGL ES 2.0 Buffer sharing Desirable 64-bit CPU EGL/GLES extensions EGL_KHR_image_base EGL_KHR_surfaceless_context EGL_EXT_image_dma_buf_import EGL_EXT_image_dma_buf_import_modifiers EGL_MESA_image_dma_buf_export Embedded WPE WebKit Adrian Perez de Castro, 2024-04-17 13 / 34
  • 26. Pain Point: GPU Drivers 🖥️ Embedded WPE WebKit Adrian Perez de Castro, 2024-04-17 14 / 34
  • 27. Pain Point: GPU Drivers 🖥️ Wayland/DMA-BUF support Lack of OpenGL ES 3+ Vulkan-only drivers Unusable driver Embedded WPE WebKit Adrian Perez de Castro, 2024-04-17 14 / 34
  • 28. Pain Point: GPU Drivers 🖥️ Wayland/DMA-BUF support Lack of OpenGL ES 3+ Vulkan-only drivers Unusable driver Steadily improving GLESv2 as baseline Zink usable, seldom tested Mesa swrast/llvmpipe Embedded WPE WebKit Adrian Perez de Castro, 2024-04-17 14 / 34
  • 29. Pain Point: GPU Drivers 🖥️ Wayland/DMA-BUF support Lack of OpenGL ES 3+ Vulkan-only drivers Unusable driver Steadily improving GLESv2 as baseline Zink usable, seldom tested Mesa swrast/llvmpipe Prefer Open Source drivers 💫 Embedded WPE WebKit Adrian Perez de Castro, 2024-04-17 14 / 34
  • 30. Pain Point: “Funny” HW 📟 Embedded WPE WebKit Adrian Perez de Castro, 2024-04-17 15 / 34
  • 31. Pain Point: “Funny” HW 📟 Not 32-bpp RGB565 incantation. DMA-BUF. Little testing. Embedded WPE WebKit Adrian Perez de Castro, 2024-04-17 15 / 34
  • 32. Pain Point: “Funny” HW 📟 Not 32-bpp RGB565 incantation. DMA-BUF. Little testing. Rotated/Flipped Works on Wayland. Okay-ish on DRM/KMS. Embedded WPE WebKit Adrian Perez de Castro, 2024-04-17 15 / 34
  • 33. Pain Point: “Funny” HW 📟 Not 32-bpp RGB565 incantation. DMA-BUF. Little testing. Rotated/Flipped Works on Wayland. Okay-ish on DRM/KMS. Bare metal Exotic connections. Legacy: fbdev 😓. Embedded WPE WebKit Adrian Perez de Castro, 2024-04-17 15 / 34
  • 34. Pain Point: “Funny” HW 📟 Not 32-bpp RGB565 incantation. DMA-BUF. Little testing. Rotated/Flipped Works on Wayland. Okay-ish on DRM/KMS. Bare metal Exotic connections. Legacy: fbdev 😓. Prefer common technologies 💫 Embedded WPE WebKit Adrian Perez de Castro, 2024-04-17 15 / 34
  • 35. Adding WPE to Your Device Act II: Browser Embedded WPE WebKit Adrian Perez de Castro, 2024-04-17 16 / 34
  • 36. Choosing a Browser (In increasing order of complexity.) Embedded WPE WebKit Adrian Perez de Castro, 2024-04-17 17 / 34
  • 37. Choosing a Browser (In increasing order of complexity.) Use . Cog Embedded WPE WebKit Adrian Perez de Castro, 2024-04-17 17 / 34
  • 38. Choosing a Browser (In increasing order of complexity.) Use . Cog Use . libcogcore Embedded WPE WebKit Adrian Perez de Castro, 2024-04-17 17 / 34
  • 39. Choosing a Browser (In increasing order of complexity.) Use . Cog Use . libcogcore Roll your own. Embedded WPE WebKit Adrian Perez de Castro, 2024-04-17 17 / 34
  • 40. Browser: libcogcore #include <cog/cog.h> static const char *s_starturl = NULL; static WebKitWebView* on_create_view(CogShell *shell, CogPlatform *platform) { WebKitWebViewBackend *view_backend = cog_platform_get_view_backend(platform, NULL, NULL); g_autoptr(WebKitWebView) web_view = g_object_new(WEBKIT_TYPE_WEB_VIEW, "settings", cog_shell_get_web_settings(shell), "web-context", cog_shell_get_web_context(shell), "backend", view_backend, NULL); cog_platform_init_web_view(platform, web_view); webkit_web_view_load_uri(web_view, s_starturl); return g_steal_pointer(&web_view); } int main(int argc, char *argv[]) { g_set_application_name("minicog"); if (argc != 2 && argc != 3) g_error("Usage: %s [URL [platform]]n", argv[0]); s_starturl = cog_uri_guess_from_user_input(argv[1], TRUE, NULL); cog_modules_add_directory(COG_MODULEDIR); g_autoptr(GApplication) app = g_application_new(NULL, G_APPLICATION_DEFAULT_FLAGS); g_autoptr(CogShell) shell = cog_shell_new("minicog", FALSE); g_autoptr(CogPlatform) platform = cog_platform_new(g_getenv("COG_PLATFORM"), NULL); cog_platform_setup(platform, shell, "", NULL); g_signal_connect(shell, "create-view", G_CALLBACK(on_create_view), platform); g_signal_connect_swapped(app, "shutdown", G_CALLBACK(cog_shell_shutdown), shell); g_signal_connect_swapped(app, "startup", G_CALLBACK(cog_shell_startup), shell); g_signal_connect(app, "activate", G_CALLBACK(g_application_hold), NULL); return g_application_run(app, 1, argv); } Embedded WPE WebKit Adrian Perez de Castro, 2024-04-17 18 / 34
  • 41. Browser: WPE Platform API #include <wpe/webkit.h> int main(int argc, const char *argv[]) { g_autoptr(GMainLoop) loop = g_main_loop_new(NULL, FALSE); g_autoptr(WebKitWebView) view = webkit_web_view_new(NULL); webkit_web_view_load_uri(view, (argc > 1) ? argv[1] : "https://wpewebkit.org"); g_main_loop_run(loop); return EXIT_SUCCESS; } Embedded WPE WebKit Adrian Perez de Castro, 2024-04-17 19 / 34
  • 42. Adding WPE to Your Device Act III: Integration Embedded WPE WebKit Adrian Perez de Castro, 2024-04-17 20 / 34
  • 43. Motivation Make Web content talk to your hardware Embedded WPE WebKit Adrian Perez de Castro, 2024-04-17 21 / 34
  • 44. Motivation Make Web content talk to your hardware Local web server! Local web server! Embedded WPE WebKit Adrian Perez de Castro, 2024-04-17 21 / 34
  • 45. Motivation Make Web content talk to your hardware Embedded WPE WebKit Adrian Perez de Castro, 2024-04-17 21 / 34
  • 46. Integration: URI Scheme Handler Embedded WPE WebKit Adrian Perez de Castro, 2024-04-17 22 / 34
  • 47. Integration: URI Scheme Handler static void configure_web_context(WebKitWebContext *context) { webkit_web_context_register_uri_scheme(context, "echo", (WebKitURISchemeRequestCallback) handle_echo_scheme, NULL /* userdata */, NULL /* destroy_notify */); } Embedded WPE WebKit Adrian Perez de Castro, 2024-04-17 22 / 34
  • 48. Integration: URI Scheme Handler static void configure_web_context(WebKitWebContext *context) { webkit_web_context_register_uri_scheme(context, "echo", (WebKitURISchemeRequestCallback) handle_echo_scheme, NULL /* userdata */, NULL /* destroy_notify */); } static void handle_echo_scheme(WebKitURISchemeRequest *r) { const char *uri = webkit_uri_scheme_request_get_uri(r); g_autoptr(GBytes) data = g_bytes_new(uri, strlen(uri)); g_autoptr(GInputStream) stream = g_memory_input_stream_new_from_bytes(data); webkit_uri_scheme_request_finish(request, stream, g_bytes_get_size(data), "text/plain"); } Embedded WPE WebKit Adrian Perez de Castro, 2024-04-17 22 / 34
  • 49. Integration: URI Scheme Handler static void configure_web_context(WebKitWebContext *context) { webkit_web_context_register_uri_scheme(context, "echo", (WebKitURISchemeRequestCallback) handle_echo_scheme, NULL /* userdata */, NULL /* destroy_notify */); } static void handle_echo_scheme(WebKitURISchemeRequest *r) { const char *uri = webkit_uri_scheme_request_get_uri(r); g_autoptr(GBytes) data = g_bytes_new(uri, strlen(uri)); g_autoptr(GInputStream) stream = g_memory_input_stream_new_from_bytes(data); webkit_uri_scheme_request_finish(request, stream, g_bytes_get_size(data), "text/plain"); } Some fine print applies ⚠️CORS Ahead! ⚠️ Embedded WPE WebKit Adrian Perez de Castro, 2024-04-17 22 / 34
  • 50. Integration: User Script Messages Embedded WPE WebKit Adrian Perez de Castro, 2024-04-17 23 / 34
  • 51. Integration: User Script Messages static void configure_content_manager(WebKitUserContentManager *mgr) { webkit_user_content_manager_register_script_message_handler_with_reply( mgr, "bluetooth", NULL); g_signal_connect(mgr, "script-message-with-reply-received::bluetooth", G_CALLBACK(handle_bluetooth), NULL); } Embedded WPE WebKit Adrian Perez de Castro, 2024-04-17 23 / 34
  • 52. Integration: User Script Messages static void configure_content_manager(WebKitUserContentManager *mgr) { webkit_user_content_manager_register_script_message_handler_with_reply( mgr, "bluetooth", NULL); g_signal_connect(mgr, "script-message-with-reply-received::bluetooth", G_CALLBACK(handle_bluetooth), NULL); } static gboolean handle_bluetooth(WebKitUserContentManager *mgr, JSCValue *value, WebKitScriptMessageReply *reply) { g_autoptr(JSCValue) result = /* ... */; webkit_script_message_reply_return_value(reply, result); } Embedded WPE WebKit Adrian Perez de Castro, 2024-04-17 23 / 34
  • 53. Integration: User Script Messages static void configure_content_manager(WebKitUserContentManager *mgr) { webkit_user_content_manager_register_script_message_handler_with_reply( mgr, "bluetooth", NULL); g_signal_connect(mgr, "script-message-with-reply-received::bluetooth", G_CALLBACK(handle_bluetooth), NULL); } static gboolean handle_bluetooth(WebKitUserContentManager *mgr, JSCValue *value, WebKitScriptMessageReply *reply) { g_autoptr(JSCValue) result = /* ... */; webkit_script_message_reply_return_value(reply, result); } function PairBluetooth(btAddr) { const m = { kind: "pair", target: btAddr }; return window.webkit.messageHandlers.bluetooth.postMessage(m); } // Elsewhere: const device = await PairBluetooth("FD:FD:34:00:00:01"); console.log("Paired with:", device.name); Embedded WPE WebKit Adrian Perez de Castro, 2024-04-17 23 / 34
  • 54. Integration: User Script Messages static void configure_content_manager(WebKitUserContentManager *mgr) { webkit_user_content_manager_register_script_message_handler_with_reply( mgr, "bluetooth", NULL); g_signal_connect(mgr, "script-message-with-reply-received::bluetooth", G_CALLBACK(handle_bluetooth), NULL); } static gboolean handle_bluetooth(WebKitUserContentManager *mgr, JSCValue *value, WebKitScriptMessageReply *reply) { g_autoptr(JSCValue) result = /* ... */; webkit_script_message_reply_return_value(reply, result); } function PairBluetooth(btAddr) { const m = { kind: "pair", target: btAddr }; return window.webkit.messageHandlers.bluetooth.postMessage(m); } // Elsewhere: const device = await PairBluetooth("FD:FD:34:00:00:01"); console.log("Paired with:", device.name); 📨Async Involves message passing Embedded WPE WebKit Adrian Perez de Castro, 2024-04-17 23 / 34
  • 55. Integration: JSC API Embedded WPE WebKit Adrian Perez de Castro, 2024-04-17 24 / 34
  • 56. Integration: JSC API static void native_print(JSCValue *value) { g_autofree char *value_string = jsc_value_to_string(value); printf("%sn", value_string); } Embedded WPE WebKit Adrian Perez de Castro, 2024-04-17 24 / 34
  • 57. Integration: JSC API static void native_print(JSCValue *value) { g_autofree char *value_string = jsc_value_to_string(value); printf("%sn", value_string); } static void register_print(JSCContext *context) { g_autoptr(JSCValue) func = jsc_value_new_function(context, "print", G_CALLBACK(native_print), NULL, NULL, G_TYPE_NONE, 1, JSC_TYPE_VALUE); jsc_context_set_value(context, "print", func); } Embedded WPE WebKit Adrian Perez de Castro, 2024-04-17 24 / 34
  • 58. Integration: JSC API static void native_print(JSCValue *value) { g_autofree char *value_string = jsc_value_to_string(value); printf("%sn", value_string); } static void register_print(JSCContext *context) { g_autoptr(JSCValue) func = jsc_value_new_function(context, "print", G_CALLBACK(native_print), NULL, NULL, G_TYPE_NONE, 1, JSC_TYPE_VALUE); jsc_context_set_value(context, "print", func); } It works! print(3 + 2); Embedded WPE WebKit Adrian Perez de Castro, 2024-04-17 24 / 34
  • 59. Integration: JSCContext Standalone program: jsc_context_new(). Web process extension In the Web Process: WebKitWebExtension::page-created webkit_script_world_get_default() WebKitScriptWorld::window-object-cleared webkit_frame_get_js_context_for_script_world() In the IU Process (browser): webkit_web_context_set_web_process_extensions_directory() Embedded WPE WebKit Adrian Perez de Castro, 2024-04-17 25 / 34
  • 60. Integration: Resources Blog: . Reference: . Reference: . Reference: . URI Scheme Handlers and Script Messages WPE WebKit API Web Process Extension API JSC API Embedded WPE WebKit Adrian Perez de Castro, 2024-04-17 26 / 34
  • 61. Done, now what? Embedded WPE WebKit Adrian Perez de Castro, 2024-04-17 27 / 34
  • 62. Now What? Updates We are trying hard to make updating WPE WebKit hassle-free: Feature each March and September. Documented dependencies , . Recommended . Stable API + ABI. New features typically backwards-compatible. releases policy GCC requirements practices for security updates Embedded WPE WebKit Adrian Perez de Castro, 2024-04-17 28 / 34
  • 63. Should I ship updates? Embedded WPE WebKit Adrian Perez de Castro, 2024-04-17 29 / 34
  • 64. Should I ship updates? YES YES YES Embedded WPE WebKit Adrian Perez de Castro, 2024-04-17 29 / 34
  • 65. Updates — Some tips Pick minor releases with security fixes. These rarely break. Consider using WebDriver for automated testing. Avoid patching WPE WebKit, follow upstream if possible. Parallel integration queue that uses development releases. Design your QA for testing updates, too! Embedded WPE WebKit Adrian Perez de Castro, 2024-04-17 30 / 34
  • 66. Takeaways 🥡 Embedded WPE WebKit Adrian Perez de Castro, 2024-04-17 31 / 34
  • 67. Takeaways 🥡 WPE can fit your needs. Hardware checklist. Prefer OSS drivers. Prefer common hardware. Do ship updates. Avoid rolling your browser. Reuse parts of another. Avoid local HTTP servers. Try easier integration. QA for WPE + Web apps. Embedded WPE WebKit Adrian Perez de Castro, 2024-04-17 31 / 34
  • 68. Q&A ℹ Embedded WPE WebKit Adrian Perez de Castro, 2024-04-17 32 / 34
  • 69. Bonus Track WPE WebKit can be used headless. The JSC API can be used standalone. Resource usage can be limited with cgroups Memory limits. CPU usage. Hardening: Run as non-root. Use containers/namespaces. Built-in Bubblewrap sandbox. Embedded WPE WebKit Adrian Perez de Castro, 2024-04-17 33 / 34